-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
diagnostics: dead_code does not track trait impls (false negative: unused struct with Clone derived) #57613
Comments
Dupe of #47851 |
Interesting.. why is this only a problem for |
I'm guessing because |
No lint was being generated because of #[derive(Clone)]. rust-lang/rust#57613
No lint was being generated because of #[derive(Clone)]. rust-lang/rust#57613
Is this really a bug? Surely, in the case of a struct with |
If you come up with a very simple definition of "used" and apply it literally, then yes the struct is used in the That’s not to say that such a definition is a useful one. In this case it’s clear that this struct is dead code. In the spirit of the what motivates this lint to exist, a warning should be emitted. In fact, the very simple definition is not the one currently in rustc: struct Foo;
fn foo() {
let _ = Foo;
} Output: warning: struct is never constructed: `Foo`
--> src/lib.rs:1:1
|
1 | struct Foo;
| ^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
warning: function is never used: `foo`
--> src/lib.rs:3:1
|
3 | fn foo() {
| ^^^^^^^^ The It appears that the real issue here is that (methods of) trait impl are not tracked as used/unused the way functions are. |
Closing as a duplicate of #47851 |
there's no
dead_code
warning forwhile
correctly warns:
reproduces with stable 1.31.1, beta 1.32.0-beta.14 and nightly 1.33.0 2019.01.13
The text was updated successfully, but these errors were encountered: