-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
Or at the very least this should be a configuration option for the lint. Usually importing a trait this way means the name is never used in the code so it is sensible to not rename e.g. std::io::Write to IoWrite to distinguish it from std::fmt::Write in those cases.
Lint Name
missing_enforced_import_renames
Reproducer
I tried this code:
use std::io::Write as _;with the lint set to deny in Cargo.toml and clippy toml
enforced-import-renames = [
{ path = "std::fmt::Write", rename = "FmtWrite" },
{ path = "std::io::Write", rename = "IoWrite" },
]I saw this happen:
error: this import should be renamed
--> code.rs:4:1
|
4 | use std::io::Write as _;
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `use std::io::Write as IoWrite`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#missing_enforced_import_renames
I expected to see this happen:
No lint error because I assumed the lint was intended for situations where the name is actually imported to be used in the code.
Version
rustc 1.91.1 (ed61e7d7e 2025-11-07)
binary: rustc
commit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb
commit-date: 2025-11-07
host: x86_64-unknown-linux-gnu
release: 1.91.1
LLVM version: 21.1.2
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have