@@ -22,18 +22,27 @@ declare_clippy_lint! {
22
22
///
23
23
/// let x = AtomicU8::new(0);
24
24
///
25
+ /// // Bad: `Release` and `AcqRel` cannot be used for `load`.
25
26
/// let _ = x.load(Ordering::Release);
26
27
/// let _ = x.load(Ordering::AcqRel);
27
28
///
29
+ /// // Bad: `Acquire` and `AcqRel` cannot be used for `store`.
28
30
/// x.store(1, Ordering::Acquire);
29
31
/// x.store(2, Ordering::AcqRel);
30
32
///
33
+ /// // Bad: `Relaxed` cannot be used as a fence's ordering.
31
34
/// atomic::fence(Ordering::Relaxed);
32
35
/// atomic::compiler_fence(Ordering::Relaxed);
33
36
///
34
- /// let _ = x.compare_exchange(1, 2, Ordering::Relaxed, Ordering::SeqCst);
35
- /// let _ = x.compare_exchange_weak(2, 3, Ordering::SeqCst, Ordering::Release);
36
- /// let _ = x.fetch_update(Ordering::AcqRel, Ordering::AcqRel, |val| Some(val + val));
37
+ /// // Bad: `Release` and `AcqRel` are both always invalid
38
+ /// // for the failure ordering (the last arg).
39
+ /// let _ = x.compare_exchange(1, 2, Ordering::SeqCst, Ordering::Release);
40
+ /// let _ = x.compare_exchange_weak(2, 3, Ordering::AcqRel, Ordering::AcqRel);
41
+ ///
42
+ /// // Bad: The failure ordering is not allowed to be
43
+ /// // stronger than the success order, and `SeqCst` is
44
+ /// // stronger than `Relaxed`.
45
+ /// let _ = x.fetch_update(Ordering::Relaxed, Ordering::SeqCst, |val| Some(val + val));
37
46
/// ```
38
47
pub INVALID_ATOMIC_ORDERING ,
39
48
correctness,
0 commit comments