Remove check for Fn, reflect this in test cases, make test cases more robust/explicit
This commit is contained in:
parent
152cdcb45b
commit
4db6abcd50
@ -43,9 +43,14 @@ declare_clippy_lint! {
|
||||
///
|
||||
/// This can lead to confusing error messages at best and to unexpected behavior at worst.
|
||||
///
|
||||
/// Note that this will not warn about wildcard imports from modules named `prelude`; many
|
||||
/// crates (including the standard library) provide modules named "prelude" specifically
|
||||
/// designed for wildcard import.
|
||||
/// **Exceptions:**
|
||||
///
|
||||
/// Wildcard imports are allowed from modules named `prelude`. Many crates (including the standard library)
|
||||
/// provide modules named "prelude" specifically designed for wildcard import.
|
||||
///
|
||||
/// `use super::*` is allowed in test modules. This is defined as any module with "test" in the name.
|
||||
///
|
||||
/// These exceptions can be disabled using the `warn-on-all-wildcard-imports` configuration flag.
|
||||
///
|
||||
/// **Known problems:** If macros are imported through the wildcard, this macro is not included
|
||||
/// by the suggestion and has to be added by hand.
|
||||
@ -198,5 +203,5 @@ fn is_super_only_import(segments: &[PathSegment<'_>]) -> bool {
|
||||
}
|
||||
|
||||
fn is_test_module_or_function(item: &Item<'_>) -> bool {
|
||||
matches!(item.kind, ItemKind::Fn(..) | ItemKind::Mod(..)) && item.ident.name.as_str().contains("test")
|
||||
matches!(item.kind, ItemKind::Mod(..)) && item.ident.name.as_str().contains("test")
|
||||
}
|
||||
|
@ -175,13 +175,34 @@ mod super_imports {
|
||||
}
|
||||
}
|
||||
|
||||
mod inner {
|
||||
fn test_should_pass() {
|
||||
mod test_should_pass_inside_function {
|
||||
fn with_super_inside_function() {
|
||||
use super::*;
|
||||
let _ = foofoo();
|
||||
}
|
||||
}
|
||||
|
||||
mod test_should_pass_further_inside {
|
||||
fn insidefoo() {}
|
||||
mod inner {
|
||||
use super::*;
|
||||
fn with_super() {
|
||||
let _ = insidefoo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod should_be_replaced_futher_inside {
|
||||
fn insidefoo() {}
|
||||
mod inner {
|
||||
use super::insidefoo;
|
||||
fn with_super() {
|
||||
let _ = insidefoo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mod use_explicit_should_be_replaced {
|
||||
use super_imports::foofoo;
|
||||
|
||||
|
@ -176,13 +176,33 @@ mod super_imports {
|
||||
}
|
||||
}
|
||||
|
||||
mod inner {
|
||||
fn test_should_pass() {
|
||||
mod test_should_pass_inside_function {
|
||||
fn with_super_inside_function() {
|
||||
use super::*;
|
||||
let _ = foofoo();
|
||||
}
|
||||
}
|
||||
|
||||
mod test_should_pass_further_inside {
|
||||
fn insidefoo() {}
|
||||
mod inner {
|
||||
use super::*;
|
||||
fn with_super() {
|
||||
let _ = insidefoo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod should_be_replaced_futher_inside {
|
||||
fn insidefoo() {}
|
||||
mod inner {
|
||||
use super::*;
|
||||
fn with_super() {
|
||||
let _ = insidefoo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod use_explicit_should_be_replaced {
|
||||
use super_imports::*;
|
||||
|
||||
|
@ -99,22 +99,28 @@ LL | use super::*;
|
||||
| ^^^^^^^^ help: try: `super::foofoo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:187:13
|
||||
--> $DIR/wildcard_imports.rs:199:17
|
||||
|
|
||||
LL | use super::*;
|
||||
| ^^^^^^^^ help: try: `super::insidefoo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:208:13
|
||||
|
|
||||
LL | use super_imports::*;
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `super_imports::foofoo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:196:17
|
||||
--> $DIR/wildcard_imports.rs:217:17
|
||||
|
|
||||
LL | use super::super::*;
|
||||
| ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:205:13
|
||||
--> $DIR/wildcard_imports.rs:226:13
|
||||
|
|
||||
LL | use super::super::super_imports::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo`
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user