-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code produces an incorrect dead code warning ("warning: variant is never constructed: Variant
"), when using the Self
keyword. When using the enumeration name (E
), there is no warning.
// rustc --edition 2018 --crate-type rlib warning.rs
enum E {
Variant { _unused: () }
}
impl E {
fn new() -> Self {
Self::Variant { _unused: () }
// E::Variant { _unused: () } // <-- warning vanishes
}
}
pub struct S(E);
impl S {
pub fn new() -> Self {
Self(E::new())
}
}
Tested versions:
rustc 1.41.0 (5e1a79984 2020-01-27)
rustc 1.42.0-nightly (212b2c7da 2020-01-30)
rustc 1.43.0-nightly (58b834344 2020-02-05)
This issue has been assigned to @matprec via this comment.
davidvartan
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.