Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive on similar_names? #2651

Closed
darnir opened this issue Apr 9, 2018 · 9 comments
Closed

False positive on similar_names? #2651

darnir opened this issue Apr 9, 2018 · 9 comments
Labels
C-bug Category: Clippy is not doing the correct thing T-macros Type: Issues with macros and macro expansion

Comments

@darnir
Copy link

darnir commented Apr 9, 2018

The similar_names lint seems to be very strict with what it considers "similar". For example, I just had clippy give me this warning:

warning: binding's name is too similar to existing binding
  --> src/argparse.rs:53:5
   |
53 |     pub cache_util: f32,
   |     ^^^^^^^^^^^^^^^^^^^
   |
note: lint level defined here
  --> src/main.rs:24:9
   |
24 | #![warn(similar_names)]
   |         ^^^^^^^^^^^^^
note: existing binding defined here
  --> src/argparse.rs:43:5
   |
43 |     pub input: InputType,
   |     ^^^^^^^^^^^^^^^^^^^^

Sure, both of these fields are part of the same struct, but I don't see how input and cache_util are similar or confusing looking variable names.

@phansch phansch added the C-bug Category: Clippy is not doing the correct thing label Apr 9, 2018
@phansch
Copy link
Member

phansch commented Apr 9, 2018

@darnir That does look like a false positive, indeed.
Could you provide the original source of the struct or if that's not possible, a playground link that shows the issue? I can't seem to reproduce it unfortunately.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 9, 2018

I think this might be the issue with spans not having expansion info since the last update. So this is actually occurring inside a derive

@darnir
Copy link
Author

darnir commented Apr 10, 2018

@phansch: Here's the entire struct:

#[derive(Debug)]
pub struct RtaArgs {
    pub input: InputType,
    pub hwdesc: HardwareDescription,
    pub ntasks: u16,
    pub nsets: u16,
    pub save_tasksets: bool,
    pub utilization_begin: f32,
    pub utilization_step: f32,
    pub utilization_end: f32,
    pub min_period: u32,
    pub max_period: u32,
    pub cache_util: f32,
    pub reuse_factor: f32,
}

@phansch
Copy link
Member

phansch commented Apr 10, 2018

@darnir thanks!

@oli-obk I guess you're correct: https://play.rust-lang.org/?gist=77d160aa9b7de5f0e132f4c65aa316d9&version=nightly

It only triggers when the #[derive(Debug)] is there.

@phansch
Copy link
Member

phansch commented Apr 26, 2018

Looks like this is caused by rust-lang/rust#49154, which broke the macro check in some cases.

@phansch phansch added the T-macros Type: Issues with macros and macro expansion label Apr 29, 2018
@darnir
Copy link
Author

darnir commented May 11, 2018

Given how this is still a broken lint, how about adding it to the list of known problems and maybe disabling while it is fixed?

EDIT: Just realized, I've been explicitly enabling it.
But, adding this to the list of known problems still stands

@oli-obk
Copy link
Contributor

oli-obk commented May 11, 2018

The lint isn't broken, rustc is. If we disable this lint we could just as well disable all clippy lints, because all of them have this issue in some form or another ;)

I'll try to find the root cause in rustc today.

@gnzlbg
Copy link
Contributor

gnzlbg commented Aug 23, 2018

I am having this issue with structopt derives :/ I was confused at first but in hindsight it makes sense.

@flip1995
Copy link
Member

Will probably be fixed with the next nightly.

matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Sep 8, 2018
@ghost ghost closed this as completed in #3149 Sep 9, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

No branches or pull requests

5 participants