Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e69e05b

Browse files
committedApr 28, 2019
Ignore trailing commas in ExpectedDebug
rust-lang/rust/pull/59076 changed the multiline Debug representation to always include a trailing comma. This change currently breaks our tests on beta and nightly, since we use this Debug representation to compare expected parsing output. We cannot simply add the trailing commas to the expected output strings, since that would break on older rustc versions we support. Instead, this commit makes it so that all trailing commas are stripped before the comparison. This workaround can be removed once rust-lang/rust/pull/59076 reaches our minimum supported rustc version.
1 parent 4643478 commit e69e05b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
 

‎lalrpop-test/src/util/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ struct ExpectedDebug<'a>(&'a str);
6666

6767
impl<'a> Debug for ExpectedDebug<'a> {
6868
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
69-
write!(fmt, "{}", self.0)
69+
// Ignore trailing commas in multiline Debug representation.
70+
// Needed to work around rust-lang/rust#59076.
71+
let s = self.0.replace(",\n", "\n");
72+
write!(fmt, "{}", s)
7073
}
7174
}
7275

‎lalrpop/src/test_util.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ struct ExpectedDebug<'a>(&'a str);
1414

1515
impl<'a> Debug for ExpectedDebug<'a> {
1616
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
17-
write!(fmt, "{}", self.0)
17+
// Ignore trailing commas in multiline Debug representation.
18+
// Needed to work around rust-lang/rust#59076.
19+
let s = self.0.replace(",\n", "\n");
20+
write!(fmt, "{}", s)
1821
}
1922
}
2023

0 commit comments

Comments
 (0)