@@ -18,11 +18,14 @@ declare_clippy_lint! {
18
18
///
19
19
/// On the other hand, `Mutex`es are, in general, easier to
20
20
/// 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.
22
23
///
23
24
/// ### 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`.
26
29
///
27
30
/// ### Example
28
31
/// ```no_run
@@ -48,14 +51,23 @@ declare_clippy_lint! {
48
51
/// Checks for usage of `Mutex<X>` where `X` is an integral
49
52
/// type.
50
53
///
51
- /// ### Why is this bad ?
54
+ /// ### Why restrict this?
52
55
/// Using a mutex just to make access to a plain integer
53
56
/// sequential is
54
57
/// shooting flies with cannons. `std::sync::atomic::AtomicUsize` is leaner and faster.
55
58
///
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
+ ///
56
64
/// ### 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.
59
71
///
60
72
/// ### Example
61
73
/// ```no_run
@@ -70,7 +82,7 @@ declare_clippy_lint! {
70
82
/// ```
71
83
#[ clippy:: version = "pre 1.29.0" ]
72
84
pub MUTEX_INTEGER ,
73
- nursery ,
85
+ restriction ,
74
86
"using a mutex for an integer type"
75
87
}
76
88
@@ -108,7 +120,7 @@ fn get_atomic_name(ty: Ty<'_>) -> Option<&'static str> {
108
120
UintTy :: U32 => Some ( "AtomicU32" ) ,
109
121
UintTy :: U64 => Some ( "AtomicU64" ) ,
110
122
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
112
124
UintTy :: U128 => None ,
113
125
}
114
126
} ,
@@ -119,7 +131,7 @@ fn get_atomic_name(ty: Ty<'_>) -> Option<&'static str> {
119
131
IntTy :: I32 => Some ( "AtomicI32" ) ,
120
132
IntTy :: I64 => Some ( "AtomicI64" ) ,
121
133
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
123
135
IntTy :: I128 => None ,
124
136
}
125
137
} ,
0 commit comments