Skip to content

Clippy incorrectly reports redundant imported items #12373

@Robbepop

Description

@Robbepop

Summary

For my crate wasmi_core in https://github.com/wasmi-labs/wasmi/tree/master/crates/core I see the following warnings when running clippy on nightly channel:

warning: the item `Box` is imported redundantly
   --> crates/wasmi/src/store.rs:32:5
    |
32  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /Users/robin/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13
    |
125 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

Many more warnings pop up, but they all are very similar to the one above.
This import is required for proper no_std builds.

In lib.rs we do:

#[cfg(not(feature = "std"))]
extern crate alloc;

Thus alloc is always available as crate root import.

Lint Name

unused_imports

Reproducer

  • Clone the repository https://github.com/wasmi-labs/wasmi (rev = a2f299af2f97af3691e195a4473abaa93bca72f7)
  • Install clippy from current nightly channel. (I use clippy 0.1.78 (ef324565 2024-02-27))
  • Run cargo +nightly clippy -p wasmi_core

Version

rustc 1.78.0-nightly (ef324565d 2024-02-27)
binary: rustc
commit-hash: ef324565d071c6d7e2477a195648549e33d6a465
commit-date: 2024-02-27
host: aarch64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions