clippy 0.0.212 / rustc 1.30.0-nightly (d767ee116 2018-08-15)
code:
````rust
pub(crate) struct DirSizes {
pub(crate) total_size: u64, // total size of cargo root dir
pub(crate) numb_bins: u64, // number of binaries found
pub(crate) total_bin_size: u64, // total size of binaries found
pub(crate) total_reg_size: u64, // registry size
pub(crate) total_git_db_size: u64, // size of bare repos and checkouts combined
pub(crate) total_git_repos_bare_size: u64, // git db size
pub(crate) numb_git_repos_bare_repos: u64, // number of cloned repos
pub(crate) numb_git_checkouts: u64, // number of checked out repos
pub(crate) total_git_chk_size: u64, // git checkout size
pub(crate) total_reg_cache_size: u64, // registry cache size
pub(crate) total_reg_src_size: u64, // registry sources size
pub(crate) numb_reg_cache_entries: u64, // number of source archives
pub(crate) numb_reg_src_checkouts: u64, // number of source checkouts
}
fn main() {
println!("Hello, world!");
}
````
I'm getting similar_names warning for binding names total_reg_src_size and total_size although levensthein distance of these is 8.
Was the check tightened recently?
Also:
numb_reg_src_checkouts and total_bin_size (????)
o_O The warnings disappear as soon as I remove #[derive(Debug, Clone)]
Something really weird is happening here Playground (original):
insane thinks I tried
The lint gets always triggered on the 10th line after total_size and total_bin_size. So if we move total_bin_size it will trigger on the 10th line after it. If we remove a field from the struct it won't get triggered on total_bin_size anymore, because there are only 9 fields defined after that. Playground
Well, or maybe not... If we remove a field above total_bin_size it also won't get triggered, even if the 10th field after it is still the same. Playground
With total_size it's always the 10th element below. Except we remove total_size itself, then it triggers on numb_bins and numb_reg_cache_entries Playground. It also doesn't matter what the 11th field is... It just lints..
Let's move total_size to the bottom Playground. It just lints on the 11th and 13th field with the field 10 lines above.
So it seems, that this lint doesn't like odd numbers greater than 10. Time to go crazy: let's add a 14th and 15th field and see what happens: Playground
Well it lints on.. both.... But the 10 field distance is still the same.
Why stop at 15 fields? Playground
It lints on field11, field13..20 with field1, field3..10. So it likes field12.
It lints on field21..22, field24..30 with field1..2, field4..10. So it likes field23.
It lints on field31..33, field35..30 with field1..3, field5..10. So it likes field34.
I think it will go on like this.
You're seeing the same things right? Am I going crazy? Send help!! :smile:
EDIT: Deriving both Debug and Clone will lint on field11 twice, but not on every other field.
It's a macro expansion problem. If you use cargo rustc -- -Z unpretty=hir and fix the compilation errors, it starts to make more sense.
Checking playground v0.0.1 (file:///playground)
warning: binding's name is too similar to existing binding
--> src/main.rs:47:41
|
47 | total_reg_src_size: ref __self_0_10,
| ^^^^^^^^^^^
|
note: lint level defined here
--> src/main.rs:1:44
|
1 | #![cfg_attr(feature = "cargo-clippy", warn(similar_names))]
| ^^^^^^^^^^^^^
note: existing binding defined here
--> src/main.rs:37:33
|
37 | total_size: ref __self_0_0,
| ^^^^^^^^^^
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#similar_names
It's already been fixed by #3056.
Oh I thought this was already in the Clippy version of yesterday. Even better then!
@flip1995 it can take few days before rust module is updated.