]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #88835 - FabianWolff:issue-88770, r=petrochenkov
authorbors <bors@rust-lang.org>
Fri, 24 Sep 2021 11:54:29 +0000 (11:54 +0000)
committerbors <bors@rust-lang.org>
Fri, 24 Sep 2021 11:54:29 +0000 (11:54 +0000)
commita0648eab3686f100c7ab9b0d38472c740079cce4
tree2f0983f6033f3a568ab04ada0bfe7be61fee121d
parent91d8da1f4ba24679e92b7939a26c681a5d2d3548
parenta8421cacfec5798f600549508545b85003c2143c
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:
https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/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()`](https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/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()`:
https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/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.
compiler/rustc_builtin_macros/src/format.rs
compiler/rustc_parse/src/parser/diagnostics.rs