From 86a5cec050b617eb2ef53d3b803a192d4fe93f0d Mon Sep 17 00:00:00 2001 From: takashiidobe <idobetakashi@gmail.com> Date: Tue, 31 May 2022 11:33:54 -0500 Subject: [PATCH 1/2] remove panics for atomic load and stores --- library/core/src/sync/atomic.rs | 36 +++++++++------------------------ 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 43cfb1bb6407a..2f5e8bdd0a0fd 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -427,10 +427,6 @@ impl AtomicBool { /// `load` takes an [`Ordering`] argument which describes the memory ordering /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`]. /// - /// # Panics - /// - /// Panics if `order` is [`Release`] or [`AcqRel`]. - /// /// # Examples /// /// ``` @@ -453,10 +449,6 @@ impl AtomicBool { /// `store` takes an [`Ordering`] argument which describes the memory ordering /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`]. /// - /// # Panics - /// - /// Panics if `order` is [`Acquire`] or [`AcqRel`]. - /// /// # Examples /// /// ``` @@ -1109,10 +1101,6 @@ impl<T> AtomicPtr<T> { /// `load` takes an [`Ordering`] argument which describes the memory ordering /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`]. /// - /// # Panics - /// - /// Panics if `order` is [`Release`] or [`AcqRel`]. - /// /// # Examples /// /// ``` @@ -1135,10 +1123,6 @@ impl<T> AtomicPtr<T> { /// `store` takes an [`Ordering`] argument which describes the memory ordering /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`]. /// - /// # Panics - /// - /// Panics if `order` is [`Acquire`] or [`AcqRel`]. - /// /// # Examples /// /// ``` @@ -1692,10 +1676,6 @@ macro_rules! atomic_int { /// `load` takes an [`Ordering`] argument which describes the memory ordering of this operation. /// Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`]. /// - /// # Panics - /// - /// Panics if `order` is [`Release`] or [`AcqRel`]. - /// /// # Examples /// /// ``` @@ -1717,10 +1697,6 @@ macro_rules! atomic_int { /// `store` takes an [`Ordering`] argument which describes the memory ordering of this operation. /// Possible values are [`SeqCst`], [`Release`] and [`Relaxed`]. /// - /// # Panics - /// - /// Panics if `order` is [`Acquire`] or [`AcqRel`]. - /// /// # Examples /// /// ``` @@ -2664,7 +2640,11 @@ unsafe fn atomic_compare_exchange<T: Copy>( _ => panic!("a failure ordering can't be stronger than a success ordering"), } }; - if ok { Ok(val) } else { Err(val) } + if ok { + Ok(val) + } else { + Err(val) + } } #[inline] @@ -2693,7 +2673,11 @@ unsafe fn atomic_compare_exchange_weak<T: Copy>( _ => panic!("a failure ordering can't be stronger than a success ordering"), } }; - if ok { Ok(val) } else { Err(val) } + if ok { + Ok(val) + } else { + Err(val) + } } #[inline] From 35490c3f4bd583edba32183031043f75bea493a0 Mon Sep 17 00:00:00 2001 From: takashiidobe <idobetakashi@gmail.com> Date: Tue, 31 May 2022 12:32:53 -0500 Subject: [PATCH 2/2] remove formatting of if ok --- library/core/src/sync/atomic.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 2f5e8bdd0a0fd..257bf2fc156d9 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -2640,11 +2640,7 @@ unsafe fn atomic_compare_exchange<T: Copy>( _ => panic!("a failure ordering can't be stronger than a success ordering"), } }; - if ok { - Ok(val) - } else { - Err(val) - } + if ok { Ok(val) } else { Err(val) } } #[inline] @@ -2673,11 +2669,7 @@ unsafe fn atomic_compare_exchange_weak<T: Copy>( _ => panic!("a failure ordering can't be stronger than a success ordering"), } }; - if ok { - Ok(val) - } else { - Err(val) - } + if ok { Ok(val) } else { Err(val) } } #[inline]