1 // basic tests to see that certain "obvious" errors are caught by
2 // these types no longer requiring `'static` (RFC 458)
6 use std::sync::{Mutex, RwLock, mpsc};
11 let lock = Mutex::new(&x);
12 *lock.lock().unwrap() = &*y;
13 drop(y); //~ ERROR cannot move out
16 *lock.lock().unwrap() = &z;
18 //~^^ ERROR `z` does not live long enough
19 lock.use_ref(); // (Mutex is #[may_dangle] so its dtor does not use `z` => needs explicit use)
25 let lock = RwLock::new(&x);
26 *lock.write().unwrap() = &*y;
27 drop(y); //~ ERROR cannot move out
30 *lock.write().unwrap() = &z;
32 //~^^ ERROR `z` does not live long enough
33 lock.use_ref(); // (RwLock is #[may_dangle] so its dtor does not use `z` => needs explicit use)
39 let (tx, rx) = mpsc::channel();
43 drop(y); //~ ERROR cannot move out
48 //~^^ ERROR `z` does not live long enough
49 // (channels lack #[may_dangle], thus their dtors are implicit uses of `z`)
54 trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
55 impl<T> Fake for T { }