rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

single_component_path_imports should respect #[allow(unused_imports)]

Open dhardy opened this issue 3 years ago • 2 comments

Summary

To achieve dynamic linking, I use this:

#[cfg(feature = "dynamic")]
#[allow(unused_imports)]
use kas_dylib;

Without this import, built executables do not dynamically link this library. Bevy does the same.

Clippy complains:

warning: this import is redundant
  --> src/lib.rs:59:1
   |
59 | use kas_dylib;
   | ^^^^^^^^^^^^^^ 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

Since this import already has #[allow(unused_imports)] I would expect Clippy to ignore it.

Lint Name

single_component_path_imports

Reproducer

No response

Version

rustc 1.64.0-nightly (2f3ddd9f5 2022-06-27)

Additional Labels

No response

dhardy avatar Jul 09 '22 10:07 dhardy

@dhardy Is it still issue? Can't reproduce it playground

alex-semenyuk avatar Aug 05 '22 09:08 alex-semenyuk

Yes. On kas master:

❯ rustc +nightly -V
rustc 1.64.0-nightly (f6f9d5e73 2022-08-04)
❯ cargo +nightly clippy --all-features
[...]
    Checking kas v0.11.0 (/home/dhardy/projects/kas/kas)
warning: this import is redundant
   --> src/lib.rs:112:1
    |
112 | use kas_dylib;
    | ^^^^^^^^^^^^^^ 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

dhardy avatar Aug 05 '22 14:08 dhardy

Clippy now respects #[allow(unused_imports)], this issue can now be closed.

Ahmard avatar Nov 11 '23 11:11 Ahmard