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

cargo fix --edition-idioms tackles macro twice #57211

Closed
richo opened this issue Dec 30, 2018 · 2 comments
Closed

cargo fix --edition-idioms tackles macro twice #57211

richo opened this issue Dec 30, 2018 · 2 comments
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.

Comments

@richo
Copy link
Contributor

richo commented Dec 30, 2018

Sorry if this is already reported, I couldn't find it in the tracker.

This was the easiest case for me to repro, but obviously it could be minimized further to any type with a hidden lifetime param.

macro_rules! bug {
    ($struct:ident) => {
        impl std::fmt::Debug for $struct {
            fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
                fmt.debug_struct(stringify!($struct))
                    .field("token", &"...")
                    .finish()
            }
        }
    };
}

struct Sensitive {
    token: String,
}
bug!(Sensitive);

struct Other {
    token: String,
}
bug!(Other);

from inspecting the output of --broken-code, cargo fix is adding the lifetime param once for each invocation of the macro.

@ehuss
Copy link
Contributor

ehuss commented Dec 30, 2018

I believe this is #55768.

@Centril Centril added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-edition-2018-lints C-bug Category: This is a bug. labels Dec 30, 2018
@richo
Copy link
Contributor Author

richo commented Dec 31, 2018

So it is! Amusing that our usecases were identical.

@richo richo closed this as completed Dec 31, 2018
@fmease fmease added A-edition-2018 Area: The 2018 edition and removed A-edition-2018-lints labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants