diff options
| author | bors <bors@rust-lang.org> | 2022-03-12 19:10:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-12 19:10:33 +0000 |
| commit | f103b2969b0088953873dc1ac92eb3387c753596 (patch) | |
| tree | cc7d446b9027618de27857f7e6c8abca90260e11 /compiler/rustc_parse/src/parser | |
| parent | 22a20e3f0f952d42122370ac3628e59cd2aecfdc (diff) | |
| parent | 26e299a4a74e4526ee405476bf45559c434d28ce (diff) | |
| download | rust-f103b2969b0088953873dc1ac92eb3387c753596.tar.gz rust-f103b2969b0088953873dc1ac92eb3387c753596.zip | |
Auto merge of #94865 - notriddle:notriddle/single-colon-path-not-const-generics, r=cjgillot
diagnostics: single colon within `<>` probably, not type ascription Fixes #94812
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -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..21d5bec65f0 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, + "write a path separator here", + "::".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: |
