mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Add regression tests for keyword-in-identifier-position recovery ICE
... in macro invocations.
Issue: <https://github.com/rust-lang/rust/issues/149692>.
(cherry picked from commit 31531b3665)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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() {}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user