-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 #10763 - GuillaumeGomez:unique_cfg_condition, r=Jarcho
Add `MINIMAL_CFG_CONDITION` lint I encountered a few cases where some code had: ```rust #[cfg(any(unix))] ``` In this case, the `any` is useless. This lint checks this and also for the `all` condition. ``` changelog: [`unique_cfg_condition`]: Add new `UNIQUE_CFG_CONDITION` lint ```
- Loading branch information
Showing
8 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
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,17 @@ | ||
//@run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
#[cfg(windows)] | ||
fn hermit() {} | ||
|
||
#[cfg(windows)] | ||
fn wasi() {} | ||
|
||
#[cfg(all(unix, not(windows)))] | ||
fn the_end() {} | ||
|
||
#[cfg(any())] | ||
fn any() {} | ||
|
||
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,17 @@ | ||
//@run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
#[cfg(all(windows))] | ||
fn hermit() {} | ||
|
||
#[cfg(any(windows))] | ||
fn wasi() {} | ||
|
||
#[cfg(all(any(unix), all(not(windows))))] | ||
fn the_end() {} | ||
|
||
#[cfg(any())] | ||
fn any() {} | ||
|
||
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,28 @@ | ||
error: unneeded sub `cfg` when there is only one condition | ||
--> $DIR/non_minimal_cfg.rs:5:7 | ||
| | ||
LL | #[cfg(all(windows))] | ||
| ^^^^^^^^^^^^ help: try: `windows` | ||
| | ||
= note: `-D clippy::non-minimal-cfg` implied by `-D warnings` | ||
|
||
error: unneeded sub `cfg` when there is only one condition | ||
--> $DIR/non_minimal_cfg.rs:8:7 | ||
| | ||
LL | #[cfg(any(windows))] | ||
| ^^^^^^^^^^^^ help: try: `windows` | ||
|
||
error: unneeded sub `cfg` when there is only one condition | ||
--> $DIR/non_minimal_cfg.rs:11:11 | ||
| | ||
LL | #[cfg(all(any(unix), all(not(windows))))] | ||
| ^^^^^^^^^ help: try: `unix` | ||
|
||
error: unneeded sub `cfg` when there is only one condition | ||
--> $DIR/non_minimal_cfg.rs:11:22 | ||
| | ||
LL | #[cfg(all(any(unix), all(not(windows))))] | ||
| ^^^^^^^^^^^^^^^^^ help: try: `not(windows)` | ||
|
||
error: aborting due to 4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#![allow(unused)] | ||
|
||
#[cfg(all())] | ||
fn all() {} | ||
|
||
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,10 @@ | ||
error: unneeded sub `cfg` when there is no condition | ||
--> $DIR/non_minimal_cfg2.rs:3:7 | ||
| | ||
LL | #[cfg(all())] | ||
| ^^^^^ | ||
| | ||
= note: `-D clippy::non-minimal-cfg` implied by `-D warnings` | ||
|
||
error: aborting due to previous error | ||
|