Closed
Description
e.g. in E0596:
fn main() {
let x = 1;
let y = &mut x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR [E0596]
}
AST borrowck knows that x
is an "immutable local variable", but MIR semi-inaccurately calls it an immutable item:
error[E0596]: cannot borrow immutable local variable `x` as mutable (Ast)
--> /home/ariel/Rust/rust-master/src/test/compile-fail/E0596.rs:16:18
|
15 | let x = 1;
| - consider changing this to `mut x`
16 | let y = &mut x; //[ast]~ ERROR [E0596]
| ^ cannot borrow mutably
error[E0596]: cannot borrow immutable item `x` as mutable (Mir)
--> /home/ariel/Rust/rust-master/src/test/compile-fail/E0596.rs:16:13
|
16 | let y = &mut x; //[ast]~ ERROR [E0596]
| ^^^^^^ cannot borrow as mutable
error: aborting due to 2 previous errors
The AST code for doing that is actually in mem_categorization
, and should be ported to MIR borrowck:
rust/src/librustc/middle/mem_categorization.rs
Line 1450 in 02b4d3d