]> git.lizzy.rs Git - rust.git/blob - tests/ui/atomic_ordering_bool.rs
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
[rust.git] / tests / ui / atomic_ordering_bool.rs
1 #![warn(clippy::invalid_atomic_ordering)]
2
3 use std::sync::atomic::{AtomicBool, Ordering};
4
5 fn main() {
6     let x = AtomicBool::new(true);
7
8     // Allowed load ordering modes
9     let _ = x.load(Ordering::Acquire);
10     let _ = x.load(Ordering::SeqCst);
11     let _ = x.load(Ordering::Relaxed);
12
13     // Disallowed load ordering modes
14     let _ = x.load(Ordering::Release);
15     let _ = x.load(Ordering::AcqRel);
16
17     // Allowed store ordering modes
18     x.store(false, Ordering::Release);
19     x.store(false, Ordering::SeqCst);
20     x.store(false, Ordering::Relaxed);
21
22     // Disallowed store ordering modes
23     x.store(false, Ordering::Acquire);
24     x.store(false, Ordering::AcqRel);
25 }