diff options
| author | bors <bors@rust-lang.org> | 2021-09-24 11:54:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-24 11:54:29 +0000 |
| commit | a0648eab3686f100c7ab9b0d38472c740079cce4 (patch) | |
| tree | 2f0983f6033f3a568ab04ada0bfe7be61fee121d /src/test | |
| parent | 91d8da1f4ba24679e92b7939a26c681a5d2d3548 (diff) | |
| parent | a8421cacfec5798f600549508545b85003c2143c (diff) | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/parser/issue-88770.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-88770.stderr | 66 |
2 files changed, 77 insertions, 0 deletions
diff --git a/src/test/ui/parser/issue-88770.rs b/src/test/ui/parser/issue-88770.rs new file mode 100644 index 00000000000..bf89033f560 --- /dev/null +++ b/src/test/ui/parser/issue-88770.rs @@ -0,0 +1,11 @@ +// Regression test for the ICE described in #88770. + +// error-pattern:this file contains an unclosed delimiter +// error-pattern:expected one of +// error-pattern:missing `in` in `for` loop +// error-pattern:expected `;`, found `e` + +fn m(){print!("",(c for&g +u +e +e diff --git a/src/test/ui/parser/issue-88770.stderr b/src/test/ui/parser/issue-88770.stderr new file mode 100644 index 00000000000..c7e24155d16 --- /dev/null +++ b/src/test/ui/parser/issue-88770.stderr @@ -0,0 +1,66 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-88770.rs:11:3 + | +LL | fn m(){print!("",(c for&g + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +... +LL | e + | ^ + +error: this file contains an unclosed delimiter + --> $DIR/issue-88770.rs:11:3 + | +LL | fn m(){print!("",(c for&g + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +... +LL | e + | ^ + +error: this file contains an unclosed delimiter + --> $DIR/issue-88770.rs:11:3 + | +LL | fn m(){print!("",(c for&g + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +... +LL | e + | ^ + +error: missing `in` in `for` loop + --> $DIR/issue-88770.rs:8:26 + | +LL | fn m(){print!("",(c for&g + | __________________________^ +LL | | u + | |_ help: try adding `in` here + +error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found keyword `for` + --> $DIR/issue-88770.rs:8:21 + | +LL | fn m(){print!("",(c for&g + | ^^^ expected one of 8 possible tokens + +error: expected `;`, found `e` + --> $DIR/issue-88770.rs:10:2 + | +LL | e + | ^ help: add `;` here +LL | e + | - unexpected token + +error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `)` + --> $DIR/issue-88770.rs:11:3 + | +LL | e + | ^ expected one of 7 possible tokens + +error: aborting due to 7 previous errors + |
