Skip to content

Commit bbf0b15

Browse files
committed
Make core::sync::atomic::Ordering #[non_exhaustive]
1 parent a573305 commit bbf0b15

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
#![feature(const_slice_len)]
121121
#![feature(const_str_as_bytes)]
122122
#![feature(const_str_len)]
123+
#![feature(non_exhaustive)]
123124

124125
#[prelude_import]
125126
#[allow(unused)]

src/libcore/sync/atomic.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
185185
/// [nomicon]: ../../../nomicon/atomics.html
186186
#[stable(feature = "rust1", since = "1.0.0")]
187187
#[derive(Copy, Clone, Debug)]
188+
#[non_exhaustive]
188189
pub enum Ordering {
189190
/// No ordering constraints, only atomic operations.
190191
///
@@ -256,10 +257,6 @@ pub enum Ordering {
256257
/// [`AcqRel`]: https://llvm.org/docs/Atomics.html#acquirerelease
257258
#[stable(feature = "rust1", since = "1.0.0")]
258259
SeqCst,
259-
// Prevent exhaustive matching to allow for future extension
260-
#[doc(hidden)]
261-
#[unstable(feature = "future_atomic_orderings", issue = "0")]
262-
__Nonexhaustive,
263260
}
264261

265262
/// An [`AtomicBool`] initialized to `false`.
@@ -1954,7 +1951,6 @@ fn strongest_failure_ordering(order: Ordering) -> Ordering {
19541951
SeqCst => SeqCst,
19551952
Acquire => Acquire,
19561953
AcqRel => Acquire,
1957-
__Nonexhaustive => __Nonexhaustive,
19581954
}
19591955
}
19601956

@@ -1966,7 +1962,6 @@ unsafe fn atomic_store<T>(dst: *mut T, val: T, order: Ordering) {
19661962
SeqCst => intrinsics::atomic_store(dst, val),
19671963
Acquire => panic!("there is no such thing as an acquire store"),
19681964
AcqRel => panic!("there is no such thing as an acquire/release store"),
1969-
__Nonexhaustive => panic!("invalid memory ordering"),
19701965
}
19711966
}
19721967

@@ -1978,7 +1973,6 @@ unsafe fn atomic_load<T>(dst: *const T, order: Ordering) -> T {
19781973
SeqCst => intrinsics::atomic_load(dst),
19791974
Release => panic!("there is no such thing as a release load"),
19801975
AcqRel => panic!("there is no such thing as an acquire/release load"),
1981-
__Nonexhaustive => panic!("invalid memory ordering"),
19821976
}
19831977
}
19841978

@@ -1991,7 +1985,6 @@ unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
19911985
AcqRel => intrinsics::atomic_xchg_acqrel(dst, val),
19921986
Relaxed => intrinsics::atomic_xchg_relaxed(dst, val),
19931987
SeqCst => intrinsics::atomic_xchg(dst, val),
1994-
__Nonexhaustive => panic!("invalid memory ordering"),
19951988
}
19961989
}
19971990

@@ -2004,7 +1997,6 @@ unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
20041997
AcqRel => intrinsics::atomic_xadd_acqrel(dst, val),
20051998
Relaxed => intrinsics::atomic_xadd_relaxed(dst, val),
20061999
SeqCst => intrinsics::atomic_xadd(dst, val),
2007-
__Nonexhaustive => panic!("invalid memory ordering"),
20082000
}
20092001
}
20102002

@@ -2017,7 +2009,6 @@ unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
20172009
AcqRel => intrinsics::atomic_xsub_acqrel(dst, val),
20182010
Relaxed => intrinsics::atomic_xsub_relaxed(dst, val),
20192011
SeqCst => intrinsics::atomic_xsub(dst, val),
2020-
__Nonexhaustive => panic!("invalid memory ordering"),
20212012
}
20222013
}
20232014

