2013-05-26 04:48:04 -05:00
|
|
|
// Test that attempt to move `&mut` pointer while pointee is borrowed
|
|
|
|
// yields an error.
|
|
|
|
//
|
2020-08-27 22:58:48 -05:00
|
|
|
// Example from compiler/rustc_borrowck/borrowck/README.md
|
2013-05-26 04:48:04 -05:00
|
|
|
|
2018-08-14 18:16:05 -05:00
|
|
|
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn foo(t0: &mut isize) {
|
|
|
|
let p: &isize = &*t0; // Freezes `*t0`
|
2013-05-26 04:48:04 -05:00
|
|
|
let t1 = t0; //~ ERROR cannot move out of `t0`
|
|
|
|
*t1 = 22;
|
2018-08-14 18:16:05 -05:00
|
|
|
p.use_ref();
|
2013-05-26 04:48:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2013-09-23 19:20:36 -05:00
|
|
|
}
|
2018-08-14 18:16:05 -05:00
|
|
|
|
|
|
|
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
|
|
|
|
impl<T> Fake for T { }
|