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

dead_code lint considers use in derive impls #48679

Closed
jethrogb opened this issue Mar 2, 2018 · 2 comments
Closed

dead_code lint considers use in derive impls #48679

jethrogb opened this issue Mar 2, 2018 · 2 comments
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jethrogb
Copy link
Contributor

jethrogb commented Mar 2, 2018

This code:

struct S {
    f: i32
}

impl S {
    fn u(self) {}
}

fn main() {
    let a = S { f: 3 };
    a.u();
}

results in this lint:

warning: field is never used: `f`
 --> test.rs:2:5
  |
2 |     f: i32
  |     ^^^^^^
  |
  = note: #[warn(dead_code)] on by default

But this code:

#[derive(Debug)] // added line compared to above
struct S {
    f: i32
}

impl S {
    fn u(self) {}
}

fn main() {
    let a = S { f: 3 };
    a.u();
}

doesn't.

@nagisa
Copy link
Member

nagisa commented Mar 3, 2018

Related #47851

@pietroalbini pietroalbini added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 6, 2018
@Mark-Simulacrum
Copy link
Member

I feel that this isn't just related but a duplicate of #47851, so closing in favor of it.

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants