Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test for #117058 #117092

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tests/ui/attributes/statement-attribute-validation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// test for #117058 - check that attributes are validated on various kinds of statements.

struct A;

fn func() {}

fn main() {
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
if true {
} else {
}
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
(1);
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
match 1 {
_ => {}
}
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
while false {}
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
{}
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
A {};
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
func();
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
A;
#[allow(two-words)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
loop {}
}
56 changes: 56 additions & 0 deletions tests/ui/attributes/statement-attribute-validation.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:8:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:13:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:16:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:21:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:24:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:27:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:30:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:33:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/statement-attribute-validation.rs:36:16
|
LL | #[allow(two-words)]
| ^ expected one of `(`, `,`, `::`, or `=`

error: aborting due to 9 previous errors

Loading