1 // Test that assignments to an `&mut` pointer which is found in a
2 // borrowed (but otherwise non-aliasable) location is illegal.
4 // compile-flags: -C overflow-checks=off
10 fn copy_borrowed_ptr
<'a
>(p
: &'a
mut S
<'a
>) -> S
<'a
> {
11 S { pointer: &mut *p.pointer }
18 let mut y
= S { pointer: &mut x }
;
19 let z
= copy_borrowed_ptr(&mut y
);
21 //~^ ERROR cannot use `*y.pointer` because it was mutably borrowed [E0503]
22 //~| ERROR cannot assign to `*y.pointer` because it is borrowed [E0506]