1 // Test that attempt to mutably borrow `&mut` pointer while pointee is
2 // borrowed yields an error.
4 // Example from compiler/rustc_borrowck/borrowck/README.md
8 fn foo<'a>(mut t0: &'a mut isize,
9 mut t1: &'a mut isize) {
10 let p: &isize = &*t0; // Freezes `*t0`
11 let mut t2 = &mut t0; //~ ERROR cannot borrow `t0`
12 **t2 += 1; // Mutates `*t0`
16 fn bar<'a>(mut t0: &'a mut isize,
17 mut t1: &'a mut isize) {
18 let p: &mut isize = &mut *t0; // Claims `*t0`
19 let mut t2 = &mut t0; //~ ERROR cannot borrow `t0`
20 **t2 += 1; // Mutates `*t0` but not through `*p`
27 trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
28 impl<T> Fake for T { }