Closed
Description
Hi everybody,
While playing with Rust move/borrow, I ran across a strange behavior, that comes from the following code:
struct Point<'a> {x123: &'a mut i32, y541: &'a mut i32}
fn main() {
let p123 = Point {x123: &mut 10, y541: &mut 11};
let x : &mut i32 = p123.x123;
let y = p123.y541;
let z = p123;
}
The thing that happens is that p123.x123 is borrowed by x, while p123.y541 is moved in y (according to the error messages). I think that this may happen from the type inference that finds that x and p123.x123 do not have the same type of pointer (different lifetimes ?) and hence does a reborrow, is it correct ? Is it an expected feature of the type checker ?
Thanks in advance.