Closed
Description
Code:
fn main() {
let mut x = &5;
{
let y = 5;
x = &y;
}
}
Compiler's output:
error: `y` does not live long enough
--> <anon>:6:5
|
5 | x = &y;
| - borrow occurs here
6 | }
| ^ `y` dropped here while still borrowed
7 | }
| - borrowed value needs to live until here
error: aborting due to previous error
Look at --> <anon>:6:5
.
It points to the }
,
but I expected it to point to the y
.
Look at | ^
y dropped here while still borrowed
.
It is treated as a primary span,
but I expected | - borrow occurs here
to be treated as a primary span.
It is bad for editors, i.e., VSCode.