Make recovery for enum with struct field a bit more accurate

This commit is contained in:
Michael Goulet
2025-06-26 17:53:39 +00:00
parent 94e9973b92
commit e63921262c
3 changed files with 18 additions and 1 deletions

View File

@@ -1552,7 +1552,8 @@ impl<'a> Parser<'a> {
})
.map_err(|mut err| {
err.span_label(ident.span, "while parsing this enum");
if self.token == token::Colon {
// Try to recover `enum Foo { ident : Ty }`.
if self.prev_token.is_non_reserved_ident() && self.token == token::Colon {
let snapshot = self.create_snapshot_for_diagnostic();
self.bump();
match self.parse_ty() {