@@ -185,6 +185,7 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
185
185
/// [nomicon]: ../../../nomicon/atomics.html
186
186
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
187
187
#[ derive( Copy , Clone , Debug ) ]
188
+ #[ non_exhaustive]
188
189
pub enum Ordering {
189
190
/// No ordering constraints, only atomic operations.
190
191
///
@@ -256,10 +257,6 @@ pub enum Ordering {
256
257
/// [`AcqRel`]: https://llvm.org/docs/Atomics.html#acquirerelease
257
258
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
258
259
SeqCst ,
259
- // Prevent exhaustive matching to allow for future extension
260
- #[ doc( hidden) ]
261
- #[ unstable( feature = "future_atomic_orderings" , issue = "0" ) ]
262
- __Nonexhaustive,
263
260
}
264
261
265
262
/// An [`AtomicBool`] initialized to `false`.
@@ -1954,7 +1951,6 @@ fn strongest_failure_ordering(order: Ordering) -> Ordering {
1954
1951
SeqCst => SeqCst ,
1955
1952
Acquire => Acquire ,
1956
1953
AcqRel => Acquire ,
1957
- __Nonexhaustive => __Nonexhaustive,
1958
1954
}
1959
1955
}
1960
1956
@@ -1966,7 +1962,6 @@ unsafe fn atomic_store<T>(dst: *mut T, val: T, order: Ordering) {
1966
1962
SeqCst => intrinsics:: atomic_store ( dst, val) ,
1967
1963
Acquire => panic ! ( "there is no such thing as an acquire store" ) ,
1968
1964
AcqRel => panic ! ( "there is no such thing as an acquire/release store" ) ,
1969
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
1970
1965
}
1971
1966
}
1972
1967
@@ -1978,7 +1973,6 @@ unsafe fn atomic_load<T>(dst: *const T, order: Ordering) -> T {
1978
1973
SeqCst => intrinsics:: atomic_load ( dst) ,
1979
1974
Release => panic ! ( "there is no such thing as a release load" ) ,
1980
1975
AcqRel => panic ! ( "there is no such thing as an acquire/release load" ) ,
1981
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
1982
1976
}
1983
1977
}
1984
1978
@@ -1991,7 +1985,6 @@ unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
1991
1985
AcqRel => intrinsics:: atomic_xchg_acqrel ( dst, val) ,
1992
1986
Relaxed => intrinsics:: atomic_xchg_relaxed ( dst, val) ,
1993
1987
SeqCst => intrinsics:: atomic_xchg ( dst, val) ,
1994
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
1995
1988
}
1996
1989
}
1997
1990
@@ -2004,7 +1997,6 @@ unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
2004
1997
AcqRel => intrinsics:: atomic_xadd_acqrel ( dst, val) ,
2005
1998
Relaxed => intrinsics:: atomic_xadd_relaxed ( dst, val) ,
2006
1999
SeqCst => intrinsics:: atomic_xadd ( dst, val) ,
2007
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2008
2000
}
2009
2001
}
2010
2002
@@ -2017,7 +2009,6 @@ unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
2017
2009
AcqRel => intrinsics:: atomic_xsub_acqrel ( dst, val) ,
2018
2010
Relaxed => intrinsics:: atomic_xsub_relaxed ( dst, val) ,
2019
2011
SeqCst => intrinsics:: atomic_xsub ( dst, val) ,
2020
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2021
2012
}
2022
2013
}
2023
2014
@@ -2039,8 +2030,6 @@ unsafe fn atomic_compare_exchange<T>(dst: *mut T,
2039
2030
( AcqRel , Relaxed ) => intrinsics:: atomic_cxchg_acqrel_failrelaxed ( dst, old, new) ,
2040
2031
( SeqCst , Relaxed ) => intrinsics:: atomic_cxchg_failrelaxed ( dst, old, new) ,
2041
2032
( SeqCst , Acquire ) => intrinsics:: atomic_cxchg_failacq ( dst, old, new) ,
2042
- ( __Nonexhaustive, _) => panic ! ( "invalid memory ordering" ) ,
2043
- ( _, __Nonexhaustive) => panic ! ( "invalid memory ordering" ) ,
2044
2033
( _, AcqRel ) => panic ! ( "there is no such thing as an acquire/release failure ordering" ) ,
2045
2034
( _, Release ) => panic ! ( "there is no such thing as a release failure ordering" ) ,
2046
2035
_ => 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,
2065
2054
( AcqRel , Relaxed ) => intrinsics:: atomic_cxchgweak_acqrel_failrelaxed ( dst, old, new) ,
2066
2055
( SeqCst , Relaxed ) => intrinsics:: atomic_cxchgweak_failrelaxed ( dst, old, new) ,
2067
2056
( SeqCst , Acquire ) => intrinsics:: atomic_cxchgweak_failacq ( dst, old, new) ,
2068
- ( __Nonexhaustive, _) => panic ! ( "invalid memory ordering" ) ,
2069
- ( _, __Nonexhaustive) => panic ! ( "invalid memory ordering" ) ,
2070
2057
( _, AcqRel ) => panic ! ( "there is no such thing as an acquire/release failure ordering" ) ,
2071
2058
( _, Release ) => panic ! ( "there is no such thing as a release failure ordering" ) ,
2072
2059
_ => 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 {
2082
2069
AcqRel => intrinsics:: atomic_and_acqrel ( dst, val) ,
2083
2070
Relaxed => intrinsics:: atomic_and_relaxed ( dst, val) ,
2084
2071
SeqCst => intrinsics:: atomic_and ( dst, val) ,
2085
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2086
2072
}
2087
2073
}
2088
2074
@@ -2094,7 +2080,6 @@ unsafe fn atomic_nand<T>(dst: *mut T, val: T, order: Ordering) -> T {
2094
2080
AcqRel => intrinsics:: atomic_nand_acqrel ( dst, val) ,
2095
2081
Relaxed => intrinsics:: atomic_nand_relaxed ( dst, val) ,
2096
2082
SeqCst => intrinsics:: atomic_nand ( dst, val) ,
2097
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2098
2083
}
2099
2084
}
2100
2085
@@ -2106,7 +2091,6 @@ unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
2106
2091
AcqRel => intrinsics:: atomic_or_acqrel ( dst, val) ,
2107
2092
Relaxed => intrinsics:: atomic_or_relaxed ( dst, val) ,
2108
2093
SeqCst => intrinsics:: atomic_or ( dst, val) ,
2109
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2110
2094
}
2111
2095
}
2112
2096
@@ -2118,7 +2102,6 @@ unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
2118
2102
AcqRel => intrinsics:: atomic_xor_acqrel ( dst, val) ,
2119
2103
Relaxed => intrinsics:: atomic_xor_relaxed ( dst, val) ,
2120
2104
SeqCst => intrinsics:: atomic_xor ( dst, val) ,
2121
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2122
2105
}
2123
2106
}
2124
2107
@@ -2131,7 +2114,6 @@ unsafe fn atomic_max<T>(dst: *mut T, val: T, order: Ordering) -> T {
2131
2114
AcqRel => intrinsics:: atomic_max_acqrel ( dst, val) ,
2132
2115
Relaxed => intrinsics:: atomic_max_relaxed ( dst, val) ,
2133
2116
SeqCst => intrinsics:: atomic_max ( dst, val) ,
2134
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2135
2117
}
2136
2118
}
2137
2119
@@ -2144,7 +2126,6 @@ unsafe fn atomic_min<T>(dst: *mut T, val: T, order: Ordering) -> T {
2144
2126
AcqRel => intrinsics:: atomic_min_acqrel ( dst, val) ,
2145
2127
Relaxed => intrinsics:: atomic_min_relaxed ( dst, val) ,
2146
2128
SeqCst => intrinsics:: atomic_min ( dst, val) ,
2147
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2148
2129
}
2149
2130
}
2150
2131
@@ -2157,7 +2138,6 @@ unsafe fn atomic_umax<T>(dst: *mut T, val: T, order: Ordering) -> T {
2157
2138
AcqRel => intrinsics:: atomic_umax_acqrel ( dst, val) ,
2158
2139
Relaxed => intrinsics:: atomic_umax_relaxed ( dst, val) ,
2159
2140
SeqCst => intrinsics:: atomic_umax ( dst, val) ,
2160
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2161
2141
}
2162
2142
}
2163
2143
@@ -2170,7 +2150,6 @@ unsafe fn atomic_umin<T>(dst: *mut T, val: T, order: Ordering) -> T {
2170
2150
AcqRel => intrinsics:: atomic_umin_acqrel ( dst, val) ,
2171
2151
Relaxed => intrinsics:: atomic_umin_relaxed ( dst, val) ,
2172
2152
SeqCst => intrinsics:: atomic_umin ( dst, val) ,
2173
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2174
2153
}
2175
2154
}
2176
2155
@@ -2260,7 +2239,6 @@ pub fn fence(order: Ordering) {
2260
2239
AcqRel => intrinsics:: atomic_fence_acqrel ( ) ,
2261
2240
SeqCst => intrinsics:: atomic_fence ( ) ,
2262
2241
Relaxed => panic ! ( "there is no such thing as a relaxed fence" ) ,
2263
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2264
2242
}
2265
2243
}
2266
2244
}
@@ -2350,7 +2328,6 @@ pub fn compiler_fence(order: Ordering) {
2350
2328
AcqRel => intrinsics:: atomic_singlethreadfence_acqrel ( ) ,
2351
2329
SeqCst => intrinsics:: atomic_singlethreadfence ( ) ,
2352
2330
Relaxed => panic ! ( "there is no such thing as a relaxed compiler fence" ) ,
2353
- __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
2354
2331
}
2355
2332
}
2356
2333
}
0 commit comments