-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 #11979 - J-ZhengLi:issue11428, r=Alexendoo
add configuration for [`wildcard_imports`] to ignore certain imports fixes: #11428 changelog: add configuration `ignored-wildcard-imports` for lint [`wildcard_imports`]
- Loading branch information
Showing
14 changed files
with
184 additions
and
7 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
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
warn-on-all-wildcard-imports = true | ||
|
||
# This should be ignored since `warn-on-all-wildcard-imports` has higher precedence | ||
allowed-wildcard-imports = ["utils"] |
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 |
---|---|---|
@@ -1,11 +1,23 @@ | ||
error: usage of wildcard import | ||
--> $DIR/wildcard_imports.rs:6:5 | ||
--> $DIR/wildcard_imports.rs:18:5 | ||
| | ||
LL | use prelude::*; | ||
| ^^^^^^^^^^ help: try: `prelude::FOO` | ||
LL | use utils::*; | ||
| ^^^^^^^^ help: try: `utils::{BAR, print}` | ||
| | ||
= note: `-D clippy::wildcard-imports` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` | ||
|
||
error: aborting due to 1 previous error | ||
error: usage of wildcard import | ||
--> $DIR/wildcard_imports.rs:20:5 | ||
| | ||
LL | use my_crate::utils::*; | ||
| ^^^^^^^^^^^^^^^^^^ help: try: `my_crate::utils::my_util_fn` | ||
|
||
error: usage of wildcard import | ||
--> $DIR/wildcard_imports.rs:22:5 | ||
| | ||
LL | use prelude::*; | ||
| ^^^^^^^^^^ help: try: `prelude::FOO` | ||
|
||
error: aborting due to 3 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 @@ | ||
allowed-wildcard-imports = ["utils"] |
26 changes: 26 additions & 0 deletions
26
tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.fixed
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,26 @@ | ||
#![warn(clippy::wildcard_imports)] | ||
|
||
mod utils { | ||
pub fn print() {} | ||
} | ||
|
||
mod utils_plus { | ||
pub fn do_something() {} | ||
} | ||
|
||
mod my_crate { | ||
pub mod utils { | ||
pub fn my_util_fn() {} | ||
} | ||
} | ||
|
||
use my_crate::utils::*; | ||
use utils::*; | ||
use utils_plus::do_something; | ||
//~^ ERROR: usage of wildcard import | ||
|
||
fn main() { | ||
print(); | ||
my_util_fn(); | ||
do_something(); | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.rs
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,26 @@ | ||
#![warn(clippy::wildcard_imports)] | ||
|
||
mod utils { | ||
pub fn print() {} | ||
} | ||
|
||
mod utils_plus { | ||
pub fn do_something() {} | ||
} | ||
|
||
mod my_crate { | ||
pub mod utils { | ||
pub fn my_util_fn() {} | ||
} | ||
} | ||
|
||
use my_crate::utils::*; | ||
use utils::*; | ||
use utils_plus::*; | ||
//~^ ERROR: usage of wildcard import | ||
|
||
fn main() { | ||
print(); | ||
my_util_fn(); | ||
do_something(); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui-toml/wildcard_imports_whitelist/wildcard_imports.stderr
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,11 @@ | ||
error: usage of wildcard import | ||
--> $DIR/wildcard_imports.rs:19:5 | ||
| | ||
LL | use utils_plus::*; | ||
| ^^^^^^^^^^^^^ help: try: `utils_plus::do_something` | ||
| | ||
= note: `-D clippy::wildcard-imports` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` | ||
|
||
error: aborting due to 1 previous error | ||
|