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

2018 idioms: duplicate suggestion for anonymous lifetime #55768

Open
alexcrichton opened this Issue Nov 7, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@alexcrichton
Copy link
Member

alexcrichton commented Nov 7, 2018

First reported here this code:

#![warn(rust_2018_idioms)]

macro_rules! foo {
    ($name:ident) => {
        pub struct $name;
        impl ::std::fmt::Debug for $name {
            fn fmt(&self, _fmt: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
                Ok(())
            }
        }
    }
}

foo!(One);
foo!(Two);

fn main() {}

when compiled yields two warnings to insert anonymous lifetimes. While we as humans can figure this out pretty well, Cargo as a merciless program can't figure this out and cargo fix attempts to apply the fix twice, creating invalid <'_><'_> syntax.

It's not clear whether it's best to fix this in cargo fix or fix this in the compiler itself. I figure it's easiest to track all idiom-lint related issues in this repository though, so I've opted to move it over here.

@zackmdavis

This comment has been minimized.

Copy link
Member

zackmdavis commented Nov 8, 2018

I think we could use the session's one-time diagnostics functionality to de-duplicate just the suggestion? (I assume this would require stripping expansion info from the spans.) If this is a good idea, it might also generalize to other lints ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment