Add test for malformed and misapplied crate_type
This commit is contained in:
parent
e902d0512c
commit
8a1d6d319b
2 changed files with 89 additions and 0 deletions
19
tests/ui/attributes/crate-type-non-crate.rs
Normal file
19
tests/ui/attributes/crate-type-non-crate.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//! Test the behavior of various malformed `crate_type` attributes applied to a non-crate target.
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
// No arguments
|
||||
#[crate_type] //~ ERROR malformed `crate_type` attribute input
|
||||
// List/NameValue with/without strings
|
||||
#[crate_type(lib)] //~ ERROR malformed `crate_type` attribute input
|
||||
#[crate_type("lib")] //~ ERROR malformed `crate_type` attribute input
|
||||
#[crate_type = lib] //~ ERROR attribute value must be a literal
|
||||
#[crate_type = "lib"] // OK
|
||||
// Same as above but with invalid names
|
||||
#[crate_type(foo)] //~ ERROR malformed `crate_type` attribute input
|
||||
#[crate_type("foo")] //~ ERROR malformed `crate_type` attribute input
|
||||
#[crate_type = foo] //~ ERROR attribute value must be a literal
|
||||
#[crate_type = "foo"] // OK - we don't report errors on invalid crate types here
|
||||
// Non-string literals
|
||||
#[crate_type(1)] //~ ERROR malformed `crate_type` attribute input
|
||||
#[crate_type = 1] //~ ERROR malformed `crate_type` attribute input
|
||||
fn main() {}
|
||||
70
tests/ui/attributes/crate-type-non-crate.stderr
Normal file
70
tests/ui/attributes/crate-type-non-crate.stderr
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
error: malformed `crate_type` attribute input
|
||||
--> $DIR/crate-type-non-crate.rs:5:1
|
||||
|
|
||||
LL | #[crate_type]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
|
||||
|
||||
error: malformed `crate_type` attribute input
|
||||
--> $DIR/crate-type-non-crate.rs:7:1
|
||||
|
|
||||
LL | #[crate_type(lib)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
|
||||
|
||||
error: malformed `crate_type` attribute input
|
||||
--> $DIR/crate-type-non-crate.rs:8:1
|
||||
|
|
||||
LL | #[crate_type("lib")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
|
||||
|
||||
error: attribute value must be a literal
|
||||
--> $DIR/crate-type-non-crate.rs:9:16
|
||||
|
|
||||
LL | #[crate_type = lib]
|
||||
| ^^^
|
||||
|
||||
error: malformed `crate_type` attribute input
|
||||
--> $DIR/crate-type-non-crate.rs:12:1
|
||||
|
|
||||
LL | #[crate_type(foo)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
|
||||
|
||||
error: malformed `crate_type` attribute input
|
||||
--> $DIR/crate-type-non-crate.rs:13:1
|
||||
|
|
||||
LL | #[crate_type("foo")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
|
||||
|
||||
error: attribute value must be a literal
|
||||
--> $DIR/crate-type-non-crate.rs:14:16
|
||||
|
|
||||
LL | #[crate_type = foo]
|
||||
| ^^^
|
||||
|
||||
error: malformed `crate_type` attribute input
|
||||
--> $DIR/crate-type-non-crate.rs:17:1
|
||||
|
|
||||
LL | #[crate_type(1)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
|
||||
|
||||
error: malformed `crate_type` attribute input
|
||||
--> $DIR/crate-type-non-crate.rs:18:1
|
||||
|
|
||||
LL | #[crate_type = 1]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue