Open
Description
Lint name:
single_component_path_imports
I tried this code:
#[cfg(feature = "log")]
use log;
mod foo {
use crate::log::warn;
pub fn bar() {
warn!("bar");
}
}
pub fn bar() {
foo::bar()
}
(I think it doesn't matter whether the feature log
is turned on or off.)
I expected to see this happen: no warning, since the log
import is used in an inner module.
Instead, this happened:
warning: this import is redundant
--> src/lib.rs:3:1
|
3 | use log;
| ^^^^^^^^ help: remove it entirely
|
= note: `#[warn(clippy::single_component_path_imports)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
Meta
cargo clippy -V
: clippy 0.1.53 (42816d6 2021-04-24)rustc -Vv
:rustc 1.53.0-nightly (42816d61e 2021-04-24) binary: rustc commit-hash: 42816d61ead7e46d462df997958ccfd514f8c21c commit-date: 2021-04-24 host: x86_64-apple-darwin release: 1.53.0-nightly LLVM version: 12.0.0
cc @ThibsG (re #6905 (comment))