- Notifications
You must be signed in to change notification settings - Fork 14k
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.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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
Consider the following code snippet:
struct Foo { inner: u32, } impl From<u32> for Foo { fn from(inner: u32) -> Self { Self { inner } } } This will trigger a 'struct is never constructed' warning, even though the struct is clearly constructed in the implementation of From<u32>.
The problem seems to be caused by using Self as the constructor. If I replace Self with the name of the struct, as in the following code snippet, the warning goes away:
struct Foo { inner: u32, } impl From<u32> for Foo { fn from(inner: u32) -> Self { Foo { inner } } } drrlvn
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.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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.