-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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
Code
struct Foo {
field: u32,
}
impl Foo {
fn field(&self) -> u32 {
self.field
}
fn new() -> Foo {
Foo { field }
}
}
Current output
error[E0425]: cannot find value `field` in this scope
--> src/lib.rs:11:15
|
11 | Foo { field }
| ^^^^^ a field by this name exists in `Self`
|
help: consider using the associated function
|
11 | Foo { self.field }
| +++++
We should not suggest using self.field
inside of a struct initializer.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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.