@@ -22,18 +22,27 @@ declare_clippy_lint! {
2222 ///
2323 /// let x = AtomicU8::new(0);
2424 ///
25+ /// // Bad: `Release` and `AcqRel` cannot be used for `load`.
2526 /// let _ = x.load(Ordering::Release);
2627 /// let _ = x.load(Ordering::AcqRel);
2728 ///
29+ /// // Bad: `Acquire` and `AcqRel` cannot be used for `store`.
2830 /// x.store(1, Ordering::Acquire);
2931 /// x.store(2, Ordering::AcqRel);
3032 ///
33+ /// // Bad: `Relaxed` cannot be used as a fence's ordering.
3134 /// atomic::fence(Ordering::Relaxed);
3235 /// atomic::compiler_fence(Ordering::Relaxed);
3336 ///
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));
3746 /// ```
3847 pub INVALID_ATOMIC_ORDERING ,
3948 correctness,
0 commit comments