Add regression tests for keyword-in-identifier-position recovery ICE
... in macro invocations. Issue: <https://github.com/rust-lang/rust/issues/149692>.
This commit is contained in:
parent
a47f4dfd7f
commit
31531b3665
4 changed files with 70 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
|||
//! More test coverage for <https://github.com/rust-lang/rust/issues/149692>; this test is
|
||||
//! specifically for `const` items.
|
||||
|
||||
macro_rules! m {
|
||||
(const $id:item()) => {}
|
||||
}
|
||||
|
||||
m!(const Self());
|
||||
//~^ ERROR expected one of `!` or `::`, found `(`
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error: expected one of `!` or `::`, found `(`
|
||||
--> $DIR/kw-in-const-item-pos-recovery-149692.rs:8:14
|
||||
|
|
||||
LL | (const $id:item()) => {}
|
||||
| -------- while parsing argument for this `item` macro fragment
|
||||
...
|
||||
LL | m!(const Self());
|
||||
| ^ expected one of `!` or `::`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
19
tests/ui/parser/macro/kw-in-item-pos-recovery-149692.rs
Normal file
19
tests/ui/parser/macro/kw-in-item-pos-recovery-149692.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//! Regression test for a diagnostic ICE where we tried to recover a keyword as the identifier when
|
||||
//! we are already trying to recover a missing keyword before item.
|
||||
//!
|
||||
//! See <https://github.com/rust-lang/rust/issues/149692>.
|
||||
|
||||
macro_rules! m {
|
||||
($id:item()) => {}
|
||||
}
|
||||
|
||||
m!(Self());
|
||||
//~^ ERROR expected one of `!` or `::`, found `(`
|
||||
|
||||
m!(Self{});
|
||||
//~^ ERROR expected one of `!` or `::`, found `{`
|
||||
|
||||
m!(crate());
|
||||
//~^ ERROR expected one of `!` or `::`, found `(`
|
||||
|
||||
fn main() {}
|
||||
29
tests/ui/parser/macro/kw-in-item-pos-recovery-149692.stderr
Normal file
29
tests/ui/parser/macro/kw-in-item-pos-recovery-149692.stderr
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
error: expected one of `!` or `::`, found `(`
|
||||
--> $DIR/kw-in-item-pos-recovery-149692.rs:10:8
|
||||
|
|
||||
LL | ($id:item()) => {}
|
||||
| -------- while parsing argument for this `item` macro fragment
|
||||
...
|
||||
LL | m!(Self());
|
||||
| ^ expected one of `!` or `::`
|
||||
|
||||
error: expected one of `!` or `::`, found `{`
|
||||
--> $DIR/kw-in-item-pos-recovery-149692.rs:13:8
|
||||
|
|
||||
LL | ($id:item()) => {}
|
||||
| -------- while parsing argument for this `item` macro fragment
|
||||
...
|
||||
LL | m!(Self{});
|
||||
| ^ expected one of `!` or `::`
|
||||
|
||||
error: expected one of `!` or `::`, found `(`
|
||||
--> $DIR/kw-in-item-pos-recovery-149692.rs:16:9
|
||||
|
|
||||
LL | ($id:item()) => {}
|
||||
| -------- while parsing argument for this `item` macro fragment
|
||||
...
|
||||
LL | m!(crate());
|
||||
| ^ expected one of `!` or `::`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue