Make core::sync::atomic::Ordering #[non_exhaustive]
This commit is contained in:
parent
a5733050de
commit
bbf0b159b7
@ -120,6 +120,7 @@
|
||||
#![feature(const_slice_len)]
|
||||
#![feature(const_str_as_bytes)]
|
||||
#![feature(const_str_len)]
|
||||
#![feature(non_exhaustive)]
|
||||
|
||||
#[prelude_import]
|
||||
#[allow(unused)]
|
||||
|
@ -185,6 +185,7 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
|
||||
/// [nomicon]: ../../../nomicon/atomics.html
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[non_exhaustive]
|
||||
pub enum Ordering {
|
||||
/// No ordering constraints, only atomic operations.
|
||||
///
|
||||
@ -256,10 +257,6 @@ pub enum Ordering {
|
||||
/// [`AcqRel`]: https://llvm.org/docs/Atomics.html#acquirerelease
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
SeqCst,
|
||||
// Prevent exhaustive matching to allow for future extension
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "future_atomic_orderings", issue = "0")]
|
||||
__Nonexhaustive,
|
||||
}
|
||||
|
||||
/// An [`AtomicBool`] initialized to `false`.
|
||||
@ -1954,7 +1951,6 @@ fn strongest_failure_ordering(order: Ordering) -> Ordering {
|
||||
SeqCst => SeqCst,
|
||||
Acquire => Acquire,
|
||||
AcqRel => Acquire,
|
||||
__Nonexhaustive => __Nonexhaustive,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1966,7 +1962,6 @@ unsafe fn atomic_store<T>(dst: *mut T, val: T, order: Ordering) {
|
||||
SeqCst => intrinsics::atomic_store(dst, val),
|
||||
Acquire => panic!("there is no such thing as an acquire store"),
|
||||
AcqRel => panic!("there is no such thing as an acquire/release store"),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1978,7 +1973,6 @@ unsafe fn atomic_load<T>(dst: *const T, order: Ordering) -> T {
|
||||
SeqCst => intrinsics::atomic_load(dst),
|
||||
Release => panic!("there is no such thing as a release load"),
|
||||
AcqRel => panic!("there is no such thing as an acquire/release load"),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1991,7 +1985,6 @@ unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_xchg_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_xchg_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_xchg(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2004,7 +1997,6 @@ unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_xadd_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_xadd_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_xadd(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2017,7 +2009,6 @@ unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_xsub_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_xsub_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_xsub(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2039,8 +2030,6 @@ unsafe fn atomic_compare_exchange<T>(dst: *mut T,
|
||||
(AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_failrelaxed(dst, old, new),
|
||||
(SeqCst, Relaxed) => intrinsics::atomic_cxchg_failrelaxed(dst, old, new),
|
||||
(SeqCst, Acquire) => intrinsics::atomic_cxchg_failacq(dst, old, new),
|
||||
(__Nonexhaustive, _) => panic!("invalid memory ordering"),
|
||||
(_, __Nonexhaustive) => panic!("invalid memory ordering"),
|
||||
(_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"),
|
||||
(_, Release) => panic!("there is no such thing as a release failure ordering"),
|
||||
_ => panic!("a failure ordering can't be stronger than a success ordering"),
|
||||
@ -2065,8 +2054,6 @@ unsafe fn atomic_compare_exchange_weak<T>(dst: *mut T,
|
||||
(AcqRel, Relaxed) => intrinsics::atomic_cxchgweak_acqrel_failrelaxed(dst, old, new),
|
||||
(SeqCst, Relaxed) => intrinsics::atomic_cxchgweak_failrelaxed(dst, old, new),
|
||||
(SeqCst, Acquire) => intrinsics::atomic_cxchgweak_failacq(dst, old, new),
|
||||
(__Nonexhaustive, _) => panic!("invalid memory ordering"),
|
||||
(_, __Nonexhaustive) => panic!("invalid memory ordering"),
|
||||
(_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"),
|
||||
(_, Release) => panic!("there is no such thing as a release failure ordering"),
|
||||
_ => panic!("a failure ordering can't be stronger than a success ordering"),
|
||||
@ -2082,7 +2069,6 @@ unsafe fn atomic_and<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_and_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_and_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_and(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2094,7 +2080,6 @@ unsafe fn atomic_nand<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_nand_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_nand_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_nand(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2106,7 +2091,6 @@ unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_or_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_or_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_or(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2118,7 +2102,6 @@ unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_xor_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_xor_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_xor(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2131,7 +2114,6 @@ unsafe fn atomic_max<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_max_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_max_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_max(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2144,7 +2126,6 @@ unsafe fn atomic_min<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_min_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_min_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_min(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2157,7 +2138,6 @@ unsafe fn atomic_umax<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_umax_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_umax_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_umax(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2170,7 +2150,6 @@ unsafe fn atomic_umin<T>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
AcqRel => intrinsics::atomic_umin_acqrel(dst, val),
|
||||
Relaxed => intrinsics::atomic_umin_relaxed(dst, val),
|
||||
SeqCst => intrinsics::atomic_umin(dst, val),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2260,7 +2239,6 @@ pub fn fence(order: Ordering) {
|
||||
AcqRel => intrinsics::atomic_fence_acqrel(),
|
||||
SeqCst => intrinsics::atomic_fence(),
|
||||
Relaxed => panic!("there is no such thing as a relaxed fence"),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2350,7 +2328,6 @@ pub fn compiler_fence(order: Ordering) {
|
||||
AcqRel => intrinsics::atomic_singlethreadfence_acqrel(),
|
||||
SeqCst => intrinsics::atomic_singlethreadfence(),
|
||||
Relaxed => panic!("there is no such thing as a relaxed compiler fence"),
|
||||
__Nonexhaustive => panic!("invalid memory ordering"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user