]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-move-mut-base-ptr.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-move-mut-base-ptr.rs
1 // Test that attempt to move `&mut` pointer while pointee is borrowed
2 // yields an error.
3 //
4 // Example from compiler/rustc_borrowck/borrowck/README.md
5
6
7
8 fn foo(t0: &mut isize) {
9     let p: &isize = &*t0; // Freezes `*t0`
10     let t1 = t0;        //~ ERROR cannot move out of `t0`
11     *t1 = 22;
12     p.use_ref();
13 }
14
15 fn main() {
16 }
17
18 trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { }  }
19 impl<T> Fake for T { }