-
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
"variant is never constructed" lint appears to be incorrect? #64362
Comments
Bug report: rust-lang/rust#64362 Signed-off-by: iliana destroyer of worlds <[email protected]>
This is correct. Your snippet is treated as a library, where the enum Behavoir inteded and therefore this can be closed. |
The bug is that it doesn't trigger for If the lint triggered for all variants, then it would just say:
|
The problem seems to manifest itself when variants with named fields are constructed using Here is a minimal example (playground): #[derive(Debug)]
enum Foo {
A { data: u32 },
}
impl Foo {
fn new() -> Self {
Self::A { data: 0 }
}
}
fn main() {
println!("created: {:?}", Foo::new());
} |
@rustbot claim |
Fix false "never constructed" warnings for `Self::` variant paths Closes rust-lang#64362.
Bug report: rust-lang/rust#64362 Signed-off-by: iliana destroyer of worlds <[email protected]>
Bug report: rust-lang/rust#64362 Signed-off-by: iliana destroyer of worlds <[email protected]>
Bug report: rust-lang/rust#64362 Signed-off-by: iliana destroyer of worlds <[email protected]>
Bug report: rust-lang/rust#64362 Signed-off-by: iliana destroyer of worlds <[email protected]>
Here is a slightly altered playground to illlustrate further. |
This code (playground) causes a "variant is never constructed" lint, even though the variant is constructed in the
FromStr
implementation:Changing
Self
for the type name infrom_str
forFoo
(playground) compiles with the "field is never used" lint I would expect from this code.Tested on
rustc 1.39.0-nightly (0b36e9dea 2019-09-09)
This issue has been assigned to @jakubadamw via this comment.
The text was updated successfully, but these errors were encountered: