Skip to content

Commit 04b710b

Browse files
Use libtest errors check to better enforce UI testing
1 parent 15de3dd commit 04b710b

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

tests/ui/needless_pass_by_ref_mut.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use std::ptr::NonNull;
55

6-
// Should only warn for `s`.
76
fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
7+
//~^ ERROR: this argument is a mutable reference, but not used mutably
88
*x += *b + s.len() as u32;
99
}
1010

@@ -28,8 +28,8 @@ fn foo5(s: &mut Vec<u32>) {
2828
foo2(s);
2929
}
3030

31-
// Should warn.
3231
fn foo6(s: &mut Vec<u32>) {
32+
//~^ ERROR: this argument is a mutable reference, but not used mutably
3333
non_mut_ref(s);
3434
}
3535

@@ -41,13 +41,13 @@ impl Bar {
4141
// Should not warn on `&mut self`.
4242
fn bar(&mut self) {}
4343

44-
// Should warn about `vec`
4544
fn mushroom(&self, vec: &mut Vec<i32>) -> usize {
45+
//~^ ERROR: this argument is a mutable reference, but not used mutably
4646
vec.len()
4747
}
4848

49-
// Should warn about `vec` (and not `self`).
5049
fn badger(&mut self, vec: &mut Vec<i32>) -> usize {
50+
//~^ ERROR: this argument is a mutable reference, but not used mutably
5151
vec.len()
5252
}
5353
}
@@ -123,36 +123,36 @@ async fn f7(x: &mut i32, y: i32, z: &mut i32, a: i32) {
123123
*z += 1;
124124
}
125125

126-
// Should warn.
127126
async fn a1(x: &mut i32) {
127+
//~^ ERROR: this argument is a mutable reference, but not used mutably
128128
println!("{:?}", x);
129129
}
130-
// Should warn.
131130
async fn a2(x: &mut i32, y: String) {
131+
//~^ ERROR: this argument is a mutable reference, but not used mutably
132132
println!("{:?}", x);
133133
}
134-
// Should warn.
135134
async fn a3(x: &mut i32, y: String, z: String) {
135+
//~^ ERROR: this argument is a mutable reference, but not used mutably
136136
println!("{:?}", x);
137137
}
138-
// Should warn.
139138
async fn a4(x: &mut i32, y: i32) {
139+
//~^ ERROR: this argument is a mutable reference, but not used mutably
140140
println!("{:?}", x);
141141
}
142-
// Should warn.
143142
async fn a5(x: i32, y: &mut i32) {
143+
//~^ ERROR: this argument is a mutable reference, but not used mutably
144144
println!("{:?}", x);
145145
}
146-
// Should warn.
147146
async fn a6(x: i32, y: &mut i32) {
147+
//~^ ERROR: this argument is a mutable reference, but not used mutably
148148
println!("{:?}", x);
149149
}
150-
// Should warn.
151150
async fn a7(x: i32, y: i32, z: &mut i32) {
151+
//~^ ERROR: this argument is a mutable reference, but not used mutably
152152
println!("{:?}", z);
153153
}
154-
// Should warn.
155154
async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
155+
//~^ ERROR: this argument is a mutable reference, but not used mutably
156156
println!("{:?}", z);
157157
}
158158

@@ -185,13 +185,15 @@ fn used_as_path(s: &mut u32) {}
185185
fn lint_attr(s: &mut u32) {}
186186

187187
#[cfg(not(feature = "a"))]
188-
// Should warn with note.
189188
fn cfg_warn(s: &mut u32) {}
189+
//~^ ERROR: this argument is a mutable reference, but not used mutably
190+
//~| NOTE: this is cfg-gated and may require further changes
190191

191192
#[cfg(not(feature = "a"))]
192193
mod foo {
193-
// Should warn with note.
194194
fn cfg_warn(s: &mut u32) {}
195+
//~^ ERROR: this argument is a mutable reference, but not used mutably
196+
//~| NOTE: this is cfg-gated and may require further changes
195197
}
196198

197199
fn main() {

tests/ui/needless_pass_by_ref_mut.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
11
error: this argument is a mutable reference, but not used mutably
2-
--> $DIR/needless_pass_by_ref_mut.rs:7:11
2+
--> $DIR/needless_pass_by_ref_mut.rs:6:11
33
|
44
LL | fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
55
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
66
|
77
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
88

99
error: this argument is a mutable reference, but not used mutably
10-
--> $DIR/needless_pass_by_ref_mut.rs:32:12
10+
--> $DIR/needless_pass_by_ref_mut.rs:31:12
1111
|
1212
LL | fn foo6(s: &mut Vec<u32>) {
1313
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
1414

1515
error: this argument is a mutable reference, but not used mutably
16-
--> $DIR/needless_pass_by_ref_mut.rs:45:29
16+
--> $DIR/needless_pass_by_ref_mut.rs:44:29
1717
|
1818
LL | fn mushroom(&self, vec: &mut Vec<i32>) -> usize {
1919
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
2020

2121
error: this argument is a mutable reference, but not used mutably
22-
--> $DIR/needless_pass_by_ref_mut.rs:50:31
22+
--> $DIR/needless_pass_by_ref_mut.rs:49:31
2323
|
2424
LL | fn badger(&mut self, vec: &mut Vec<i32>) -> usize {
2525
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
2626

2727
error: this argument is a mutable reference, but not used mutably
28-
--> $DIR/needless_pass_by_ref_mut.rs:127:16
28+
--> $DIR/needless_pass_by_ref_mut.rs:126:16
2929
|
3030
LL | async fn a1(x: &mut i32) {
3131
| ^^^^^^^^ help: consider changing to: `&i32`
3232

3333
error: this argument is a mutable reference, but not used mutably
34-
--> $DIR/needless_pass_by_ref_mut.rs:131:16
34+
--> $DIR/needless_pass_by_ref_mut.rs:130:16
3535
|
3636
LL | async fn a2(x: &mut i32, y: String) {
3737
| ^^^^^^^^ help: consider changing to: `&i32`
3838

3939
error: this argument is a mutable reference, but not used mutably
40-
--> $DIR/needless_pass_by_ref_mut.rs:135:16
40+
--> $DIR/needless_pass_by_ref_mut.rs:134:16
4141
|
4242
LL | async fn a3(x: &mut i32, y: String, z: String) {
4343
| ^^^^^^^^ help: consider changing to: `&i32`
4444

4545
error: this argument is a mutable reference, but not used mutably
46-
--> $DIR/needless_pass_by_ref_mut.rs:139:16
46+
--> $DIR/needless_pass_by_ref_mut.rs:138:16
4747
|
4848
LL | async fn a4(x: &mut i32, y: i32) {
4949
| ^^^^^^^^ help: consider changing to: `&i32`
5050

5151
error: this argument is a mutable reference, but not used mutably
52-
--> $DIR/needless_pass_by_ref_mut.rs:143:24
52+
--> $DIR/needless_pass_by_ref_mut.rs:142:24
5353
|
5454
LL | async fn a5(x: i32, y: &mut i32) {
5555
| ^^^^^^^^ help: consider changing to: `&i32`
5656

5757
error: this argument is a mutable reference, but not used mutably
58-
--> $DIR/needless_pass_by_ref_mut.rs:147:24
58+
--> $DIR/needless_pass_by_ref_mut.rs:146:24
5959
|
6060
LL | async fn a6(x: i32, y: &mut i32) {
6161
| ^^^^^^^^ help: consider changing to: `&i32`
6262

6363
error: this argument is a mutable reference, but not used mutably
64-
--> $DIR/needless_pass_by_ref_mut.rs:151:32
64+
--> $DIR/needless_pass_by_ref_mut.rs:150:32
6565
|
6666
LL | async fn a7(x: i32, y: i32, z: &mut i32) {
6767
| ^^^^^^^^ help: consider changing to: `&i32`
6868

6969
error: this argument is a mutable reference, but not used mutably
70-
--> $DIR/needless_pass_by_ref_mut.rs:155:24
70+
--> $DIR/needless_pass_by_ref_mut.rs:154:24
7171
|
7272
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
7373
| ^^^^^^^^ help: consider changing to: `&i32`
7474

7575
error: this argument is a mutable reference, but not used mutably
76-
--> $DIR/needless_pass_by_ref_mut.rs:155:45
76+
--> $DIR/needless_pass_by_ref_mut.rs:154:45
7777
|
7878
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
7979
| ^^^^^^^^ help: consider changing to: `&i32`
8080

8181
error: this argument is a mutable reference, but not used mutably
82-
--> $DIR/needless_pass_by_ref_mut.rs:189:16
82+
--> $DIR/needless_pass_by_ref_mut.rs:188:16
8383
|
8484
LL | fn cfg_warn(s: &mut u32) {}
8585
| ^^^^^^^^ help: consider changing to: `&u32`

0 commit comments

Comments
 (0)