@@ -166,6 +166,10 @@ pub enum Ordering {
166166 /// sequentially consistent operations in the same order.
167167 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
168168 SeqCst ,
169+ // Prevent exhaustive matching to allow for future extension
170+ #[ doc( hidden) ]
171+ #[ unstable( feature = "future_atomic_orderings" , issue = "0" ) ]
172+ __Nonexhaustive,
169173}
170174
171175/// An `AtomicBool` initialized to `false`.
@@ -1277,6 +1281,7 @@ fn strongest_failure_ordering(order: Ordering) -> Ordering {
12771281 SeqCst => SeqCst ,
12781282 Acquire => Acquire ,
12791283 AcqRel => Acquire ,
1284+ __Nonexhaustive => __Nonexhaustive,
12801285 }
12811286}
12821287
@@ -1288,6 +1293,7 @@ unsafe fn atomic_store<T>(dst: *mut T, val: T, order: Ordering) {
12881293 SeqCst => intrinsics:: atomic_store ( dst, val) ,
12891294 Acquire => panic ! ( "there is no such thing as an acquire store" ) ,
12901295 AcqRel => panic ! ( "there is no such thing as an acquire/release store" ) ,
1296+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
12911297 }
12921298}
12931299
@@ -1299,6 +1305,7 @@ unsafe fn atomic_load<T>(dst: *const T, order: Ordering) -> T {
12991305 SeqCst => intrinsics:: atomic_load ( dst) ,
13001306 Release => panic ! ( "there is no such thing as a release load" ) ,
13011307 AcqRel => panic ! ( "there is no such thing as an acquire/release load" ) ,
1308+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
13021309 }
13031310}
13041311
@@ -1310,6 +1317,7 @@ unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
13101317 AcqRel => intrinsics:: atomic_xchg_acqrel ( dst, val) ,
13111318 Relaxed => intrinsics:: atomic_xchg_relaxed ( dst, val) ,
13121319 SeqCst => intrinsics:: atomic_xchg ( dst, val) ,
1320+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
13131321 }
13141322}
13151323
@@ -1322,6 +1330,7 @@ unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
13221330 AcqRel => intrinsics:: atomic_xadd_acqrel ( dst, val) ,
13231331 Relaxed => intrinsics:: atomic_xadd_relaxed ( dst, val) ,
13241332 SeqCst => intrinsics:: atomic_xadd ( dst, val) ,
1333+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
13251334 }
13261335}
13271336
@@ -1334,6 +1343,7 @@ unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
13341343 AcqRel => intrinsics:: atomic_xsub_acqrel ( dst, val) ,
13351344 Relaxed => intrinsics:: atomic_xsub_relaxed ( dst, val) ,
13361345 SeqCst => intrinsics:: atomic_xsub ( dst, val) ,
1346+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
13371347 }
13381348}
13391349
@@ -1354,6 +1364,8 @@ unsafe fn atomic_compare_exchange<T>(dst: *mut T,
13541364 ( AcqRel , Relaxed ) => intrinsics:: atomic_cxchg_acqrel_failrelaxed ( dst, old, new) ,
13551365 ( SeqCst , Relaxed ) => intrinsics:: atomic_cxchg_failrelaxed ( dst, old, new) ,
13561366 ( SeqCst , Acquire ) => intrinsics:: atomic_cxchg_failacq ( dst, old, new) ,
1367+ ( __Nonexhaustive, _) => panic ! ( "invalid memory ordering" ) ,
1368+ ( _, __Nonexhaustive) => panic ! ( "invalid memory ordering" ) ,
13571369 ( _, AcqRel ) => panic ! ( "there is no such thing as an acquire/release failure ordering" ) ,
13581370 ( _, Release ) => panic ! ( "there is no such thing as a release failure ordering" ) ,
13591371 _ => panic ! ( "a failure ordering can't be stronger than a success ordering" ) ,
@@ -1378,6 +1390,8 @@ unsafe fn atomic_compare_exchange_weak<T>(dst: *mut T,
13781390 ( AcqRel , Relaxed ) => intrinsics:: atomic_cxchgweak_acqrel_failrelaxed ( dst, old, new) ,
13791391 ( SeqCst , Relaxed ) => intrinsics:: atomic_cxchgweak_failrelaxed ( dst, old, new) ,
13801392 ( SeqCst , Acquire ) => intrinsics:: atomic_cxchgweak_failacq ( dst, old, new) ,
1393+ ( __Nonexhaustive, _) => panic ! ( "invalid memory ordering" ) ,
1394+ ( _, __Nonexhaustive) => panic ! ( "invalid memory ordering" ) ,
13811395 ( _, AcqRel ) => panic ! ( "there is no such thing as an acquire/release failure ordering" ) ,
13821396 ( _, Release ) => panic ! ( "there is no such thing as a release failure ordering" ) ,
13831397 _ => panic ! ( "a failure ordering can't be stronger than a success ordering" ) ,
@@ -1393,6 +1407,7 @@ unsafe fn atomic_and<T>(dst: *mut T, val: T, order: Ordering) -> T {
13931407 AcqRel => intrinsics:: atomic_and_acqrel ( dst, val) ,
13941408 Relaxed => intrinsics:: atomic_and_relaxed ( dst, val) ,
13951409 SeqCst => intrinsics:: atomic_and ( dst, val) ,
1410+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
13961411 }
13971412}
13981413
@@ -1404,6 +1419,7 @@ unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
14041419 AcqRel => intrinsics:: atomic_or_acqrel ( dst, val) ,
14051420 Relaxed => intrinsics:: atomic_or_relaxed ( dst, val) ,
14061421 SeqCst => intrinsics:: atomic_or ( dst, val) ,
1422+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
14071423 }
14081424}
14091425
@@ -1415,6 +1431,7 @@ unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
14151431 AcqRel => intrinsics:: atomic_xor_acqrel ( dst, val) ,
14161432 Relaxed => intrinsics:: atomic_xor_relaxed ( dst, val) ,
14171433 SeqCst => intrinsics:: atomic_xor ( dst, val) ,
1434+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
14181435 }
14191436}
14201437
@@ -1448,6 +1465,7 @@ pub fn fence(order: Ordering) {
14481465 AcqRel => intrinsics:: atomic_fence_acqrel ( ) ,
14491466 SeqCst => intrinsics:: atomic_fence ( ) ,
14501467 Relaxed => panic ! ( "there is no such thing as a relaxed fence" ) ,
1468+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
14511469 }
14521470 }
14531471}
0 commit comments