suggest using double colon when using single colon in struct field type path

This commit is contained in:
Takayuki Maeda 2022-03-11 16:15:57 +09:00
parent d53e19540e
commit bdc3177868
3 changed files with 66 additions and 0 deletions

View file

@ -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()?;