diff options
| author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2021-02-08 10:43:54 +0300 |
|---|---|---|
| committer | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2021-02-08 10:46:19 +0300 |
| commit | 6eb1bd4c3e3ad9a28d0a3b0f1579a4769d9a88d2 (patch) | |
| tree | 6b9617fdbfadb5ae72b10ccb0b9c488e21f31cbe /src/test/ui/parser | |
| parent | 0b7a598e12649d7ab2415a82cbc3fea879fa9dab (diff) | |
| download | rust-6eb1bd4c3e3ad9a28d0a3b0f1579a4769d9a88d2.tar.gz rust-6eb1bd4c3e3ad9a28d0a3b0f1579a4769d9a88d2.zip | |
parser: Fix panic in 'const impl' recovery
The panic happens when in recovery parsing a full `impl` (`parse_item_impl`) fails and we drop the `DiagnosticBuilder` for the recovery suggestion and return the `parse_item_impl` error. We now raise the original error "expected identifier found `impl`" when parsing the `impl` fails. Note that the regression test is slightly simplified version of the original repro in #81806, to make the error output smaller and more resilient to unrelated changes in parser error messages. Fixes #81806
Diffstat (limited to 'src/test/ui/parser')
| -rw-r--r-- | src/test/ui/parser/issue-81806.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-81806.stderr | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/parser/issue-81806.rs b/src/test/ui/parser/issue-81806.rs new file mode 100644 index 00000000000..ca86788dff7 --- /dev/null +++ b/src/test/ui/parser/issue-81806.rs @@ -0,0 +1,5 @@ +trait T { const +impl //~ ERROR: expected identifier, found keyword `impl` +} + +fn main() {} diff --git a/src/test/ui/parser/issue-81806.stderr b/src/test/ui/parser/issue-81806.stderr new file mode 100644 index 00000000000..b8ada11d922 --- /dev/null +++ b/src/test/ui/parser/issue-81806.stderr @@ -0,0 +1,17 @@ +error: expected identifier, found keyword `impl` + --> $DIR/issue-81806.rs:2:1 + | +LL | trait T { const + | - while parsing this item list starting here +LL | impl + | ^^^^ expected identifier, found keyword +LL | } + | - the item list ends here + | +help: you can escape reserved keywords to use them as identifiers + | +LL | r#impl + | ^^^^^^ + +error: aborting due to previous error + |
