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