1 // Test that if we deref an immutable borrow to access a Place,
2 // then we can't mutate the final place.
4 #![feature(capture_disjoint_fields)]
5 //~^ WARNING: the feature `capture_disjoint_fields` is incomplete
8 let mut x = (format!(""), format!("X2"));
10 let z = (&mut y, "Z");
12 // `x.0` is mutable but we access `x` via `z.0.0`, which is an immutable reference and
13 // therefore can't be mutated.
15 //~^ ERROR: cannot borrow `z.0.0.0` as mutable, as it is behind a `&` reference
16 z.0.0.0 = format!("X1");
17 //~^ ERROR: cannot assign to `z`, as it is not declared as mutable