diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-03-11 16:15:57 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-03-11 16:15:57 +0900 |
| commit | bdc317786856c3a49dfa9a35a25037ce1872440e (patch) | |
| tree | d516e976315190bb876e28eb2ab3053b8465c2b8 /compiler/rustc_parse/src/parser | |
| parent | d53e19540e7e201042c8b07a236e5351de085a42 (diff) | |
| download | rust-bdc317786856c3a49dfa9a35a25037ce1872440e.tar.gz rust-bdc317786856c3a49dfa9a35a25037ce1872440e.zip | |
suggest using double colon when using single colon in struct field type path
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 5db1e4e0523..423ce7c354c 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1534,6 +1534,16 @@ impl<'a> Parser<'a> { let name = self.parse_field_ident(adt_ty, lo)?; self.expect_field_ty_separator()?; let ty = self.parse_ty()?; + if self.token.kind == token::Colon && self.look_ahead(1, |tok| tok.kind != token::Colon) { + self.struct_span_err(self.token.span, "found single colon in a struct field type path") + .span_suggestion_verbose( + self.token.span, + "maybe you meant to write a path separator here", + "::".to_string(), + Applicability::MaybeIncorrect, + ) + .emit(); + } if self.token.kind == token::Eq { self.bump(); let const_expr = self.parse_anon_const_expr()?; |
