Auto merge of #77015 - davidtwco:check-attr-variant-closure-expr, r=lcnr
passes: `check_attr` on more targets This PR modifies `check_attr` so that: - Enum variants are now checked (some attributes would not have been prohibited on variants previously). - `check_expr_attributes` and `check_stmt_attributes` are removed as `check_attributes` can perform the same checks. This means that codegen attribute errors aren't shown if there are other errors first (e.g. from other attributes, as shown in `src/test/ui/macros/issue-68060.rs` changes below).
This commit is contained in:
commit
7bade6ef73
20 changed files with 114 additions and 131 deletions
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
#[inline] struct Foo; //~ ERROR attribute should be applied to function or closure
|
||||
#[repr(C)] fn foo() {} //~ ERROR attribute should be applied to struct, enum, or union
|
||||
#[repr(C)] fn foo() {} //~ ERROR attribute should be applied to a struct, enum, or union
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0518]: attribute should be applied to function or closure
|
|||
LL | #[inline] struct Foo;
|
||||
| ^^^^^^^^^ ----------- not a function or closure
|
||||
|
||||
error[E0517]: attribute should be applied to struct, enum, or union
|
||||
error[E0517]: attribute should be applied to a struct, enum, or union
|
||||
--> $DIR/issue-31769.rs:3:12
|
||||
|
|
||||
LL | #[repr(C)] fn foo() {}
|
||||
|
|
|
|||
|
|
@ -13,18 +13,17 @@ fn main() {
|
|||
|
||||
#[repr(nothing)]
|
||||
let _x = 0;
|
||||
//~^^ ERROR attribute should not be applied to a statement
|
||||
//~^^ ERROR attribute should be applied to a struct, enum, or union
|
||||
|
||||
#[repr(something_not_real)]
|
||||
loop {
|
||||
()
|
||||
};
|
||||
//~^^^^ ERROR attribute should not be applied to an expression
|
||||
//~^^^^ ERROR attribute should be applied to a struct, enum, or union
|
||||
|
||||
#[repr]
|
||||
let _y = "123";
|
||||
//~^^ ERROR attribute should not be applied to a statement
|
||||
//~| ERROR malformed `repr` attribute
|
||||
//~^^ ERROR malformed `repr` attribute
|
||||
|
||||
fn foo() {}
|
||||
|
||||
|
|
@ -33,6 +32,5 @@ fn main() {
|
|||
//~^^ ERROR attribute should be applied to function or closure
|
||||
|
||||
let _z = #[repr] 1;
|
||||
//~^ ERROR attribute should not be applied to an expression
|
||||
//~| ERROR malformed `repr` attribute
|
||||
//~^ ERROR malformed `repr` attribute
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | #[repr]
|
|||
| ^^^^^^^ help: must be of the form: `#[repr(C)]`
|
||||
|
||||
error: malformed `repr` attribute input
|
||||
--> $DIR/issue-43988.rs:35:14
|
||||
--> $DIR/issue-43988.rs:34:14
|
||||
|
|
||||
LL | let _z = #[repr] 1;
|
||||
| ^^^^^^^ help: must be of the form: `#[repr(C)]`
|
||||
|
|
@ -26,47 +26,33 @@ LL | #[inline(XYZ)]
|
|||
LL | let _b = 4;
|
||||
| ----------- not a function or closure
|
||||
|
||||
error[E0517]: attribute should not be applied to a statement
|
||||
--> $DIR/issue-43988.rs:14:5
|
||||
error[E0517]: attribute should be applied to a struct, enum, or union
|
||||
--> $DIR/issue-43988.rs:14:12
|
||||
|
|
||||
LL | #[repr(nothing)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^
|
||||
LL | let _x = 0;
|
||||
| ----------- not a struct, enum, or union
|
||||
|
||||
error[E0517]: attribute should not be applied to an expression
|
||||
--> $DIR/issue-43988.rs:18:5
|
||||
error[E0517]: attribute should be applied to a struct, enum, or union
|
||||
--> $DIR/issue-43988.rs:18:12
|
||||
|
|
||||
LL | #[repr(something_not_real)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
LL | / loop {
|
||||
LL | | ()
|
||||
LL | | };
|
||||
| |_____- not defining a struct, enum, or union
|
||||
|
||||
error[E0517]: attribute should not be applied to a statement
|
||||
--> $DIR/issue-43988.rs:24:5
|
||||
|
|
||||
LL | #[repr]
|
||||
| ^^^^^^^
|
||||
LL | let _y = "123";
|
||||
| --------------- not a struct, enum, or union
|
||||
| |_____- not a struct, enum, or union
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43988.rs:31:5
|
||||
--> $DIR/issue-43988.rs:30:5
|
||||
|
|
||||
LL | #[inline(ABC)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
LL | foo();
|
||||
| ----- not a function or closure
|
||||
|
||||
error[E0517]: attribute should not be applied to an expression
|
||||
--> $DIR/issue-43988.rs:35:14
|
||||
|
|
||||
LL | let _z = #[repr] 1;
|
||||
| ^^^^^^^ - not defining a struct, enum, or union
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0517, E0518.
|
||||
For more information about an error, try `rustc --explain E0517`.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
#[repr(i128)] //~ ERROR: attribute should be applied to enum
|
||||
#[repr(i128)] //~ ERROR: attribute should be applied to an enum
|
||||
struct Foo;
|
||||
|
||||
#[repr(u128)] //~ ERROR: attribute should be applied to enum
|
||||
#[repr(u128)] //~ ERROR: attribute should be applied to an enum
|
||||
struct Bar;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0517]: attribute should be applied to enum
|
||||
error[E0517]: attribute should be applied to an enum
|
||||
--> $DIR/issue-74082.rs:3:8
|
||||
|
|
||||
LL | #[repr(i128)]
|
||||
|
|
@ -6,7 +6,7 @@ LL | #[repr(i128)]
|
|||
LL | struct Foo;
|
||||
| ----------- not an enum
|
||||
|
||||
error[E0517]: attribute should be applied to enum
|
||||
error[E0517]: attribute should be applied to an enum
|
||||
--> $DIR/issue-74082.rs:6:8
|
||||
|
|
||||
LL | #[repr(u128)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue