]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/send-is-not-static-std-sync-2.rs
Rollup merge of #87922 - Manishearth:c-enum-target-spec, r=nagisa,eddyb
[rust.git] / src / test / ui / span / send-is-not-static-std-sync-2.rs
1 // basic tests to see that certain "obvious" errors are caught by
2 // these types no longer requiring `'static` (RFC 458)
3
4 #![allow(dead_code)]
5
6 use std::sync::{Mutex, RwLock, mpsc};
7
8 fn mutex() {
9     let lock = {
10         let x = 1;
11         Mutex::new(&x)
12     };
13     //~^^ ERROR `x` does not live long enough
14
15     let _dangling = *lock.lock().unwrap();
16 }
17
18 fn rwlock() {
19     let lock = {
20         let x = 1;
21         RwLock::new(&x)
22     };
23     //~^^ ERROR `x` does not live long enough
24     let _dangling = *lock.read().unwrap();
25 }
26
27 fn channel() {
28     let (_tx, rx) = {
29         let x = 1;
30         let (tx, rx) = mpsc::channel();
31         let _ = tx.send(&x);
32         (tx, rx)
33     };
34     //~^^^ ERROR `x` does not live long enough
35
36     let _dangling = rx.recv();
37 }
38
39 fn main() {}