]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs
Auto merge of #107663 - matthiaskrgr:107423-point-at-EOF-code, r=compiler-errors
[rust.git] / tests / ui / borrowck / borrowck-move-from-subpath-of-borrowed-path.rs
1 // verify that an error is raised when trying to move out of a
2 // borrowed path.
3
4
5
6
7
8 fn main() {
9     let a: Box<Box<_>> = Box::new(Box::new(2));
10     let b = &a;
11
12     let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed
13     b.use_ref();
14 }
15
16 trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { }  }
17 impl<T> Fake for T { }