diff --git a/src/librustc_parse/parser/ty.rs b/src/librustc_parse/parser/ty.rs index 990661bf6b5b9..a573a1ee69976 100644 --- a/src/librustc_parse/parser/ty.rs +++ b/src/librustc_parse/parser/ty.rs @@ -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) diff --git a/src/test/ui/parser/issue-68890.rs b/src/test/ui/parser/issue-68890.rs new file mode 100644 index 0000000000000..a7c5a5e13008a --- /dev/null +++ b/src/test/ui/parser/issue-68890.rs @@ -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 diff --git a/src/test/ui/parser/issue-68890.stderr b/src/test/ui/parser/issue-68890.stderr new file mode 100644 index 0000000000000..9bb8761b67b5f --- /dev/null +++ b/src/test/ui/parser/issue-68890.stderr @@ -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 +