Skip to content

Commit fccf07b

Browse files
committed
Auto merge of #8260 - taiki-e:mutex_atomic, r=llogiq
Downgrade mutex_atomic to nursery See #1516 and #4295. There are suggestions about removing this lint from the default warned lints in both issues. Also, [`mutex_integer`](https://rust-lang.github.io/rust-clippy/master/index.html#mutex_integer) lint that has the same problems as this lint is in `nursery` group. changelog: Moved [`mutex_atomic`] to `nursery`
2 parents 51282fc + cf86cee commit fccf07b

6 files changed

+10
-10
lines changed

clippy_lints/src/lib.register_all.rs

-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
206206
LintId::of(mut_key::MUTABLE_KEY_TYPE),
207207
LintId::of(mut_mutex_lock::MUT_MUTEX_LOCK),
208208
LintId::of(mut_reference::UNNECESSARY_MUT_PASSED),
209-
LintId::of(mutex_atomic::MUTEX_ATOMIC),
210209
LintId::of(needless_arbitrary_self_type::NEEDLESS_ARBITRARY_SELF_TYPE),
211210
LintId::of(needless_bool::BOOL_COMPARISON),
212211
LintId::of(needless_bool::NEEDLESS_BOOL),

clippy_lints/src/lib.register_nursery.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
1515
LintId::of(let_if_seq::USELESS_LET_IF_SEQ),
1616
LintId::of(missing_const_for_fn::MISSING_CONST_FOR_FN),
1717
LintId::of(mutable_debug_assertion::DEBUG_ASSERT_WITH_MUT_CALL),
18+
LintId::of(mutex_atomic::MUTEX_ATOMIC),
1819
LintId::of(mutex_atomic::MUTEX_INTEGER),
1920
LintId::of(non_send_fields_in_send_ty::NON_SEND_FIELDS_IN_SEND_TY),
2021
LintId::of(nonstandard_macro_braces::NONSTANDARD_MACRO_BRACES),

clippy_lints/src/lib.register_perf.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ store.register_group(true, "clippy::perf", Some("clippy_perf"), vec![
1919
LintId::of(methods::SINGLE_CHAR_PATTERN),
2020
LintId::of(methods::UNNECESSARY_TO_OWNED),
2121
LintId::of(misc::CMP_OWNED),
22-
LintId::of(mutex_atomic::MUTEX_ATOMIC),
2322
LintId::of(redundant_clone::REDUNDANT_CLONE),
2423
LintId::of(slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
2524
LintId::of(stable_sort_primitive::STABLE_SORT_PRIMITIVE),

clippy_lints/src/mutex_atomic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare_clippy_lint! {
3838
/// ```
3939
#[clippy::version = "pre 1.29.0"]
4040
pub MUTEX_ATOMIC,
41-
perf,
41+
nursery,
4242
"using a mutex where an atomic value could be used instead"
4343
}
4444

tests/ui/mutex_atomic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![warn(clippy::all)]
22
#![warn(clippy::mutex_integer)]
3+
#![warn(clippy::mutex_atomic)]
34

45
fn main() {
56
use std::sync::Mutex;

tests/ui/mutex_atomic.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
error: consider using an `AtomicBool` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>`
2-
--> $DIR/mutex_atomic.rs:6:5
2+
--> $DIR/mutex_atomic.rs:7:5
33
|
44
LL | Mutex::new(true);
55
| ^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::mutex-atomic` implied by `-D warnings`
88

99
error: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>`
10-
--> $DIR/mutex_atomic.rs:7:5
10+
--> $DIR/mutex_atomic.rs:8:5
1111
|
1212
LL | Mutex::new(5usize);
1313
| ^^^^^^^^^^^^^^^^^^
1414

1515
error: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>`
16-
--> $DIR/mutex_atomic.rs:8:5
16+
--> $DIR/mutex_atomic.rs:9:5
1717
|
1818
LL | Mutex::new(9isize);
1919
| ^^^^^^^^^^^^^^^^^^
2020

2121
error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>`
22-
--> $DIR/mutex_atomic.rs:10:5
22+
--> $DIR/mutex_atomic.rs:11:5
2323
|
2424
LL | Mutex::new(&x as *const u32);
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626

2727
error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>`
28-
--> $DIR/mutex_atomic.rs:11:5
28+
--> $DIR/mutex_atomic.rs:12:5
2929
|
3030
LL | Mutex::new(&mut x as *mut u32);
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232

3333
error: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>`
34-
--> $DIR/mutex_atomic.rs:12:5
34+
--> $DIR/mutex_atomic.rs:13:5
3535
|
3636
LL | Mutex::new(0u32);
3737
| ^^^^^^^^^^^^^^^^
3838
|
3939
= note: `-D clippy::mutex-integer` implied by `-D warnings`
4040

4141
error: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>`
42-
--> $DIR/mutex_atomic.rs:13:5
42+
--> $DIR/mutex_atomic.rs:14:5
4343
|
4444
LL | Mutex::new(0i32);
4545
| ^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)