-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #88681 - ehuss:duplicate-attributes, r=petrochenkov
Check for duplicate attributes. This adds some checks for duplicate attributes. In many cases, the duplicates were being ignored without error or warning. This adds several kinds of checks (see `AttributeDuplicates` enum). The motivation here is to issue unused warnings with similar reasoning for any unused lint, and to error for cases where there are conflicts. This also adds a check for empty attribute lists in a few attributes where this causes the attribute to be ignored. Closes #55112.
- Loading branch information
Showing
15 changed files
with
1,052 additions
and
302 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![deny(unused_attributes)] | ||
#![allow()] //~ ERROR unused attribute | ||
#![warn()] //~ ERROR unused attribute | ||
#![deny()] //~ ERROR unused attribute | ||
#![forbid()] //~ ERROR unused attribute | ||
#![feature()] //~ ERROR unused attribute | ||
|
||
#[repr()] //~ ERROR unused attribute | ||
pub struct S; | ||
|
||
#[target_feature()] //~ ERROR unused attribute | ||
pub unsafe fn foo() {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
error: unused attribute | ||
--> $DIR/empty-attributes.rs:8:1 | ||
| | ||
LL | #[repr()] | ||
| ^^^^^^^^^ help: remove this attribute | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/empty-attributes.rs:1:9 | ||
| | ||
LL | #![deny(unused_attributes)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
= note: attribute `repr` with an empty list has no effect | ||
|
||
error: unused attribute | ||
--> $DIR/empty-attributes.rs:11:1 | ||
| | ||
LL | #[target_feature()] | ||
| ^^^^^^^^^^^^^^^^^^^ help: remove this attribute | ||
| | ||
= note: attribute `target_feature` with an empty list has no effect | ||
|
||
error: unused attribute | ||
--> $DIR/empty-attributes.rs:2:1 | ||
| | ||
LL | #![allow()] | ||
| ^^^^^^^^^^^ help: remove this attribute | ||
| | ||
= note: attribute `allow` with an empty list has no effect | ||
|
||
error: unused attribute | ||
--> $DIR/empty-attributes.rs:3:1 | ||
| | ||
LL | #![warn()] | ||
| ^^^^^^^^^^ help: remove this attribute | ||
| | ||
= note: attribute `warn` with an empty list has no effect | ||
|
||
error: unused attribute | ||
--> $DIR/empty-attributes.rs:4:1 | ||
| | ||
LL | #![deny()] | ||
| ^^^^^^^^^^ help: remove this attribute | ||
| | ||
= note: attribute `deny` with an empty list has no effect | ||
|
||
error: unused attribute | ||
--> $DIR/empty-attributes.rs:5:1 | ||
| | ||
LL | #![forbid()] | ||
| ^^^^^^^^^^^^ help: remove this attribute | ||
| | ||
= note: attribute `forbid` with an empty list has no effect | ||
|
||
error: unused attribute | ||
--> $DIR/empty-attributes.rs:6:1 | ||
| | ||
LL | #![feature()] | ||
| ^^^^^^^^^^^^^ help: remove this attribute | ||
| | ||
= note: attribute `feature` with an empty list has no effect | ||
|
||
error: aborting due to 7 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.