diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index c41f2d3299bf7..17bac362ec81f 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -731,28 +731,22 @@ impl<'a> Parser<'a> { match x { Ok((_, _, false)) => { if self.eat(&token::Gt) { - let turbo_err = e.span_suggestion_verbose( + e.span_suggestion_verbose( binop.span.shrink_to_lo(), TURBOFISH_SUGGESTION_STR, "::".to_string(), Applicability::MaybeIncorrect, - ); - if self.check(&TokenKind::Semi) { - turbo_err.emit(); - *expr = self.mk_expr_err(expr.span); - return Ok(()); - } else { - match self.parse_expr() { - Ok(_) => { - turbo_err.emit(); - *expr = self - .mk_expr_err(expr.span.to(self.prev_token.span)); - return Ok(()); - } - Err(mut err) => { - turbo_err.cancel(); - err.cancel(); - } + ) + .emit(); + match self.parse_expr() { + Ok(_) => { + *expr = + self.mk_expr_err(expr.span.to(self.prev_token.span)); + return Ok(()); + } + Err(mut err) => { + *expr = self.mk_expr_err(expr.span); + err.cancel(); } } } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 26284728ff2c6..693dd0051dad1 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1458,7 +1458,7 @@ impl<'a> Parser<'a> { self.parse_block_expr(label, lo, BlockCheckMode::Default, attrs) } else if !ate_colon && (self.check(&TokenKind::Comma) || self.check(&TokenKind::Gt)) { // We're probably inside of a `Path<'a>` that needs a turbofish, so suppress the - // "must be followed by a colon" error. + // "must be followed by a colon" error, and the "expected one of" error. self.diagnostic().delay_span_bug(lo, "this label wasn't parsed correctly"); consume_colon = false; Ok(self.mk_expr_err(lo)) diff --git a/src/test/ui/parser/issues/issue-93282.rs b/src/test/ui/parser/issues/issue-93282.rs new file mode 100644 index 0000000000000..7be8b25363e09 --- /dev/null +++ b/src/test/ui/parser/issues/issue-93282.rs @@ -0,0 +1,4 @@ +fn main() { + f<'a,> + //~^ ERROR expected +} diff --git a/src/test/ui/parser/issues/issue-93282.stderr b/src/test/ui/parser/issues/issue-93282.stderr new file mode 100644 index 0000000000000..20e6c3ed8a8d5 --- /dev/null +++ b/src/test/ui/parser/issues/issue-93282.stderr @@ -0,0 +1,13 @@ +error: expected one of `.`, `:`, `;`, `?`, `for`, `loop`, `while`, `{`, `}`, or an operator, found `,` + --> $DIR/issue-93282.rs:2:9 + | +LL | f<'a,> + | ^ expected one of 10 possible tokens + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | f::<'a,> + | ++ + +error: aborting due to previous error +