New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Borrowing error refers to ***borrow
when borrow
should be &mut i32
#33071
Comments
@birkenfeld In closure you have |
@KalitaAlexey I know. The point of the issue isn't that it should compile, but that the error message is strange: it refers to |
Not sure if this helps, but using a move closure as shown below changes the name in the error let mut var = 0i32;
let borrow = &mut var;
move || {
let borrow_borrow: &&mut i32 = &borrow;
*borrow = 1;
};
|
Triage: non-lexical lifetimes makes this code work. But without it, this error still happens. Are there other code samples that trigger this error? Because eventually, in practice, nobody will see it, even if it's bad. |
fn main() {
let mut var = 0i32;
let borrow = &mut var;
|| {
let borrow_borrow = &borrow;
*borrow = 1;
let _use = borrow_borrow;
};
} gives (with NLL)
So the diagnostic is fixed when NLL is enabled. |
Now that NLL is stably deployed for all editions, closing as fixed. |
Found on rustc 1.10.0-nightly (2174bd9 2016-04-14). Minimal example:
The error is
Actually trying to assign to
***borrow
or**borrow
fails with the expected "i32 cannot be dereferenced".The text was updated successfully, but these errors were encountered: