Skip to content

Commit

Permalink
Ignore trailing commas in ExpectedDebug (#455)
Browse files Browse the repository at this point in the history
* 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.

* Bump minimum Rust version to 1.31.0

That's required by the current version rustc-demangle, which is a
dependency of mdbook.
  • Loading branch information
teskje authored and Marwes committed Apr 30, 2019
1 parent 4643478 commit 9b5ec5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: rust
rust:
- 1.26.0
- 1.31.0
- beta
- nightly
cache:
Expand Down
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 9b5ec5f

Please sign in to comment.