Auto merge of #88835 - FabianWolff:issue-88770, r=petrochenkov
Fix error recovery in format macro parsing Fixes #88770. Basically, the assumption in the following comment is incorrect:b69fe57261/compiler/rustc_builtin_macros/src/format.rs (L167-L172)
This is only true in the first iteration of the loop, when [`p.clear_expected_tokens()`](b69fe57261/compiler/rustc_builtin_macros/src/format.rs (L164)
) is called. In subsequent iterations, `p.expected_tokens` won't be empty, so `p.expect()` won't actually call `unexpected_try_recover()`:b69fe57261/compiler/rustc_parse/src/parser/mod.rs (L487-L498)
Instead, it will call `expect_one_of()`, which _can_ recover and return `Ok()`. This PR handles this case to fix the ICE in #88770.
This commit is contained in:
commit
a0648eab36
4 changed files with 94 additions and 18 deletions
|
@ -277,7 +277,7 @@ impl<'a> Parser<'a> {
|
|||
self.struct_span_err(sp, &msg)
|
||||
.span_suggestion_short(sp, "change this to `;`", ";".to_string(), appl)
|
||||
.emit();
|
||||
return Ok(false);
|
||||
return Ok(true);
|
||||
} else if self.look_ahead(0, |t| {
|
||||
t == &token::CloseDelim(token::Brace)
|
||||
|| (
|
||||
|
@ -295,7 +295,7 @@ impl<'a> Parser<'a> {
|
|||
.span_label(self.token.span, "unexpected token")
|
||||
.span_suggestion_short(sp, "add `;` here", ";".to_string(), appl)
|
||||
.emit();
|
||||
return Ok(false);
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue