Skip to content

Commit 3bd0481

Browse files
Update UI tests with new needless_pass_by_ref_mut lint
1 parent 83d8728 commit 3bd0481

26 files changed

+181
-93
lines changed

tests/ui-toml/toml_trivially_copy/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: N byte)"
33

44
#![deny(clippy::trivially_copy_pass_by_ref)]
5+
#![allow(clippy::needless_pass_by_ref_mut)]
56

67
#[derive(Copy, Clone)]
78
struct Foo(u8);

tests/ui-toml/toml_trivially_copy/test.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
2-
--> $DIR/test.rs:14:11
2+
--> $DIR/test.rs:15:11
33
|
44
LL | fn bad(x: &u16, y: &Foo) {}
55
| ^^^^ help: consider passing by value instead: `u16`
@@ -11,7 +11,7 @@ LL | #![deny(clippy::trivially_copy_pass_by_ref)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
14-
--> $DIR/test.rs:14:20
14+
--> $DIR/test.rs:15:20
1515
|
1616
LL | fn bad(x: &u16, y: &Foo) {}
1717
| ^^^^ help: consider passing by value instead: `Foo`

tests/ui/borrow_box.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#![deny(clippy::borrowed_box)]
22
#![allow(dead_code, unused_variables)]
3-
#![allow(clippy::uninlined_format_args, clippy::disallowed_names)]
3+
#![allow(
4+
clippy::uninlined_format_args,
5+
clippy::disallowed_names,
6+
clippy::needless_pass_by_ref_mut
7+
)]
48

59
use std::fmt::Display;
610

tests/ui/borrow_box.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
2-
--> $DIR/borrow_box.rs:20:14
2+
--> $DIR/borrow_box.rs:24:14
33
|
44
LL | let foo: &Box<bool>;
55
| ^^^^^^^^^^ help: try: `&bool`
@@ -11,55 +11,55 @@ LL | #![deny(clippy::borrowed_box)]
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

1313
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
14-
--> $DIR/borrow_box.rs:24:10
14+
--> $DIR/borrow_box.rs:28:10
1515
|
1616
LL | foo: &'a Box<bool>,
1717
| ^^^^^^^^^^^^^ help: try: `&'a bool`
1818

1919
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
20-
--> $DIR/borrow_box.rs:28:17
20+
--> $DIR/borrow_box.rs:32:17
2121
|
2222
LL | fn test4(a: &Box<bool>);
2323
| ^^^^^^^^^^ help: try: `&bool`
2424

2525
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
26-
--> $DIR/borrow_box.rs:94:25
26+
--> $DIR/borrow_box.rs:98:25
2727
|
2828
LL | pub fn test14(_display: &Box<dyn Display>) {}
2929
| ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display`
3030

3131
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
32-
--> $DIR/borrow_box.rs:95:25
32+
--> $DIR/borrow_box.rs:99:25
3333
|
3434
LL | pub fn test15(_display: &Box<dyn Display + Send>) {}
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
3636

3737
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
38-
--> $DIR/borrow_box.rs:96:29
38+
--> $DIR/borrow_box.rs:100:29
3939
|
4040
LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)`
4242

4343
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
44-
--> $DIR/borrow_box.rs:98:25
44+
--> $DIR/borrow_box.rs:102:25
4545
|
4646
LL | pub fn test17(_display: &Box<impl Display>) {}
4747
| ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display`
4848

4949
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
50-
--> $DIR/borrow_box.rs:99:25
50+
--> $DIR/borrow_box.rs:103:25
5151
|
5252
LL | pub fn test18(_display: &Box<impl Display + Send>) {}
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)`
5454

5555
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
56-
--> $DIR/borrow_box.rs:100:29
56+
--> $DIR/borrow_box.rs:104:29
5757
|
5858
LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
5959
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)`
6060

6161
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
62-
--> $DIR/borrow_box.rs:105:25
62+
--> $DIR/borrow_box.rs:109:25
6363
|
6464
LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {}
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`

tests/ui/infinite_loop.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
error: this argument is a mutable reference, but not used mutably
2+
--> $DIR/infinite_loop.rs:7:17
3+
|
4+
LL | fn fn_mutref(i: &mut i32) {
5+
| ^^^^^^^^ help: consider changing to: `&i32`
6+
|
7+
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
8+
19
error: variables in the condition are not mutated in the loop body
210
--> $DIR/infinite_loop.rs:20:11
311
|
@@ -91,5 +99,5 @@ LL | while y < 10 {
9199
= note: this loop contains `return`s or `break`s
92100
= help: rewrite it as `if cond { loop { } }`
93101

94-
error: aborting due to 11 previous errors
102+
error: aborting due to 12 previous errors
95103

tests/ui/let_underscore_future.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
error: this argument is a mutable reference, but not used mutably
2+
--> $DIR/let_underscore_future.rs:11:35
3+
|
4+
LL | fn do_something_to_future(future: &mut impl Future<Output = ()>) {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&impl Future<Output = ()>`
6+
|
7+
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
8+
19
error: non-binding `let` on a future
210
--> $DIR/let_underscore_future.rs:14:5
311
|
@@ -23,5 +31,5 @@ LL | let _ = future;
2331
|
2432
= help: consider awaiting the future or dropping explicitly with `std::mem::drop`
2533

26-
error: aborting due to 3 previous errors
34+
error: aborting due to 4 previous errors
2735

tests/ui/must_use_candidates.fixed

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
//@run-rustfix
22
#![feature(never_type)]
3-
#![allow(unused_mut, unused_tuple_struct_fields, clippy::redundant_allocation)]
3+
#![allow(
4+
unused_mut,
5+
unused_tuple_struct_fields,
6+
clippy::redundant_allocation,
7+
clippy::needless_pass_by_ref_mut
8+
)]
49
#![warn(clippy::must_use_candidate)]
510
use std::rc::Rc;
611
use std::sync::atomic::{AtomicBool, Ordering};

tests/ui/must_use_candidates.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
//@run-rustfix
22
#![feature(never_type)]
3-
#![allow(unused_mut, unused_tuple_struct_fields, clippy::redundant_allocation)]
3+
#![allow(
4+
unused_mut,
5+
unused_tuple_struct_fields,
6+
clippy::redundant_allocation,
7+
clippy::needless_pass_by_ref_mut
8+
)]
49
#![warn(clippy::must_use_candidate)]
510
use std::rc::Rc;
611
use std::sync::atomic::{AtomicBool, Ordering};

tests/ui/must_use_candidates.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: this function could have a `#[must_use]` attribute
2-
--> $DIR/must_use_candidates.rs:12:1
2+
--> $DIR/must_use_candidates.rs:17:1
33
|
44
LL | pub fn pure(i: u8) -> u8 {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn pure(i: u8) -> u8`
66
|
77
= note: `-D clippy::must-use-candidate` implied by `-D warnings`
88

99
error: this method could have a `#[must_use]` attribute
10-
--> $DIR/must_use_candidates.rs:17:5
10+
--> $DIR/must_use_candidates.rs:22:5
1111
|
1212
LL | pub fn inherent_pure(&self) -> u8 {
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8`
1414

1515
error: this function could have a `#[must_use]` attribute
16-
--> $DIR/must_use_candidates.rs:48:1
16+
--> $DIR/must_use_candidates.rs:53:1
1717
|
1818
LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool {
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool`
2020

2121
error: this function could have a `#[must_use]` attribute
22-
--> $DIR/must_use_candidates.rs:60:1
22+
--> $DIR/must_use_candidates.rs:65:1
2323
|
2424
LL | pub fn rcd(_x: Rc<u32>) -> bool {
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn rcd(_x: Rc<u32>) -> bool`
2626

2727
error: this function could have a `#[must_use]` attribute
28-
--> $DIR/must_use_candidates.rs:68:1
28+
--> $DIR/must_use_candidates.rs:73:1
2929
|
3030
LL | pub fn arcd(_x: Arc<u32>) -> bool {
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc<u32>) -> bool`

tests/ui/mut_from_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(unused, clippy::needless_lifetimes)]
1+
#![allow(unused, clippy::needless_lifetimes, clippy::needless_pass_by_ref_mut)]
22
#![warn(clippy::mut_from_ref)]
33

44
struct Foo;

0 commit comments

Comments
 (0)