-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improvements to the dead code lint #17410
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
Conversation
The main change here is that rustc will now warn about variants that are never constructed. I concluded this would be a worthwhile lint after finding that
Funnily enough, with this change rustc still doesn't warn about that particular case due to the Clone trait being derived on the In addition, I changed the messages to be more descriptive with regards to the particular nodes that are proven unused. Last, but not least, I also investigated how much dead code there is in rustc after disabling re-exports. Turns out, quite a lot. I carefully removed what I thought was truly dead code but I still question if it's something we should do. |
ExponentFormat, ExpNone, ExpDec, ExpBin, | ||
SignFormat, SignNone, SignNeg, SignAll, | ||
SignificantDigits, DigAll, DigMax, DigExact | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module is still currently one I'd like to leave as a private implementation detail as part of libcore, was there a reason for exporting these variants?
I do feel bad for duplicating the parsing between std/core!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just noticed the duplication between libcore and libstd.
That is fair enough. Not all of the variants in libcore are actually being used so I can remove the unused ones or annotate them with #[allow(dead_code)]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcrichton I brought back the libcore versions of the types without the unused variants, if that's OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
@alexcrichton Fixed the Windows issue. r? |
This implements a wish suggested in rust-lang#17410, detecting enum variants that are never constructed, even in the presence of `#[derive(Clone)]`. The implementation is general and not specific to `#[derive(Clone)]`. r? @jakub-
No description provided.