Skip to content

Commit 31531b3

Browse files
committed
Add regression tests for keyword-in-identifier-position recovery ICE
... in macro invocations. Issue: <#149692>.
1 parent a47f4df commit 31531b3

4 files changed

Lines changed: 70 additions & 0 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! More test coverage for <https://github.com/rust-lang/rust/issues/149692>; this test is
2+
//! specifically for `const` items.
3+
4+
macro_rules! m {
5+
(const $id:item()) => {}
6+
}
7+
8+
m!(const Self());
9+
//~^ ERROR expected one of `!` or `::`, found `(`
10+
11+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: expected one of `!` or `::`, found `(`
2+
--> $DIR/kw-in-const-item-pos-recovery-149692.rs:8:14
3+
|
4+
LL | (const $id:item()) => {}
5+
| -------- while parsing argument for this `item` macro fragment
6+
...
7+
LL | m!(const Self());
8+
| ^ expected one of `!` or `::`
9+
10+
error: aborting due to 1 previous error
11+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Regression test for a diagnostic ICE where we tried to recover a keyword as the identifier when
2+
//! we are already trying to recover a missing keyword before item.
3+
//!
4+
//! See <https://github.com/rust-lang/rust/issues/149692>.
5+
6+
macro_rules! m {
7+
($id:item()) => {}
8+
}
9+
10+
m!(Self());
11+
//~^ ERROR expected one of `!` or `::`, found `(`
12+
13+
m!(Self{});
14+
//~^ ERROR expected one of `!` or `::`, found `{`
15+
16+
m!(crate());
17+
//~^ ERROR expected one of `!` or `::`, found `(`
18+
19+
fn main() {}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error: expected one of `!` or `::`, found `(`
2+
--> $DIR/kw-in-item-pos-recovery-149692.rs:10:8
3+
|
4+
LL | ($id:item()) => {}
5+
| -------- while parsing argument for this `item` macro fragment
6+
...
7+
LL | m!(Self());
8+
| ^ expected one of `!` or `::`
9+
10+
error: expected one of `!` or `::`, found `{`
11+
--> $DIR/kw-in-item-pos-recovery-149692.rs:13:8
12+
|
13+
LL | ($id:item()) => {}
14+
| -------- while parsing argument for this `item` macro fragment
15+
...
16+
LL | m!(Self{});
17+
| ^ expected one of `!` or `::`
18+
19+
error: expected one of `!` or `::`, found `(`
20+
--> $DIR/kw-in-item-pos-recovery-149692.rs:16:9
21+
|
22+
LL | ($id:item()) => {}
23+
| -------- while parsing argument for this `item` macro fragment
24+
...
25+
LL | m!(crate());
26+
| ^ expected one of `!` or `::`
27+
28+
error: aborting due to 3 previous errors
29+

0 commit comments

Comments
 (0)