Skip to content

Commit 119bc97

Browse files
authored
Rollup merge of #69014 - dwrensha:fix-68890, r=Centril
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.
2 parents db08784 + 371060b commit 119bc97

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/librustc_parse/parser/ty.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ impl<'a> Parser<'a> {
214214
let path = match bounds.remove(0) {
215215
GenericBound::Trait(pt, ..) => pt.trait_ref.path,
216216
GenericBound::Outlives(..) => {
217-
self.span_bug(ty.span, "unexpected lifetime bound")
217+
return Err(self.struct_span_err(
218+
ty.span,
219+
"expected trait bound, not lifetime bound",
220+
));
218221
}
219222
};
220223
self.parse_remaining_bounds(Vec::new(), path, lo, true)

src/test/ui/parser/issue-68890.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
enum e{A((?'a a+?+l))}
2+
//~^ ERROR `?` may only modify trait bounds, not lifetime bounds
3+
//~| ERROR expected one of `)`, `+`, or `,`
4+
//~| ERROR expected trait bound, not lifetime bound

src/test/ui/parser/issue-68890.stderr

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: `?` may only modify trait bounds, not lifetime bounds
2+
--> $DIR/issue-68890.rs:1:11
3+
|
4+
LL | enum e{A((?'a a+?+l))}
5+
| ^
6+
7+
error: expected one of `)`, `+`, or `,`, found `a`
8+
--> $DIR/issue-68890.rs:1:15
9+
|
10+
LL | enum e{A((?'a a+?+l))}
11+
| ^ expected one of `)`, `+`, or `,`
12+
13+
error: expected trait bound, not lifetime bound
14+
--> $DIR/issue-68890.rs:1:11
15+
|
16+
LL | enum e{A((?'a a+?+l))}
17+
| ^^^
18+
19+
error: aborting due to 3 previous errors
20+

0 commit comments

Comments
 (0)