Skip to content

Commit

Permalink
Ignore trailing commas in ExpectedDebug
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
teskje committed Apr 28, 2019
1 parent 4643478 commit e69e05b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lalrpop-test/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ struct ExpectedDebug<'a>(&'a str);

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

Expand Down
5 changes: 4 additions & 1 deletion lalrpop/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ struct ExpectedDebug<'a>(&'a str);

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

Expand Down

0 comments on commit e69e05b

Please sign in to comment.