@@ -18,11 +18,14 @@ declare_clippy_lint! {
1818 ///
1919 /// On the other hand, `Mutex`es are, in general, easier to
2020 /// verify correctness. An atomic does not behave the same as
21- /// an equivalent mutex. See [this issue](https://github.com/rust-lang/rust-clippy/issues/4295)'s commentary for more details.
21+ /// an equivalent mutex. See [this issue](https://github.com/rust-lang/rust-clippy/issues/4295)'s
22+ /// commentary for more details.
2223 ///
2324 /// ### Known problems
24- /// This lint cannot detect if the mutex is actually used
25- /// for waiting before a critical section.
25+ /// * This lint cannot detect if the mutex is actually used
26+ /// for waiting before a critical section.
27+ /// * This lint has a false positive that warns without considering the case
28+ /// where `Mutex` is used together with `Condvar`.
2629 ///
2730 /// ### Example
2831 /// ```no_run
@@ -48,14 +51,23 @@ declare_clippy_lint! {
4851 /// Checks for usage of `Mutex<X>` where `X` is an integral
4952 /// type.
5053 ///
51- /// ### Why is this bad ?
54+ /// ### Why restrict this?
5255 /// Using a mutex just to make access to a plain integer
5356 /// sequential is
5457 /// shooting flies with cannons. `std::sync::atomic::AtomicUsize` is leaner and faster.
5558 ///
59+ /// On the other hand, `Mutex`es are, in general, easier to
60+ /// verify correctness. An atomic does not behave the same as
61+ /// an equivalent mutex. See [this issue](https://github.com/rust-lang/rust-clippy/issues/4295)'s
62+ /// commentary for more details.
63+ ///
5664 /// ### Known problems
57- /// This lint cannot detect if the mutex is actually used
58- /// for waiting before a critical section.
65+ /// * This lint cannot detect if the mutex is actually used
66+ /// for waiting before a critical section.
67+ /// * This lint has a false positive that warns without considering the case
68+ /// where `Mutex` is used together with `Condvar`.
69+ /// * This lint suggest using `AtomicU64` instead of `Mutex<u64>`, but
70+ /// `AtomicU64` is not available on some 32-bit platforms.
5971 ///
6072 /// ### Example
6173 /// ```no_run
@@ -70,7 +82,7 @@ declare_clippy_lint! {
7082 /// ```
7183 #[ clippy:: version = "pre 1.29.0" ]
7284 pub MUTEX_INTEGER ,
73- nursery ,
85+ restriction ,
7486 "using a mutex for an integer type"
7587}
7688
@@ -108,7 +120,7 @@ fn get_atomic_name(ty: Ty<'_>) -> Option<&'static str> {
108120 UintTy :: U32 => Some ( "AtomicU32" ) ,
109121 UintTy :: U64 => Some ( "AtomicU64" ) ,
110122 UintTy :: Usize => Some ( "AtomicUsize" ) ,
111- // There's no `AtomicU128`.
123+ // `AtomicU128` is unstable and only available on a few platforms: https://github.com/rust-lang/rust/issues/99069
112124 UintTy :: U128 => None ,
113125 }
114126 } ,
@@ -119,7 +131,7 @@ fn get_atomic_name(ty: Ty<'_>) -> Option<&'static str> {
119131 IntTy :: I32 => Some ( "AtomicI32" ) ,
120132 IntTy :: I64 => Some ( "AtomicI64" ) ,
121133 IntTy :: Isize => Some ( "AtomicIsize" ) ,
122- // There's no `AtomicI128`.
134+ // `AtomicU128` is unstable and only available on a few platforms: https://github.com/rust-lang/rust/issues/99069
123135 IntTy :: I128 => None ,
124136 }
125137 } ,
0 commit comments