- 
                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 lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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
STR
fn main() {
    let mut y = 0;
    || {
        let b = &y;
        y += 1;
        *b
    };
}Result
error[E0506]: cannot assign to `**y` because it is borrowed
 --> src/main.rs:5:9
  |
4 |         let b = &y;
  |                  - borrow of `**y` occurs here
5 |         y += 1;
  |         ^^^^^^ assignment to borrowed `**y` occurs here
error: aborting due to previous error
y is an integer, so **y isn't actually a thing. We emit the dereferences because there are layers of indirection before we get to the upvar, but they aren't actually a part of the user-visible syntax.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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.