mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-05 02:50:32 +00:00
25 lines
678 B
Rust
25 lines
678 B
Rust
#![warn(clippy::invalid_atomic_ordering)]
|
|
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
|
|
|
fn main() {
|
|
let x = AtomicBool::new(true);
|
|
|
|
// Allowed load ordering modes
|
|
let _ = x.load(Ordering::Acquire);
|
|
let _ = x.load(Ordering::SeqCst);
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
// Disallowed load ordering modes
|
|
let _ = x.load(Ordering::Release);
|
|
let _ = x.load(Ordering::AcqRel);
|
|
|
|
// Allowed store ordering modes
|
|
x.store(false, Ordering::Release);
|
|
x.store(false, Ordering::SeqCst);
|
|
x.store(false, Ordering::Relaxed);
|
|
|
|
// Disallowed store ordering modes
|
|
x.store(false, Ordering::Acquire);
|
|
x.store(false, Ordering::AcqRel);
|
|
}
|