Skip to content

Commit

Permalink
Rollup merge of #69014 - dwrensha:fix-68890, r=Centril
Browse files Browse the repository at this point in the history
change an instance of span_bug() to struct_span_err() to avoid ICE

After #67148, the `span_bug()` in `parse_ty_tuple_or_parens()` is reachable because `parse_paren_comma_seq()` can return an `Ok()` even in cases where it encounters an error.
This pull request prevents an ICE in such cases by replacing the `span_bug()` with `struct_span_error()`.

Fixes #68890.
  • Loading branch information
Dylan-DPC authored Feb 10, 2020
2 parents db08784 + 371060b commit 119bc97
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustc_parse/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ impl<'a> Parser<'a> {
let path = match bounds.remove(0) {
GenericBound::Trait(pt, ..) => pt.trait_ref.path,
GenericBound::Outlives(..) => {
self.span_bug(ty.span, "unexpected lifetime bound")
return Err(self.struct_span_err(
ty.span,
"expected trait bound, not lifetime bound",
));
}
};
self.parse_remaining_bounds(Vec::new(), path, lo, true)
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/parser/issue-68890.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
enum e{A((?'a a+?+l))}
//~^ ERROR `?` may only modify trait bounds, not lifetime bounds
//~| ERROR expected one of `)`, `+`, or `,`
//~| ERROR expected trait bound, not lifetime bound
20 changes: 20 additions & 0 deletions src/test/ui/parser/issue-68890.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error: `?` may only modify trait bounds, not lifetime bounds
--> $DIR/issue-68890.rs:1:11
|
LL | enum e{A((?'a a+?+l))}
| ^

error: expected one of `)`, `+`, or `,`, found `a`
--> $DIR/issue-68890.rs:1:15
|
LL | enum e{A((?'a a+?+l))}
| ^ expected one of `)`, `+`, or `,`

error: expected trait bound, not lifetime bound
--> $DIR/issue-68890.rs:1:11
|
LL | enum e{A((?'a a+?+l))}
| ^^^

error: aborting due to 3 previous errors

0 comments on commit 119bc97

Please sign in to comment.