@@ -2039,8 +2030,6 @@ unsafe fn atomic_compare_exchange<T>(dst: *mut T,
20392030
(AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_failrelaxed(dst, old, new),
20402031
(SeqCst, Relaxed) => intrinsics::atomic_cxchg_failrelaxed(dst, old, new),
20412032
(SeqCst, Acquire) => intrinsics::atomic_cxchg_failacq(dst, old, new),
2042-
(__Nonexhaustive, _) => panic!("invalid memory ordering"),
2043-
(_, __Nonexhaustive) => panic!("invalid memory ordering"),
20442033
(_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"),
20452034
(_, Release) => panic!("there is no such thing as a release failure ordering"),
20462035
_ => 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,
20652054
(AcqRel, Relaxed) => intrinsics::atomic_cxchgweak_acqrel_failrelaxed(dst, old, new),
20662055
(SeqCst, Relaxed) => intrinsics::atomic_cxchgweak_failrelaxed(dst, old, new),
20672056
(SeqCst, Acquire) => intrinsics::atomic_cxchgweak_failacq(dst, old, new),
2068-
(__Nonexhaustive, _) => panic!("invalid memory ordering"),
2069-
(_, __Nonexhaustive) => panic!("invalid memory ordering"),
20702057
(_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"),
20712058
(_, Release) => panic!("there is no such thing as a release failure ordering"),
20722059
_ => 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 {
20822069
AcqRel => intrinsics::atomic_and_acqrel(dst, val),
20832070
Relaxed => intrinsics::atomic_and_relaxed(dst, val),
20842071
SeqCst => intrinsics::atomic_and(dst, val),
2085-
__Nonexhaustive => panic!("invalid memory ordering"),
20862072
}
20872073
}
20882074

@@ -2094,7 +2080,6 @@ unsafe fn atomic_nand<T>(dst: *mut T, val: T, order: Ordering) -> T {
20942080
AcqRel => intrinsics::atomic_nand_acqrel(dst, val),
20952081
Relaxed => intrinsics::atomic_nand_relaxed(dst, val),
20962082
SeqCst => intrinsics::atomic_nand(dst, val),
2097-
__Nonexhaustive => panic!("invalid memory ordering"),
20982083
}
20992084
}
21002085

@@ -2106,7 +2091,6 @@ unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
21062091
AcqRel => intrinsics::atomic_or_acqrel(dst, val),
21072092
Relaxed => intrinsics::atomic_or_relaxed(dst, val),
21082093
SeqCst => intrinsics::atomic_or(dst, val),
2109-
__Nonexhaustive => panic!("invalid memory ordering"),
21102094
}
21112095
}
21122096

@@ -2118,7 +2102,6 @@ unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
21182102
AcqRel => intrinsics::atomic_xor_acqrel(dst, val),
21192103
Relaxed => intrinsics::atomic_xor_relaxed(dst, val),
21202104
SeqCst => intrinsics::atomic_xor(dst, val),
2121-
__Nonexhaustive => panic!("invalid memory ordering"),
21222105
}
21232106
}
21242107

@@ -2131,7 +2114,6 @@ unsafe fn atomic_max<T>(dst: *mut T, val: T, order: Ordering) -> T {
21312114
AcqRel => intrinsics::atomic_max_acqrel(dst, val),
21322115
Relaxed => intrinsics::atomic_max_relaxed(dst, val),
21332116
SeqCst => intrinsics::atomic_max(dst, val),
2134-
__Nonexhaustive => panic!("invalid memory ordering"),
21352117
}
21362118
}
21372119

@@ -2144,7 +2126,6 @@ unsafe fn atomic_min<T>(dst: *mut T, val: T, order: Ordering) -> T {
21442126
AcqRel => intrinsics::atomic_min_acqrel(dst, val),
21452127
Relaxed => intrinsics::atomic_min_relaxed(dst, val),
21462128
SeqCst => intrinsics::atomic_min(dst, val),
2147-
__Nonexhaustive => panic!("invalid memory ordering"),
21482129
}
21492130
}
21502131

@@ -2157,7 +2138,6 @@ unsafe fn atomic_umax<T>(dst: *mut T, val: T, order: Ordering) -> T {
21572138
AcqRel => intrinsics::atomic_umax_acqrel(dst, val),
21582139
Relaxed => intrinsics::atomic_umax_relaxed(dst, val),
21592140
SeqCst => intrinsics::atomic_umax(dst, val),
2160-
__Nonexhaustive => panic!("invalid memory ordering"),
21612141
}
21622142
}
21632143

@@ -2170,7 +2150,6 @@ unsafe fn atomic_umin<T>(dst: *mut T, val: T, order: Ordering) -> T {
21702150
AcqRel => intrinsics::atomic_umin_acqrel(dst, val),
21712151
Relaxed => intrinsics::atomic_umin_relaxed(dst, val),
21722152
SeqCst => intrinsics::atomic_umin(dst, val),
2173-
__Nonexhaustive => panic!("invalid memory ordering"),
21742153
}
21752154
}
21762155

@@ -2260,7 +2239,6 @@ pub fn fence(order: Ordering) {
22602239
AcqRel => intrinsics::atomic_fence_acqrel(),
22612240
SeqCst => intrinsics::atomic_fence(),
22622241
Relaxed => panic!("there is no such thing as a relaxed fence"),
2263-
__Nonexhaustive => panic!("invalid memory ordering"),
22642242
}
22652243
}
22662244
}
@@ -2350,7 +2328,6 @@ pub fn compiler_fence(order: Ordering) {
23502328
AcqRel => intrinsics::atomic_singlethreadfence_acqrel(),
23512329
SeqCst => intrinsics::atomic_singlethreadfence(),
23522330
Relaxed => panic!("there is no such thing as a relaxed compiler fence"),
2353-
__Nonexhaustive => panic!("invalid memory ordering"),
23542331
}
23552332
}
23562333
}

0 commit comments

Comments
 (0)