Check for macros in built-in attributes that don't support them.

This commit is contained in:
Eric Huss 2021-09-17 13:08:56 -07:00
parent 5f8c571e50
commit 75f058dbfd
14 changed files with 142 additions and 8 deletions

View file

@ -0,0 +1,7 @@
#![crate_type = foo!()] //~ ERROR malformed `crate_type` attribute
macro_rules! foo {
() => {"rlib"};
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: malformed `crate_type` attribute input
--> $DIR/invalid-crate-type-macro.rs:1:1
|
LL | #![crate_type = foo!()]
| ^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "bin|lib|..."]`
error: aborting due to previous error

View file

@ -0,0 +1,4 @@
#[path = 123] //~ ERROR malformed `path` attribute
mod foo;
fn main() {}

View file

@ -0,0 +1,8 @@
error: malformed `path` attribute input
--> $DIR/path-invalid-form.rs:1:1
|
LL | #[path = 123]
| ^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]`
error: aborting due to previous error

View file

@ -0,0 +1,8 @@
macro_rules! foo {
() => {"bar.rs"};
}
#[path = foo!()] //~ ERROR malformed `path` attribute
mod abc;
fn main() {}

View file

@ -0,0 +1,8 @@
error: malformed `path` attribute input
--> $DIR/path-macro.rs:5:1
|
LL | #[path = foo!()]
| ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]`
error: aborting due to previous error

View file

@ -0,0 +1,3 @@
#![recursion_limit = 123] //~ ERROR malformed `recursion_limit` attribute
fn main() {}

View file

@ -0,0 +1,8 @@
error: malformed `recursion_limit` attribute input
--> $DIR/invalid_digit_type.rs:1:1
|
LL | #![recursion_limit = 123]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![recursion_limit = "N"]`
error: aborting due to previous error

View file

@ -0,0 +1,7 @@
#![recursion_limit = foo!()] //~ ERROR malformed `recursion_limit` attribute
macro_rules! foo {
() => {"128"};
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: malformed `recursion_limit` attribute input
--> $DIR/invalid_macro.rs:1:1
|
LL | #![recursion_limit = foo!()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![recursion_limit = "N"]`
error: aborting due to previous error