Auto merge of #6905 - ThibsG:fpSingleComponentPathImports5210, r=giraffate
Fix FP in `single_component_path_imports` lint Fix FP in `single_component_path_imports` lint when the import is reused with `self`, like in `use self::module`. Fixes #5210 changelog: none
This commit is contained in:
commit
67fad0139f
8 changed files with 219 additions and 19 deletions
|
|
@ -19,3 +19,16 @@ fn main() {
|
|||
// False positive #5154, shouldn't trigger lint.
|
||||
m!();
|
||||
}
|
||||
|
||||
mod hello_mod {
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn hello_mod() {}
|
||||
}
|
||||
|
||||
mod hi_mod {
|
||||
use self::regex::{Regex, RegexSet};
|
||||
use regex;
|
||||
#[allow(dead_code)]
|
||||
fn hi_mod() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,3 +19,16 @@ fn main() {
|
|||
// False positive #5154, shouldn't trigger lint.
|
||||
m!();
|
||||
}
|
||||
|
||||
mod hello_mod {
|
||||
use regex;
|
||||
#[allow(dead_code)]
|
||||
fn hello_mod() {}
|
||||
}
|
||||
|
||||
mod hi_mod {
|
||||
use self::regex::{Regex, RegexSet};
|
||||
use regex;
|
||||
#[allow(dead_code)]
|
||||
fn hi_mod() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
error: this import is redundant
|
||||
--> $DIR/single_component_path_imports.rs:24:5
|
||||
|
|
||||
LL | use regex;
|
||||
| ^^^^^^^^^^ help: remove it entirely
|
||||
|
|
||||
= note: `-D clippy::single-component-path-imports` implied by `-D warnings`
|
||||
|
||||
error: this import is redundant
|
||||
--> $DIR/single_component_path_imports.rs:6:1
|
||||
|
|
||||
LL | use regex;
|
||||
| ^^^^^^^^^^ help: remove it entirely
|
||||
|
|
||||
= note: `-D clippy::single-component-path-imports` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
17
tests/ui/single_component_path_imports_nested_first.rs
Normal file
17
tests/ui/single_component_path_imports_nested_first.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// edition:2018
|
||||
#![warn(clippy::single_component_path_imports)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use regex;
|
||||
use serde as edres;
|
||||
pub use serde;
|
||||
|
||||
fn main() {
|
||||
regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
|
||||
}
|
||||
|
||||
mod root_nested_use_mod {
|
||||
use {regex, serde};
|
||||
#[allow(dead_code)]
|
||||
fn root_nested_use_mod() {}
|
||||
}
|
||||
25
tests/ui/single_component_path_imports_nested_first.stderr
Normal file
25
tests/ui/single_component_path_imports_nested_first.stderr
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
error: this import is redundant
|
||||
--> $DIR/single_component_path_imports_nested_first.rs:14:10
|
||||
|
|
||||
LL | use {regex, serde};
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `-D clippy::single-component-path-imports` implied by `-D warnings`
|
||||
= help: remove this import
|
||||
|
||||
error: this import is redundant
|
||||
--> $DIR/single_component_path_imports_nested_first.rs:14:17
|
||||
|
|
||||
LL | use {regex, serde};
|
||||
| ^^^^^
|
||||
|
|
||||
= help: remove this import
|
||||
|
||||
error: this import is redundant
|
||||
--> $DIR/single_component_path_imports_nested_first.rs:5:1
|
||||
|
|
||||
LL | use regex;
|
||||
| ^^^^^^^^^^ help: remove it entirely
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
16
tests/ui/single_component_path_imports_self_after.rs
Normal file
16
tests/ui/single_component_path_imports_self_after.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// edition:2018
|
||||
#![warn(clippy::single_component_path_imports)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use self::regex::{Regex as xeger, RegexSet as tesxeger};
|
||||
pub use self::{
|
||||
regex::{Regex, RegexSet},
|
||||
some_mod::SomeType,
|
||||
};
|
||||
use regex;
|
||||
|
||||
mod some_mod {
|
||||
pub struct SomeType;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
17
tests/ui/single_component_path_imports_self_before.rs
Normal file
17
tests/ui/single_component_path_imports_self_before.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// edition:2018
|
||||
#![warn(clippy::single_component_path_imports)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use regex;
|
||||
|
||||
use self::regex::{Regex as xeger, RegexSet as tesxeger};
|
||||
pub use self::{
|
||||
regex::{Regex, RegexSet},
|
||||
some_mod::SomeType,
|
||||
};
|
||||
|
||||
mod some_mod {
|
||||
pub struct SomeType;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue