-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
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 havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
I tried this code:
#![allow(unused_variables)]
#![warn(clippy::similar_names)]
fn main() {
let types = [1, 2, 3];
let type_ = 3;
}I expected Clippy to not emit any warnings since types and type_ are visually distinct (in my eyes).
Instead, Clippy reported similar_names suggesting to change type_ to type__ which does not make much sense to me.
Edit: Together with types, I use the identifier type_ quite a lot in my code base, which is a compiler. The unusual name obviously stems from the fact that type is a keyword in Rust and thus I cannot use it (but I prefer it to typ or r#type). All that to say, this is not an artificial corner case.
Meta
clippy 0.0.212 (1c389ff 2020-11-24)rustc 1.50.0-nightly (1c389ffef 2020-11-24)
Full Standard Error
warning: binding's name is too similar to existing binding
--> src/main.rs:6:9
|
6 | let type_ = 3;
| ^^^^^
|
note: the lint level is defined here
--> src/main.rs:2:9
|
2 | #![warn(clippy::similar_names)]
| ^^^^^^^^^^^^^^^^^^^^^
note: existing binding defined here
--> src/main.rs:5:9
|
5 | let types = [1, 2, 3];
| ^^^^^
help: separate the discriminating character by an underscore like: `type__`
--> src/main.rs:6:9
|
6 | let type_ = 3;
| ^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#similar_names
warning: 1 warning emitted
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 havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy