expand/resolve: Turn #[derive] into a regular macro attribute

This commit is contained in:
Vadim Petrochenkov 2020-11-14 14:47:14 +03:00
parent ae00b62ceb
commit dbdbd30bf2
58 changed files with 1499 additions and 1258 deletions

View file

@ -1,11 +1,8 @@
fn foo<#[derive(Debug)] T>() {
//~^ ERROR `derive` may only be applied to structs, enums and unions
fn foo<#[derive(Debug)] T>() { //~ ERROR expected non-macro attribute, found attribute macro
match 0 {
#[derive(Debug)]
//~^ ERROR `derive` may only be applied to structs, enums and unions
#[derive(Debug)] //~ ERROR expected non-macro attribute, found attribute macro
_ => (),
}
}
fn main() {
}
fn main() {}

View file

@ -1,15 +1,14 @@
error[E0774]: `derive` may only be applied to structs, enums and unions
--> $DIR/issue-49934-errors.rs:1:8
error: expected non-macro attribute, found attribute macro `derive`
--> $DIR/issue-49934-errors.rs:1:10
|
LL | fn foo<#[derive(Debug)] T>() {
| ^^^^^^^^^^^^^^^^
| ^^^^^^ not a non-macro attribute
error[E0774]: `derive` may only be applied to structs, enums and unions
--> $DIR/issue-49934-errors.rs:4:9
error: expected non-macro attribute, found attribute macro `derive`
--> $DIR/issue-49934-errors.rs:3:11
|
LL | #[derive(Debug)]
| ^^^^^^^^^^^^^^^^
| ^^^^^^ not a non-macro attribute
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0774`.

View file

@ -1,7 +1,4 @@
// check-pass
#![feature(stmt_expr_attributes)]
#![warn(unused_attributes)] //~ NOTE the lint level is defined here
fn main() {
// fold_stmt (Item)
@ -10,26 +7,24 @@ fn main() {
struct Foo;
// fold_stmt (Mac)
#[derive(Debug)]
//~^ WARN `#[derive]` does nothing on macro invocations
//~| NOTE this may become a hard error in a future release
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
println!("Hello, world!");
// fold_stmt (Semi)
#[derive(Debug)] //~ WARN unused attribute
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
"Hello, world!";
// fold_stmt (Local)
#[derive(Debug)] //~ WARN unused attribute
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
let _ = "Hello, world!";
// visit_expr
let _ = #[derive(Debug)] "Hello, world!";
//~^ WARN unused attribute
//~^ ERROR `derive` may only be applied to structs, enums and unions
let _ = [
// filter_map_expr
#[derive(Debug)] //~ WARN unused attribute
"Hello, world!"
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
"Hello, world!",
];
}

View file

@ -1,40 +1,33 @@
warning: `#[derive]` does nothing on macro invocations
--> $DIR/issue-49934.rs:13:5
|
LL | #[derive(Debug)]
| ^^^^^^^^^^^^^^^^
|
= note: this may become a hard error in a future release
warning: unused attribute
--> $DIR/issue-49934.rs:19:5
|
LL | #[derive(Debug)]
| ^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/issue-49934.rs:4:9
|
LL | #![warn(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
warning: unused attribute
--> $DIR/issue-49934.rs:23:5
error[E0774]: `derive` may only be applied to structs, enums and unions
--> $DIR/issue-49934.rs:10:5
|
LL | #[derive(Debug)]
| ^^^^^^^^^^^^^^^^
warning: unused attribute
--> $DIR/issue-49934.rs:27:13
error[E0774]: `derive` may only be applied to structs, enums and unions
--> $DIR/issue-49934.rs:14:5
|
LL | #[derive(Debug)]
| ^^^^^^^^^^^^^^^^
error[E0774]: `derive` may only be applied to structs, enums and unions
--> $DIR/issue-49934.rs:18:5
|
LL | #[derive(Debug)]
| ^^^^^^^^^^^^^^^^
error[E0774]: `derive` may only be applied to structs, enums and unions
--> $DIR/issue-49934.rs:22:13
|
LL | let _ = #[derive(Debug)] "Hello, world!";
| ^^^^^^^^^^^^^^^^
warning: unused attribute
--> $DIR/issue-49934.rs:32:9
error[E0774]: `derive` may only be applied to structs, enums and unions
--> $DIR/issue-49934.rs:27:9
|
LL | #[derive(Debug)]
| ^^^^^^^^^^^^^^^^
warning: 5 warnings emitted
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0774`.