- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`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 (playground):
struct A {
    banana: u8,
}
impl A {
    fn new(peach: u8) -> A {
        A {
            banana: banana // note: banana not in scope here
        }
    }
}produces the following error:
error[E0425]: cannot find value `banana` in this scope
 --> src/lib.rs:8:21
  |
8 |             banana: banana
  |                     ^^^^^^
  |                     |
  |                     `self` value is a keyword only available in methods with `self` parameter
  |                     help: try: `self.banana`
First, help is wrong, because this is a static method and self is not available in scope. Second it is not clear why a line above help is talking about self at all.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`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.