1 use crate::sync::debug_sync::{RwLock, Mutex};
5 #[cfg(not(feature = "backtrace"))]
6 fn recursive_lock_fail() {
7 let mutex = Mutex::new(());
8 let _a = mutex.lock().unwrap();
9 let _b = mutex.lock().unwrap();
14 let lock = RwLock::new(());
15 let _a = lock.read().unwrap();
16 let _b = lock.read().unwrap();
22 let a = Mutex::new(());
23 let b = Mutex::new(());
25 let _a = a.lock().unwrap();
26 let _b = b.lock().unwrap();
29 let _b = b.lock().unwrap();
30 let _a = a.lock().unwrap();
36 fn write_lockorder_fail() {
37 let a = RwLock::new(());
38 let b = RwLock::new(());
40 let _a = a.write().unwrap();
41 let _b = b.write().unwrap();
44 let _b = b.write().unwrap();
45 let _a = a.write().unwrap();
51 fn read_lockorder_fail() {
52 let a = RwLock::new(());
53 let b = RwLock::new(());
55 let _a = a.read().unwrap();
56 let _b = b.read().unwrap();
59 let _b = b.read().unwrap();
60 let _a = a.read().unwrap();
65 fn read_recursive_no_lockorder() {
66 // Like the above, but note that no lockorder is implied when we recursively read-lock a
67 // RwLock, causing this to pass just fine.
68 let a = RwLock::new(());
69 let b = RwLock::new(());
70 let _outer = a.read().unwrap();
72 let _a = a.read().unwrap();
73 let _b = b.read().unwrap();
76 let _b = b.read().unwrap();
77 let _a = a.read().unwrap();
83 fn read_write_lockorder_fail() {
84 let a = RwLock::new(());
85 let b = RwLock::new(());
87 let _a = a.write().unwrap();
88 let _b = b.read().unwrap();
91 let _b = b.read().unwrap();
92 let _a = a.write().unwrap();