make it more accurate by parsing ty
This commit is contained in:
parent
6b76588222
commit
0e8703da3e
1 changed files with 19 additions and 9 deletions
|
@ -1274,18 +1274,28 @@ impl<'a> Parser<'a> {
|
||||||
(thin_vec![], false)
|
(thin_vec![], false)
|
||||||
} else {
|
} else {
|
||||||
self.parse_delim_comma_seq(Delimiter::Brace, |p| p.parse_enum_variant()).map_err(
|
self.parse_delim_comma_seq(Delimiter::Brace, |p| p.parse_enum_variant()).map_err(
|
||||||
|mut e| {
|
|mut err| {
|
||||||
e.span_label(id.span, "while parsing this enum");
|
err.span_label(id.span, "while parsing this enum");
|
||||||
if self.token == token::Colon {
|
if self.token == token::Colon {
|
||||||
e.span_suggestion_verbose(
|
let snapshot = self.create_snapshot_for_diagnostic();
|
||||||
|
self.bump();
|
||||||
|
match self.parse_ty() {
|
||||||
|
Ok(_) => {
|
||||||
|
err.span_suggestion_verbose(
|
||||||
prev_span,
|
prev_span,
|
||||||
"perhaps you meant to use `struct` here",
|
"perhaps you meant to use `struct` here",
|
||||||
"struct".to_string(),
|
"struct".to_string(),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
e.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.restore_snapshot(snapshot);
|
||||||
|
}
|
||||||
self.recover_stmt();
|
self.recover_stmt();
|
||||||
e
|
err
|
||||||
},
|
},
|
||||||
)?
|
)?
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue