Skip to content

Commit 22d4a4f

Browse files
committed
Auto merge of #117757 - flip1995:clippy-beta-backport, r=cuviper
[beta] Clippy beta backport Follow-up to the stable backport done in - #116364: d3f6573 r? `@Mark-Simulacrum`
2 parents fbf0758 + a46e1c9 commit 22d4a4f

15 files changed

+72
-140
lines changed

src/tools/clippy/clippy_lints/src/needless_pass_by_ref_mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ declare_clippy_lint! {
4949
/// ```
5050
#[clippy::version = "1.72.0"]
5151
pub NEEDLESS_PASS_BY_REF_MUT,
52-
suspicious,
52+
nursery,
5353
"using a `&mut` argument when it's not mutated"
5454
}
5555

src/tools/clippy/tests/ui/infinite_loop.rs

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ fn fn_constref(i: &i32) -> i32 {
77
unimplemented!()
88
}
99
fn fn_mutref(i: &mut i32) {
10-
//~^ ERROR: this argument is a mutable reference, but not used mutably
11-
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
1210
unimplemented!()
1311
}
1412
fn fooi() -> i32 {
+12-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: variables in the condition are not mutated in the loop body
2-
--> $DIR/infinite_loop.rs:24:11
2+
--> $DIR/infinite_loop.rs:22:11
33
|
44
LL | while y < 10 {
55
| ^^^^^^
@@ -8,71 +8,71 @@ LL | while y < 10 {
88
= note: `#[deny(clippy::while_immutable_condition)]` on by default
99

1010
error: variables in the condition are not mutated in the loop body
11-
--> $DIR/infinite_loop.rs:31:11
11+
--> $DIR/infinite_loop.rs:29:11
1212
|
1313
LL | while y < 10 && x < 3 {
1414
| ^^^^^^^^^^^^^^^
1515
|
1616
= note: this may lead to an infinite or to a never running loop
1717

1818
error: variables in the condition are not mutated in the loop body
19-
--> $DIR/infinite_loop.rs:40:11
19+
--> $DIR/infinite_loop.rs:38:11
2020
|
2121
LL | while !cond {
2222
| ^^^^^
2323
|
2424
= note: this may lead to an infinite or to a never running loop
2525

2626
error: variables in the condition are not mutated in the loop body
27-
--> $DIR/infinite_loop.rs:86:11
27+
--> $DIR/infinite_loop.rs:84:11
2828
|
2929
LL | while i < 3 {
3030
| ^^^^^
3131
|
3232
= note: this may lead to an infinite or to a never running loop
3333

3434
error: variables in the condition are not mutated in the loop body
35-
--> $DIR/infinite_loop.rs:93:11
35+
--> $DIR/infinite_loop.rs:91:11
3636
|
3737
LL | while i < 3 && j > 0 {
3838
| ^^^^^^^^^^^^^^
3939
|
4040
= note: this may lead to an infinite or to a never running loop
4141

4242
error: variables in the condition are not mutated in the loop body
43-
--> $DIR/infinite_loop.rs:99:11
43+
--> $DIR/infinite_loop.rs:97:11
4444
|
4545
LL | while i < 3 {
4646
| ^^^^^
4747
|
4848
= note: this may lead to an infinite or to a never running loop
4949

5050
error: variables in the condition are not mutated in the loop body
51-
--> $DIR/infinite_loop.rs:116:11
51+
--> $DIR/infinite_loop.rs:114:11
5252
|
5353
LL | while i < 3 {
5454
| ^^^^^
5555
|
5656
= note: this may lead to an infinite or to a never running loop
5757

5858
error: variables in the condition are not mutated in the loop body
59-
--> $DIR/infinite_loop.rs:123:11
59+
--> $DIR/infinite_loop.rs:121:11
6060
|
6161
LL | while i < 3 {
6262
| ^^^^^
6363
|
6464
= note: this may lead to an infinite or to a never running loop
6565

6666
error: variables in the condition are not mutated in the loop body
67-
--> $DIR/infinite_loop.rs:191:15
67+
--> $DIR/infinite_loop.rs:189:15
6868
|
6969
LL | while self.count < n {
7070
| ^^^^^^^^^^^^^^
7171
|
7272
= note: this may lead to an infinite or to a never running loop
7373

7474
error: variables in the condition are not mutated in the loop body
75-
--> $DIR/infinite_loop.rs:201:11
75+
--> $DIR/infinite_loop.rs:199:11
7676
|
7777
LL | while y < 10 {
7878
| ^^^^^^
@@ -82,7 +82,7 @@ LL | while y < 10 {
8282
= help: rewrite it as `if cond { loop { } }`
8383

8484
error: variables in the condition are not mutated in the loop body
85-
--> $DIR/infinite_loop.rs:210:11
85+
--> $DIR/infinite_loop.rs:208:11
8686
|
8787
LL | while y < 10 {
8888
| ^^^^^^
@@ -91,14 +91,5 @@ LL | while y < 10 {
9191
= note: this loop contains `return`s or `break`s
9292
= help: rewrite it as `if cond { loop { } }`
9393

94-
error: this argument is a mutable reference, but not used mutably
95-
--> $DIR/infinite_loop.rs:9:17
96-
|
97-
LL | fn fn_mutref(i: &mut i32) {
98-
| ^^^^^^^^ help: consider changing to: `&i32`
99-
|
100-
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
101-
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
102-
103-
error: aborting due to 12 previous errors
94+
error: aborting due to 11 previous errors
10495

src/tools/clippy/tests/ui/let_underscore_future.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ fn custom() -> impl Future<Output = ()> {
99
}
1010

1111
fn do_something_to_future(future: &mut impl Future<Output = ()>) {}
12-
//~^ ERROR: this argument is a mutable reference, but not used mutably
13-
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
1412

1513
fn main() {
1614
let _ = some_async_fn();
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: non-binding `let` on a future
2-
--> $DIR/let_underscore_future.rs:16:5
2+
--> $DIR/let_underscore_future.rs:14:5
33
|
44
LL | let _ = some_async_fn();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -9,29 +9,20 @@ LL | let _ = some_async_fn();
99
= help: to override `-D warnings` add `#[allow(clippy::let_underscore_future)]`
1010

1111
error: non-binding `let` on a future
12-
--> $DIR/let_underscore_future.rs:18:5
12+
--> $DIR/let_underscore_future.rs:16:5
1313
|
1414
LL | let _ = custom();
1515
| ^^^^^^^^^^^^^^^^^
1616
|
1717
= help: consider awaiting the future or dropping explicitly with `std::mem::drop`
1818

1919
error: non-binding `let` on a future
20-
--> $DIR/let_underscore_future.rs:23:5
20+
--> $DIR/let_underscore_future.rs:21:5
2121
|
2222
LL | let _ = future;
2323
| ^^^^^^^^^^^^^^^
2424
|
2525
= help: consider awaiting the future or dropping explicitly with `std::mem::drop`
2626

27-
error: this argument is a mutable reference, but not used mutably
28-
--> $DIR/let_underscore_future.rs:11:35
29-
|
30-
LL | fn do_something_to_future(future: &mut impl Future<Output = ()>) {}
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&impl Future<Output = ()>`
32-
|
33-
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
34-
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
35-
36-
error: aborting due to 4 previous errors
27+
error: aborting due to 3 previous errors
3728

src/tools/clippy/tests/ui/mut_key.rs

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> HashSet<K
3232
//~^ ERROR: mutable key type
3333
//~| NOTE: `-D clippy::mutable-key-type` implied by `-D warnings`
3434
//~| ERROR: mutable key type
35-
//~| ERROR: this argument is a mutable reference, but not used mutably
36-
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
3735
let _other: HashMap<Key, bool> = HashMap::new();
3836
//~^ ERROR: mutable key type
3937
m.keys().cloned().collect()

src/tools/clippy/tests/ui/mut_key.stderr

+16-25
Original file line numberDiff line numberDiff line change
@@ -14,103 +14,94 @@ LL | fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> Hash
1414
| ^^^^^^^^^^^^
1515

1616
error: mutable key type
17-
--> $DIR/mut_key.rs:37:5
17+
--> $DIR/mut_key.rs:35:5
1818
|
1919
LL | let _other: HashMap<Key, bool> = HashMap::new();
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2121

2222
error: mutable key type
23-
--> $DIR/mut_key.rs:65:22
23+
--> $DIR/mut_key.rs:63:22
2424
|
2525
LL | fn tuples_bad<U>(_m: &mut HashMap<(Key, U), bool>) {}
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2727

2828
error: mutable key type
29-
--> $DIR/mut_key.rs:78:5
29+
--> $DIR/mut_key.rs:76:5
3030
|
3131
LL | let _map = HashMap::<Cell<usize>, usize>::new();
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3333

3434
error: mutable key type
35-
--> $DIR/mut_key.rs:80:5
35+
--> $DIR/mut_key.rs:78:5
3636
|
3737
LL | let _map = HashMap::<&mut Cell<usize>, usize>::new();
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3939

4040
error: mutable key type
41-
--> $DIR/mut_key.rs:82:5
41+
--> $DIR/mut_key.rs:80:5
4242
|
4343
LL | let _map = HashMap::<&mut usize, usize>::new();
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545

4646
error: mutable key type
47-
--> $DIR/mut_key.rs:85:5
47+
--> $DIR/mut_key.rs:83:5
4848
|
4949
LL | let _map = HashMap::<Vec<Cell<usize>>, usize>::new();
5050
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5151

5252
error: mutable key type
53-
--> $DIR/mut_key.rs:87:5
53+
--> $DIR/mut_key.rs:85:5
5454
|
5555
LL | let _map = HashMap::<BTreeMap<Cell<usize>, ()>, usize>::new();
5656
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5757

5858
error: mutable key type
59-
--> $DIR/mut_key.rs:89:5
59+
--> $DIR/mut_key.rs:87:5
6060
|
6161
LL | let _map = HashMap::<BTreeMap<(), Cell<usize>>, usize>::new();
6262
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6363

6464
error: mutable key type
65-
--> $DIR/mut_key.rs:91:5
65+
--> $DIR/mut_key.rs:89:5
6666
|
6767
LL | let _map = HashMap::<BTreeSet<Cell<usize>>, usize>::new();
6868
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6969

7070
error: mutable key type
71-
--> $DIR/mut_key.rs:93:5
71+
--> $DIR/mut_key.rs:91:5
7272
|
7373
LL | let _map = HashMap::<Option<Cell<usize>>, usize>::new();
7474
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7575

7676
error: mutable key type
77-
--> $DIR/mut_key.rs:95:5
77+
--> $DIR/mut_key.rs:93:5
7878
|
7979
LL | let _map = HashMap::<Option<Vec<Cell<usize>>>, usize>::new();
8080
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8181

8282
error: mutable key type
83-
--> $DIR/mut_key.rs:97:5
83+
--> $DIR/mut_key.rs:95:5
8484
|
8585
LL | let _map = HashMap::<Result<&mut usize, ()>, usize>::new();
8686
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8787

8888
error: mutable key type
89-
--> $DIR/mut_key.rs:100:5
89+
--> $DIR/mut_key.rs:98:5
9090
|
9191
LL | let _map = HashMap::<Box<Cell<usize>>, usize>::new();
9292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9393

9494
error: mutable key type
95-
--> $DIR/mut_key.rs:102:5
95+
--> $DIR/mut_key.rs:100:5
9696
|
9797
LL | let _map = HashMap::<Rc<Cell<usize>>, usize>::new();
9898
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9999

100100
error: mutable key type
101-
--> $DIR/mut_key.rs:104:5
101+
--> $DIR/mut_key.rs:102:5
102102
|
103103
LL | let _map = HashMap::<Arc<Cell<usize>>, usize>::new();
104104
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105105

106-
error: this argument is a mutable reference, but not used mutably
107-
--> $DIR/mut_key.rs:31:32
108-
|
109-
LL | fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> HashSet<Key> {
110-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&HashMap<Key, usize>`
111-
|
112-
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
113-
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
114-
115-
error: aborting due to 18 previous errors
106+
error: aborting due to 17 previous errors
116107

src/tools/clippy/tests/ui/mut_reference.rs

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ impl MyStruct {
2222
fn takes_an_immutable_reference(&self, a: &i32) {}
2323

2424
fn takes_a_mutable_reference(&self, a: &mut i32) {}
25-
//~^ ERROR: this argument is a mutable reference, but not used mutably
26-
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
2725
}
2826

2927
#[warn(clippy::unnecessary_mut_passed)]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the function `takes_an_immutable_reference` doesn't need a mutable reference
2-
--> $DIR/mut_reference.rs:32:34
2+
--> $DIR/mut_reference.rs:30:34
33
|
44
LL | takes_an_immutable_reference(&mut 42);
55
| ^^^^^^^
@@ -8,25 +8,16 @@ LL | takes_an_immutable_reference(&mut 42);
88
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_mut_passed)]`
99

1010
error: the function `as_ptr` doesn't need a mutable reference
11-
--> $DIR/mut_reference.rs:36:12
11+
--> $DIR/mut_reference.rs:34:12
1212
|
1313
LL | as_ptr(&mut 42);
1414
| ^^^^^^^
1515

1616
error: the method `takes_an_immutable_reference` doesn't need a mutable reference
17-
--> $DIR/mut_reference.rs:41:44
17+
--> $DIR/mut_reference.rs:39:44
1818
|
1919
LL | my_struct.takes_an_immutable_reference(&mut 42);
2020
| ^^^^^^^
2121

22-
error: this argument is a mutable reference, but not used mutably
23-
--> $DIR/mut_reference.rs:24:44
24-
|
25-
LL | fn takes_a_mutable_reference(&self, a: &mut i32) {}
26-
| ^^^^^^^^ help: consider changing to: `&i32`
27-
|
28-
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
29-
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
30-
31-
error: aborting due to 4 previous errors
22+
error: aborting due to 3 previous errors
3223

src/tools/clippy/tests/ui/needless_pass_by_ref_mut.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![allow(clippy::if_same_then_else, clippy::no_effect, clippy::redundant_closure_call)]
2+
#![warn(clippy::needless_pass_by_ref_mut)]
23
#![feature(lint_reasons)]
34
//@no-rustfix
45
use std::ptr::NonNull;

0 commit comments

Comments
 (0)