Modify tests to account for the new allow-by-default needless_pass_by_ref_mut

This commit is contained in:
blyxyas 2023-10-02 20:14:43 +02:00
parent 3f0da4dda2
commit 07e63291ec
No known key found for this signature in database
GPG key ID: 11095C6C8A0C9137
14 changed files with 71 additions and 139 deletions

View file

@ -7,8 +7,6 @@ fn fn_constref(i: &i32) -> i32 {
unimplemented!() unimplemented!()
} }
fn fn_mutref(i: &mut i32) { fn fn_mutref(i: &mut i32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
unimplemented!() unimplemented!()
} }
fn fooi() -> i32 { fn fooi() -> i32 {

View file

@ -1,5 +1,5 @@
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:24:11 --> $DIR/infinite_loop.rs:22:11
| |
LL | while y < 10 { LL | while y < 10 {
| ^^^^^^ | ^^^^^^
@ -8,7 +8,7 @@ LL | while y < 10 {
= note: `#[deny(clippy::while_immutable_condition)]` on by default = note: `#[deny(clippy::while_immutable_condition)]` on by default
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:31:11 --> $DIR/infinite_loop.rs:29:11
| |
LL | while y < 10 && x < 3 { LL | while y < 10 && x < 3 {
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
@ -16,7 +16,7 @@ LL | while y < 10 && x < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:40:11 --> $DIR/infinite_loop.rs:38:11
| |
LL | while !cond { LL | while !cond {
| ^^^^^ | ^^^^^
@ -24,7 +24,7 @@ LL | while !cond {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:86:11 --> $DIR/infinite_loop.rs:84:11
| |
LL | while i < 3 { LL | while i < 3 {
| ^^^^^ | ^^^^^
@ -32,7 +32,7 @@ LL | while i < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:93:11 --> $DIR/infinite_loop.rs:91:11
| |
LL | while i < 3 && j > 0 { LL | while i < 3 && j > 0 {
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@ -40,7 +40,7 @@ LL | while i < 3 && j > 0 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:99:11 --> $DIR/infinite_loop.rs:97:11
| |
LL | while i < 3 { LL | while i < 3 {
| ^^^^^ | ^^^^^
@ -48,7 +48,7 @@ LL | while i < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:116:11 --> $DIR/infinite_loop.rs:114:11
| |
LL | while i < 3 { LL | while i < 3 {
| ^^^^^ | ^^^^^
@ -56,7 +56,7 @@ LL | while i < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:123:11 --> $DIR/infinite_loop.rs:121:11
| |
LL | while i < 3 { LL | while i < 3 {
| ^^^^^ | ^^^^^
@ -64,7 +64,7 @@ LL | while i < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:191:15 --> $DIR/infinite_loop.rs:189:15
| |
LL | while self.count < n { LL | while self.count < n {
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@ -72,7 +72,7 @@ LL | while self.count < n {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:201:11 --> $DIR/infinite_loop.rs:199:11
| |
LL | while y < 10 { LL | while y < 10 {
| ^^^^^^ | ^^^^^^
@ -82,7 +82,7 @@ LL | while y < 10 {
= help: rewrite it as `if cond { loop { } }` = help: rewrite it as `if cond { loop { } }`
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:210:11 --> $DIR/infinite_loop.rs:208:11
| |
LL | while y < 10 { LL | while y < 10 {
| ^^^^^^ | ^^^^^^
@ -91,14 +91,5 @@ LL | while y < 10 {
= note: this loop contains `return`s or `break`s = note: this loop contains `return`s or `break`s
= help: rewrite it as `if cond { loop { } }` = help: rewrite it as `if cond { loop { } }`
error: this argument is a mutable reference, but not used mutably error: aborting due to 11 previous errors
--> $DIR/infinite_loop.rs:9:17
|
LL | fn fn_mutref(i: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
|
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
error: aborting due to 12 previous errors

View file

@ -9,8 +9,6 @@ fn custom() -> impl Future<Output = ()> {
} }
fn do_something_to_future(future: &mut impl Future<Output = ()>) {} fn do_something_to_future(future: &mut impl Future<Output = ()>) {}
//~^ ERROR: this argument is a mutable reference, but not used mutably
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
fn main() { fn main() {
let _ = some_async_fn(); let _ = some_async_fn();

View file

@ -1,5 +1,5 @@
error: non-binding `let` on a future error: non-binding `let` on a future
--> $DIR/let_underscore_future.rs:16:5 --> $DIR/let_underscore_future.rs:14:5
| |
LL | let _ = some_async_fn(); LL | let _ = some_async_fn();
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
@ -9,7 +9,7 @@ LL | let _ = some_async_fn();
= help: to override `-D warnings` add `#[allow(clippy::let_underscore_future)]` = help: to override `-D warnings` add `#[allow(clippy::let_underscore_future)]`
error: non-binding `let` on a future error: non-binding `let` on a future
--> $DIR/let_underscore_future.rs:18:5 --> $DIR/let_underscore_future.rs:16:5
| |
LL | let _ = custom(); LL | let _ = custom();
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
@ -17,21 +17,12 @@ LL | let _ = custom();
= help: consider awaiting the future or dropping explicitly with `std::mem::drop` = help: consider awaiting the future or dropping explicitly with `std::mem::drop`
error: non-binding `let` on a future error: non-binding `let` on a future
--> $DIR/let_underscore_future.rs:23:5 --> $DIR/let_underscore_future.rs:21:5
| |
LL | let _ = future; LL | let _ = future;
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
| |
= help: consider awaiting the future or dropping explicitly with `std::mem::drop` = help: consider awaiting the future or dropping explicitly with `std::mem::drop`
error: this argument is a mutable reference, but not used mutably error: aborting due to 3 previous errors
--> $DIR/let_underscore_future.rs:11:35
|
LL | fn do_something_to_future(future: &mut impl Future<Output = ()>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&impl Future<Output = ()>`
|
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
error: aborting due to 4 previous errors

View file

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

View file

@ -14,103 +14,94 @@ LL | fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> Hash
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:37:5 --> $DIR/mut_key.rs:35:5
| |
LL | let _other: HashMap<Key, bool> = HashMap::new(); LL | let _other: HashMap<Key, bool> = HashMap::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:65:22 --> $DIR/mut_key.rs:63:22
| |
LL | fn tuples_bad<U>(_m: &mut HashMap<(Key, U), bool>) {} LL | fn tuples_bad<U>(_m: &mut HashMap<(Key, U), bool>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:78:5 --> $DIR/mut_key.rs:76:5
| |
LL | let _map = HashMap::<Cell<usize>, usize>::new(); LL | let _map = HashMap::<Cell<usize>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:80:5 --> $DIR/mut_key.rs:78:5
| |
LL | let _map = HashMap::<&mut Cell<usize>, usize>::new(); LL | let _map = HashMap::<&mut Cell<usize>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:82:5 --> $DIR/mut_key.rs:80:5
| |
LL | let _map = HashMap::<&mut usize, usize>::new(); LL | let _map = HashMap::<&mut usize, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:85:5 --> $DIR/mut_key.rs:83:5
| |
LL | let _map = HashMap::<Vec<Cell<usize>>, usize>::new(); LL | let _map = HashMap::<Vec<Cell<usize>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:87:5 --> $DIR/mut_key.rs:85:5
| |
LL | let _map = HashMap::<BTreeMap<Cell<usize>, ()>, usize>::new(); LL | let _map = HashMap::<BTreeMap<Cell<usize>, ()>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:89:5 --> $DIR/mut_key.rs:87:5
| |
LL | let _map = HashMap::<BTreeMap<(), Cell<usize>>, usize>::new(); LL | let _map = HashMap::<BTreeMap<(), Cell<usize>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:91:5 --> $DIR/mut_key.rs:89:5
| |
LL | let _map = HashMap::<BTreeSet<Cell<usize>>, usize>::new(); LL | let _map = HashMap::<BTreeSet<Cell<usize>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:93:5 --> $DIR/mut_key.rs:91:5
| |
LL | let _map = HashMap::<Option<Cell<usize>>, usize>::new(); LL | let _map = HashMap::<Option<Cell<usize>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:95:5 --> $DIR/mut_key.rs:93:5
| |
LL | let _map = HashMap::<Option<Vec<Cell<usize>>>, usize>::new(); LL | let _map = HashMap::<Option<Vec<Cell<usize>>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:97:5 --> $DIR/mut_key.rs:95:5
| |
LL | let _map = HashMap::<Result<&mut usize, ()>, usize>::new(); LL | let _map = HashMap::<Result<&mut usize, ()>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:100:5 --> $DIR/mut_key.rs:98:5
| |
LL | let _map = HashMap::<Box<Cell<usize>>, usize>::new(); LL | let _map = HashMap::<Box<Cell<usize>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:102:5 --> $DIR/mut_key.rs:100:5
| |
LL | let _map = HashMap::<Rc<Cell<usize>>, usize>::new(); LL | let _map = HashMap::<Rc<Cell<usize>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: mutable key type error: mutable key type
--> $DIR/mut_key.rs:104:5 --> $DIR/mut_key.rs:102:5
| |
LL | let _map = HashMap::<Arc<Cell<usize>>, usize>::new(); LL | let _map = HashMap::<Arc<Cell<usize>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this argument is a mutable reference, but not used mutably error: aborting due to 17 previous errors
--> $DIR/mut_key.rs:31:32
|
LL | fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> HashSet<Key> {
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&HashMap<Key, usize>`
|
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
error: aborting due to 18 previous errors

View file

@ -22,8 +22,6 @@ impl MyStruct {
fn takes_an_immutable_reference(&self, a: &i32) {} fn takes_an_immutable_reference(&self, a: &i32) {}
fn takes_a_mutable_reference(&self, a: &mut i32) {} fn takes_a_mutable_reference(&self, a: &mut i32) {}
//~^ ERROR: this argument is a mutable reference, but not used mutably
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
} }
#[warn(clippy::unnecessary_mut_passed)] #[warn(clippy::unnecessary_mut_passed)]

View file

@ -1,5 +1,5 @@
error: the function `takes_an_immutable_reference` doesn't need a mutable reference error: the function `takes_an_immutable_reference` doesn't need a mutable reference
--> $DIR/mut_reference.rs:32:34 --> $DIR/mut_reference.rs:30:34
| |
LL | takes_an_immutable_reference(&mut 42); LL | takes_an_immutable_reference(&mut 42);
| ^^^^^^^ | ^^^^^^^
@ -8,25 +8,16 @@ LL | takes_an_immutable_reference(&mut 42);
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_mut_passed)]` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_mut_passed)]`
error: the function `as_ptr` doesn't need a mutable reference error: the function `as_ptr` doesn't need a mutable reference
--> $DIR/mut_reference.rs:36:12 --> $DIR/mut_reference.rs:34:12
| |
LL | as_ptr(&mut 42); LL | as_ptr(&mut 42);
| ^^^^^^^ | ^^^^^^^
error: the method `takes_an_immutable_reference` doesn't need a mutable reference error: the method `takes_an_immutable_reference` doesn't need a mutable reference
--> $DIR/mut_reference.rs:41:44 --> $DIR/mut_reference.rs:39:44
| |
LL | my_struct.takes_an_immutable_reference(&mut 42); LL | my_struct.takes_an_immutable_reference(&mut 42);
| ^^^^^^^ | ^^^^^^^
error: this argument is a mutable reference, but not used mutably error: aborting due to 3 previous errors
--> $DIR/mut_reference.rs:24:44
|
LL | fn takes_a_mutable_reference(&self, a: &mut i32) {}
| ^^^^^^^^ help: consider changing to: `&i32`
|
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
error: aborting due to 4 previous errors

View file

@ -1,4 +1,5 @@
#![allow(clippy::if_same_then_else, clippy::no_effect, clippy::redundant_closure_call)] #![allow(clippy::if_same_then_else, clippy::no_effect, clippy::redundant_closure_call)]
#![warn(clippy::needless_pass_by_ref_mut)]
#![feature(lint_reasons)] #![feature(lint_reasons)]
//@no-rustfix //@no-rustfix
use std::ptr::NonNull; use std::ptr::NonNull;

View file

@ -1,5 +1,5 @@
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:6:11 --> $DIR/needless_pass_by_ref_mut.rs:7:11
| |
LL | fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) { LL | fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>` | ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
@ -8,79 +8,79 @@ LL | fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:31:12 --> $DIR/needless_pass_by_ref_mut.rs:32:12
| |
LL | fn foo6(s: &mut Vec<u32>) { LL | fn foo6(s: &mut Vec<u32>) {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>` | ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:44:29 --> $DIR/needless_pass_by_ref_mut.rs:45:29
| |
LL | fn mushroom(&self, vec: &mut Vec<i32>) -> usize { LL | fn mushroom(&self, vec: &mut Vec<i32>) -> usize {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>` | ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:49:31 --> $DIR/needless_pass_by_ref_mut.rs:50:31
| |
LL | fn badger(&mut self, vec: &mut Vec<i32>) -> usize { LL | fn badger(&mut self, vec: &mut Vec<i32>) -> usize {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>` | ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:126:16 --> $DIR/needless_pass_by_ref_mut.rs:127:16
| |
LL | async fn a1(x: &mut i32) { LL | async fn a1(x: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:130:16 --> $DIR/needless_pass_by_ref_mut.rs:131:16
| |
LL | async fn a2(x: &mut i32, y: String) { LL | async fn a2(x: &mut i32, y: String) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:134:16 --> $DIR/needless_pass_by_ref_mut.rs:135:16
| |
LL | async fn a3(x: &mut i32, y: String, z: String) { LL | async fn a3(x: &mut i32, y: String, z: String) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:138:16 --> $DIR/needless_pass_by_ref_mut.rs:139:16
| |
LL | async fn a4(x: &mut i32, y: i32) { LL | async fn a4(x: &mut i32, y: i32) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:142:24 --> $DIR/needless_pass_by_ref_mut.rs:143:24
| |
LL | async fn a5(x: i32, y: &mut i32) { LL | async fn a5(x: i32, y: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:146:24 --> $DIR/needless_pass_by_ref_mut.rs:147:24
| |
LL | async fn a6(x: i32, y: &mut i32) { LL | async fn a6(x: i32, y: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:150:32 --> $DIR/needless_pass_by_ref_mut.rs:151:32
| |
LL | async fn a7(x: i32, y: i32, z: &mut i32) { LL | async fn a7(x: i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:154:24 --> $DIR/needless_pass_by_ref_mut.rs:155:24
| |
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:154:45 --> $DIR/needless_pass_by_ref_mut.rs:155:45
| |
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:188:16 --> $DIR/needless_pass_by_ref_mut.rs:189:16
| |
LL | fn cfg_warn(s: &mut u32) {} LL | fn cfg_warn(s: &mut u32) {}
| ^^^^^^^^ help: consider changing to: `&u32` | ^^^^^^^^ help: consider changing to: `&u32`
@ -88,7 +88,7 @@ LL | fn cfg_warn(s: &mut u32) {}
= note: this is cfg-gated and may require further changes = note: this is cfg-gated and may require further changes
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:194:20 --> $DIR/needless_pass_by_ref_mut.rs:195:20
| |
LL | fn cfg_warn(s: &mut u32) {} LL | fn cfg_warn(s: &mut u32) {}
| ^^^^^^^^ help: consider changing to: `&u32` | ^^^^^^^^ help: consider changing to: `&u32`
@ -96,19 +96,19 @@ LL | fn cfg_warn(s: &mut u32) {}
= note: this is cfg-gated and may require further changes = note: this is cfg-gated and may require further changes
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:208:39 --> $DIR/needless_pass_by_ref_mut.rs:209:39
| |
LL | async fn inner_async2(x: &mut i32, y: &mut u32) { LL | async fn inner_async2(x: &mut i32, y: &mut u32) {
| ^^^^^^^^ help: consider changing to: `&u32` | ^^^^^^^^ help: consider changing to: `&u32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:216:26 --> $DIR/needless_pass_by_ref_mut.rs:217:26
| |
LL | async fn inner_async3(x: &mut i32, y: &mut u32) { LL | async fn inner_async3(x: &mut i32, y: &mut u32) {
| ^^^^^^^^ help: consider changing to: `&i32` | ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:235:34 --> $DIR/needless_pass_by_ref_mut.rs:236:34
| |
LL | pub async fn call_in_closure1(n: &mut str) { LL | pub async fn call_in_closure1(n: &mut str) {
| ^^^^^^^^ help: consider changing to: `&str` | ^^^^^^^^ help: consider changing to: `&str`
@ -116,7 +116,7 @@ LL | pub async fn call_in_closure1(n: &mut str) {
= warning: changing this function will impact semver compatibility = warning: changing this function will impact semver compatibility
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:247:25 --> $DIR/needless_pass_by_ref_mut.rs:248:25
| |
LL | pub async fn closure(n: &mut usize) -> impl '_ + FnMut() { LL | pub async fn closure(n: &mut usize) -> impl '_ + FnMut() {
| ^^^^^^^^^^ help: consider changing to: `&usize` | ^^^^^^^^^^ help: consider changing to: `&usize`
@ -124,7 +124,7 @@ LL | pub async fn closure(n: &mut usize) -> impl '_ + FnMut() {
= warning: changing this function will impact semver compatibility = warning: changing this function will impact semver compatibility
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:254:20 --> $DIR/needless_pass_by_ref_mut.rs:255:20
| |
LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize {
| ^^^^^^^^^^ help: consider changing to: `&usize` | ^^^^^^^^^^ help: consider changing to: `&usize`
@ -132,7 +132,7 @@ LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize {
= warning: changing this function will impact semver compatibility = warning: changing this function will impact semver compatibility
error: this argument is a mutable reference, but not used mutably error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:265:26 --> $DIR/needless_pass_by_ref_mut.rs:266:26
| |
LL | pub async fn closure4(n: &mut usize) { LL | pub async fn closure4(n: &mut usize) {
| ^^^^^^^^^^ help: consider changing to: `&usize` | ^^^^^^^^^^ help: consider changing to: `&usize`

View file

@ -40,8 +40,6 @@ impl T {
pub fn hash(&self, state: &mut T) { pub fn hash(&self, state: &mut T) {
//~^ ERROR: method `hash` can be confused for the standard trait method `std::hash::Ha //~^ ERROR: method `hash` can be confused for the standard trait method `std::hash::Ha
//~| ERROR: this argument is a mutable reference, but not used mutably
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
unimplemented!() unimplemented!()
} }

View file

@ -38,8 +38,6 @@ error: method `hash` can be confused for the standard trait method `std::hash::H
| |
LL | / pub fn hash(&self, state: &mut T) { LL | / pub fn hash(&self, state: &mut T) {
LL | | LL | |
LL | |
LL | |
LL | | unimplemented!() LL | | unimplemented!()
LL | | } LL | | }
| |_____^ | |_____^
@ -47,7 +45,7 @@ LL | | }
= help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name = help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name
error: method `index` can be confused for the standard trait method `std::ops::Index::index` error: method `index` can be confused for the standard trait method `std::ops::Index::index`
--> $DIR/method_list_2.rs:48:5 --> $DIR/method_list_2.rs:46:5
| |
LL | / pub fn index(&self, index: usize) -> &Self { LL | / pub fn index(&self, index: usize) -> &Self {
LL | | LL | |
@ -58,7 +56,7 @@ LL | | }
= help: consider implementing the trait `std::ops::Index` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::Index` or choosing a less ambiguous method name
error: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut` error: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut`
--> $DIR/method_list_2.rs:53:5 --> $DIR/method_list_2.rs:51:5
| |
LL | / pub fn index_mut(&mut self, index: usize) -> &mut Self { LL | / pub fn index_mut(&mut self, index: usize) -> &mut Self {
LL | | LL | |
@ -69,7 +67,7 @@ LL | | }
= help: consider implementing the trait `std::ops::IndexMut` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::IndexMut` or choosing a less ambiguous method name
error: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter` error: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter`
--> $DIR/method_list_2.rs:58:5 --> $DIR/method_list_2.rs:56:5
| |
LL | / pub fn into_iter(self) -> Self { LL | / pub fn into_iter(self) -> Self {
LL | | LL | |
@ -80,7 +78,7 @@ LL | | }
= help: consider implementing the trait `std::iter::IntoIterator` or choosing a less ambiguous method name = help: consider implementing the trait `std::iter::IntoIterator` or choosing a less ambiguous method name
error: method `mul` can be confused for the standard trait method `std::ops::Mul::mul` error: method `mul` can be confused for the standard trait method `std::ops::Mul::mul`
--> $DIR/method_list_2.rs:63:5 --> $DIR/method_list_2.rs:61:5
| |
LL | / pub fn mul(self, rhs: Self) -> Self { LL | / pub fn mul(self, rhs: Self) -> Self {
LL | | LL | |
@ -91,7 +89,7 @@ LL | | }
= help: consider implementing the trait `std::ops::Mul` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::Mul` or choosing a less ambiguous method name
error: method `neg` can be confused for the standard trait method `std::ops::Neg::neg` error: method `neg` can be confused for the standard trait method `std::ops::Neg::neg`
--> $DIR/method_list_2.rs:68:5 --> $DIR/method_list_2.rs:66:5
| |
LL | / pub fn neg(self) -> Self { LL | / pub fn neg(self) -> Self {
LL | | LL | |
@ -102,7 +100,7 @@ LL | | }
= help: consider implementing the trait `std::ops::Neg` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::Neg` or choosing a less ambiguous method name
error: method `next` can be confused for the standard trait method `std::iter::Iterator::next` error: method `next` can be confused for the standard trait method `std::iter::Iterator::next`
--> $DIR/method_list_2.rs:73:5 --> $DIR/method_list_2.rs:71:5
| |
LL | / pub fn next(&mut self) -> Option<Self> { LL | / pub fn next(&mut self) -> Option<Self> {
LL | | LL | |
@ -113,7 +111,7 @@ LL | | }
= help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name = help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name
error: method `not` can be confused for the standard trait method `std::ops::Not::not` error: method `not` can be confused for the standard trait method `std::ops::Not::not`
--> $DIR/method_list_2.rs:78:5 --> $DIR/method_list_2.rs:76:5
| |
LL | / pub fn not(self) -> Self { LL | / pub fn not(self) -> Self {
LL | | LL | |
@ -124,7 +122,7 @@ LL | | }
= help: consider implementing the trait `std::ops::Not` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::Not` or choosing a less ambiguous method name
error: method `rem` can be confused for the standard trait method `std::ops::Rem::rem` error: method `rem` can be confused for the standard trait method `std::ops::Rem::rem`
--> $DIR/method_list_2.rs:83:5 --> $DIR/method_list_2.rs:81:5
| |
LL | / pub fn rem(self, rhs: Self) -> Self { LL | / pub fn rem(self, rhs: Self) -> Self {
LL | | LL | |
@ -135,7 +133,7 @@ LL | | }
= help: consider implementing the trait `std::ops::Rem` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::Rem` or choosing a less ambiguous method name
error: method `shl` can be confused for the standard trait method `std::ops::Shl::shl` error: method `shl` can be confused for the standard trait method `std::ops::Shl::shl`
--> $DIR/method_list_2.rs:88:5 --> $DIR/method_list_2.rs:86:5
| |
LL | / pub fn shl(self, rhs: Self) -> Self { LL | / pub fn shl(self, rhs: Self) -> Self {
LL | | LL | |
@ -146,7 +144,7 @@ LL | | }
= help: consider implementing the trait `std::ops::Shl` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::Shl` or choosing a less ambiguous method name
error: method `shr` can be confused for the standard trait method `std::ops::Shr::shr` error: method `shr` can be confused for the standard trait method `std::ops::Shr::shr`
--> $DIR/method_list_2.rs:93:5 --> $DIR/method_list_2.rs:91:5
| |
LL | / pub fn shr(self, rhs: Self) -> Self { LL | / pub fn shr(self, rhs: Self) -> Self {
LL | | LL | |
@ -157,7 +155,7 @@ LL | | }
= help: consider implementing the trait `std::ops::Shr` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::Shr` or choosing a less ambiguous method name
error: method `sub` can be confused for the standard trait method `std::ops::Sub::sub` error: method `sub` can be confused for the standard trait method `std::ops::Sub::sub`
--> $DIR/method_list_2.rs:98:5 --> $DIR/method_list_2.rs:96:5
| |
LL | / pub fn sub(self, rhs: Self) -> Self { LL | / pub fn sub(self, rhs: Self) -> Self {
LL | | LL | |
@ -167,15 +165,5 @@ LL | | }
| |
= help: consider implementing the trait `std::ops::Sub` or choosing a less ambiguous method name = help: consider implementing the trait `std::ops::Sub` or choosing a less ambiguous method name
error: this argument is a mutable reference, but not used mutably error: aborting due to 15 previous errors
--> $DIR/method_list_2.rs:41:31
|
LL | pub fn hash(&self, state: &mut T) {
| ^^^^^^ help: consider changing to: `&T`
|
= warning: changing this function will impact semver compatibility
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
error: aborting due to 16 previous errors

View file

@ -103,8 +103,6 @@ fn from_empty_vec() {
} }
fn do_stuff(vec: &mut [u8]) {} fn do_stuff(vec: &mut [u8]) {}
//~^ ERROR: this argument is a mutable reference, but not used mutably
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
fn extend_vector_with_manipulations_between() { fn extend_vector_with_manipulations_between() {
let len = 300; let len = 300;

View file

@ -105,14 +105,5 @@ LL | vec1 = vec![];
LL | vec1.resize(10, 0); LL | vec1.resize(10, 0);
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: this argument is a mutable reference, but not used mutably error: aborting due to 13 previous errors
--> $DIR/slow_vector_initialization.rs:105:18
|
LL | fn do_stuff(vec: &mut [u8]) {}
| ^^^^^^^^^ help: consider changing to: `&[u8]`
|
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
error: aborting due to 14 previous errors