diff options
| author | Michael Howell <michael@notriddle.com> | 2022-03-11 15:26:19 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-03-11 15:35:18 -0700 |
| commit | 7e323370b351ab138caa90cddb0e9811a4e8439d (patch) | |
| tree | b0fe363d415fb18615837d169a7048b4f5b6af64 /compiler/rustc_parse/src | |
| parent | c9b45e601065c3fb71a4f67481e912391d075621 (diff) | |
| download | rust-7e323370b351ab138caa90cddb0e9811a4e8439d.tar.gz rust-7e323370b351ab138caa90cddb0e9811a4e8439d.zip | |
diagnostics: single colon within `<>` probably, not type ascription
Fixes #94812
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 40daf4eb28f..5b398a51318 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -2073,6 +2073,19 @@ impl<'a> Parser<'a> { let value = self.mk_expr_err(start.to(expr.span)); err.emit(); return Ok(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value })); + } else if token::Colon == snapshot.token.kind + && expr.span.lo() == snapshot.token.span.hi() + && matches!(expr.kind, ExprKind::Path(..)) + { + // Find a mistake like "foo::var:A". + err.span_suggestion( + snapshot.token.span, + "you might have meant to write a path", + "::".to_string(), + Applicability::MaybeIncorrect, + ); + err.emit(); + return Ok(GenericArg::Type(self.mk_ty(start.to(expr.span), TyKind::Err))); } else if token::Comma == self.token.kind || self.token.kind.should_end_const_arg() { // Avoid the following output by checking that we consumed a full const arg: |
