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

derive(Clone, Debug) should not prevent "field is never read" from firing #84647

Closed
matklad opened this issue Apr 28, 2021 · 1 comment · Fixed by #85200
Closed

derive(Clone, Debug) should not prevent "field is never read" from firing #84647

matklad opened this issue Apr 28, 2021 · 1 comment · Fixed by #85200
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@matklad
Copy link
Member

matklad commented Apr 28, 2021

struct A { f: () }
#[derive(Clone)]
struct B { f: () }

fn main() {
    let _ = A { f: () };
    let _ = B { f: () };
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ddbb661ad3a117642c4f750b31da4b18

Only A's field triggers the warning. It's clear why B doesn't do this, but it clearly should. Doesn't seem easy to fix though :(

@matklad matklad changed the title derive(Clone) should not prevent "field is never read" from firing derive(Clone, Debug) should not prevent "field is never read" from firing Apr 28, 2021
matklad added a commit to matklad/rust-analyzer that referenced this issue Apr 28, 2021
matklad added a commit to matklad/rust-analyzer that referenced this issue Apr 28, 2021
@jonas-schievink jonas-schievink added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Apr 28, 2021
@bors bors closed this as completed in acfe7c4 Sep 11, 2021
@est31
Copy link
Member

est31 commented Sep 15, 2021

There is discussion in #88900 whether the desired (and now implemented on nightly) behaviour is good for Debug or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants