mbe: Add parser test for macro attribute recovery
This commit is contained in:
parent
1500195799
commit
9a9ccc0edb
2 changed files with 50 additions and 0 deletions
19
tests/ui/parser/macro/macro-attr-recovery.rs
Normal file
19
tests/ui/parser/macro/macro-attr-recovery.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![crate_type = "lib"]
|
||||
#![feature(macro_attr)]
|
||||
|
||||
macro_rules! attr {
|
||||
attr[$($args:tt)*] { $($body:tt)* } => {
|
||||
//~^ ERROR: macro attribute argument matchers require parentheses
|
||||
//~v ERROR: attr:
|
||||
compile_error!(concat!(
|
||||
"attr: args=\"",
|
||||
stringify!($($args)*),
|
||||
"\" body=\"",
|
||||
stringify!($($body)*),
|
||||
"\"",
|
||||
));
|
||||
};
|
||||
}
|
||||
|
||||
#[attr]
|
||||
struct S;
|
||||
31
tests/ui/parser/macro/macro-attr-recovery.stderr
Normal file
31
tests/ui/parser/macro/macro-attr-recovery.stderr
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
error: macro attribute argument matchers require parentheses
|
||||
--> $DIR/macro-attr-recovery.rs:5:9
|
||||
|
|
||||
LL | attr[$($args:tt)*] { $($body:tt)* } => {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
help: the delimiters should be `(` and `)`
|
||||
|
|
||||
LL - attr[$($args:tt)*] { $($body:tt)* } => {
|
||||
LL + attr($($args:tt)*) { $($body:tt)* } => {
|
||||
|
|
||||
|
||||
error: attr: args="" body="struct S;"
|
||||
--> $DIR/macro-attr-recovery.rs:8:9
|
||||
|
|
||||
LL | / compile_error!(concat!(
|
||||
LL | | "attr: args=\"",
|
||||
LL | | stringify!($($args)*),
|
||||
LL | | "\" body=\"",
|
||||
LL | | stringify!($($body)*),
|
||||
LL | | "\"",
|
||||
LL | | ));
|
||||
| |__________^
|
||||
...
|
||||
LL | #[attr]
|
||||
| ------- in this attribute macro expansion
|
||||
|
|
||||
= note: this error originates in the attribute macro `attr` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue