Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum authored and xobs committed Oct 3, 2023
1 parent 8828443 commit 2a02812
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ declare_clippy_lint! {
/// ```
#[clippy::version = "1.72.0"]
pub NEEDLESS_PASS_BY_REF_MUT,
suspicious,
nursery,
"using a `&mut` argument when it's not mutated"
}

Expand Down
10 changes: 1 addition & 9 deletions src/tools/clippy/tests/ui/infinite_loop.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,5 @@ LL | while y < 10 {
= note: this loop contains `return`s or `break`s
= help: rewrite it as `if cond { loop { } }`

error: this argument is a mutable reference, but not used mutably
--> $DIR/infinite_loop.rs:7: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`

error: aborting due to 12 previous errors
error: aborting due to 11 previous errors

10 changes: 1 addition & 9 deletions src/tools/clippy/tests/ui/let_underscore_future.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,5 @@ LL | let _ = future;
|
= help: consider awaiting the future or dropping explicitly with `std::mem::drop`

error: this argument is a mutable reference, but not used mutably
--> $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`

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

10 changes: 1 addition & 9 deletions src/tools/clippy/tests/ui/mut_key.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,5 @@ error: mutable key type
LL | let _map = HashMap::<Arc<Cell<usize>>, usize>::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this argument is a mutable reference, but not used mutably
--> $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`

error: aborting due to 18 previous errors
error: aborting due to 17 previous errors

10 changes: 1 addition & 9 deletions src/tools/clippy/tests/ui/mut_reference.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,5 @@ error: the method `takes_an_immutable_reference` doesn't need a mutable referenc
LL | my_struct.takes_an_immutable_reference(&mut 42);
| ^^^^^^^

error: this argument is a mutable reference, but not used mutably
--> $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`

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

4 changes: 4 additions & 0 deletions src/tools/clippy/tests/ui/needless_pass_by_ref_mut.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#![allow(clippy::if_same_then_else, clippy::no_effect)]
#![feature(lint_reasons)]

// just ignore everywhere for now
//@ignore-32bit
//@ignore-64bit

use std::ptr::NonNull;

fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
Expand Down
11 changes: 1 addition & 10 deletions src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,5 @@ LL | | }
|
= 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
--> $DIR/method_list_2.rs:38: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`

error: aborting due to 16 previous errors
error: aborting due to 15 previous errors

10 changes: 1 addition & 9 deletions src/tools/clippy/tests/ui/slow_vector_initialization.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,5 @@ LL | vec1 = Vec::new();
LL | vec1.resize(10, 0);
| ^^^^^^^^^^^^^^^^^^

error: this argument is a mutable reference, but not used mutably
--> $DIR/slow_vector_initialization.rs:78: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`

error: aborting due to 13 previous errors
error: aborting due to 12 previous errors

0 comments on commit 2a02812

Please sign in to comment.