Closed
Description
In particular this program ought to be illegal:
struct S<'self> {
pointer: &'self mut int
}
fn copy_borrowed_ptr2<'a>(p: &'a mut S<'a>) -> S<'a> {
S { pointer: &mut *p.pointer }
}
fn main() {
let mut x = 1;
{
let mut y = S { pointer: &mut x };
let z = copy_borrowed_ptr2(&mut y);
*y.pointer += 1; // ERROR EXPECTED HERE
*z.pointer += 1;
}
}
See also #8624