Skip to content

Commit 5e9e462

Browse files
Update needless_pass_by_ref_mut ui test
1 parent 8b0540b commit 5e9e462

File tree

2 files changed

+129
-11
lines changed

2 files changed

+129
-11
lines changed

tests/ui/needless_pass_by_ref_mut.rs

+74-10
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,79 @@ impl<T> Mut<T> {
9191
// Should not warn.
9292
fn unused(_: &mut u32, _b: &mut u8) {}
9393

94+
// Should not warn.
95+
async fn f1(x: &mut i32) {
96+
*x += 1;
97+
}
98+
// Should not warn.
99+
async fn f2(x: &mut i32, y: String) {
100+
*x += 1;
101+
}
102+
// Should not warn.
103+
async fn f3(x: &mut i32, y: String, z: String) {
104+
*x += 1;
105+
}
106+
// Should not warn.
107+
async fn f4(x: &mut i32, y: i32) {
108+
*x += 1;
109+
}
110+
// Should not warn.
111+
async fn f5(x: i32, y: &mut i32) {
112+
*y += 1;
113+
}
114+
// Should not warn.
115+
async fn f6(x: i32, y: &mut i32, z: &mut i32) {
116+
*y += 1;
117+
*z += 1;
118+
}
119+
// Should not warn.
120+
async fn f7(x: &mut i32, y: i32, z: &mut i32, a: i32) {
121+
*x += 1;
122+
*z += 1;
123+
}
124+
125+
// Should warn.
126+
async fn a1(x: &mut i32) {
127+
println!("{:?}", x);
128+
}
129+
// Should warn.
130+
async fn a2(x: &mut i32, y: String) {
131+
println!("{:?}", x);
132+
}
133+
// Should warn.
134+
async fn a3(x: &mut i32, y: String, z: String) {
135+
println!("{:?}", x);
136+
}
137+
// Should warn.
138+
async fn a4(x: &mut i32, y: i32) {
139+
println!("{:?}", x);
140+
}
141+
// Should warn.
142+
async fn a5(x: i32, y: &mut i32) {
143+
println!("{:?}", x);
144+
}
145+
// Should warn.
146+
async fn a6(x: i32, y: &mut i32) {
147+
println!("{:?}", x);
148+
}
149+
// Should warn.
150+
async fn a7(x: i32, y: i32, z: &mut i32) {
151+
println!("{:?}", z);
152+
}
153+
// Should warn.
154+
async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
155+
println!("{:?}", z);
156+
}
157+
94158
fn main() {
95-
let mut u = 0;
96-
let mut v = vec![0];
97-
foo(&mut v, &0, &mut u);
98-
foo2(&mut v);
99-
foo3(&mut v);
100-
foo4(&mut v);
101-
foo5(&mut v);
102-
alias_check(&mut v);
103-
alias_check2(&mut v);
104-
println!("{u}");
159+
// let mut u = 0;
160+
// let mut v = vec![0];
161+
// foo(&mut v, &0, &mut u);
162+
// foo2(&mut v);
163+
// foo3(&mut v);
164+
// foo4(&mut v);
165+
// foo5(&mut v);
166+
// alias_check(&mut v);
167+
// alias_check2(&mut v);
168+
// println!("{u}");
105169
}

tests/ui/needless_pass_by_ref_mut.stderr

+55-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,59 @@ error: this argument is a mutable reference, but not used mutably
2424
LL | fn badger(&mut self, vec: &mut Vec<i32>) -> usize {
2525
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
2626

27-
error: aborting due to 4 previous errors
27+
error: this argument is a mutable reference, but not used mutably
28+
--> $DIR/needless_pass_by_ref_mut.rs:126:16
29+
|
30+
LL | async fn a1(x: &mut i32) {
31+
| ^^^^^^^^ help: consider changing to: `&i32`
32+
33+
error: this argument is a mutable reference, but not used mutably
34+
--> $DIR/needless_pass_by_ref_mut.rs:130:16
35+
|
36+
LL | async fn a2(x: &mut i32, y: String) {
37+
| ^^^^^^^^ help: consider changing to: `&i32`
38+
39+
error: this argument is a mutable reference, but not used mutably
40+
--> $DIR/needless_pass_by_ref_mut.rs:134:16
41+
|
42+
LL | async fn a3(x: &mut i32, y: String, z: String) {
43+
| ^^^^^^^^ help: consider changing to: `&i32`
44+
45+
error: this argument is a mutable reference, but not used mutably
46+
--> $DIR/needless_pass_by_ref_mut.rs:138:16
47+
|
48+
LL | async fn a4(x: &mut i32, y: i32) {
49+
| ^^^^^^^^ help: consider changing to: `&i32`
50+
51+
error: this argument is a mutable reference, but not used mutably
52+
--> $DIR/needless_pass_by_ref_mut.rs:142:24
53+
|
54+
LL | async fn a5(x: i32, y: &mut i32) {
55+
| ^^^^^^^^ help: consider changing to: `&i32`
56+
57+
error: this argument is a mutable reference, but not used mutably
58+
--> $DIR/needless_pass_by_ref_mut.rs:146:24
59+
|
60+
LL | async fn a6(x: i32, y: &mut i32) {
61+
| ^^^^^^^^ help: consider changing to: `&i32`
62+
63+
error: this argument is a mutable reference, but not used mutably
64+
--> $DIR/needless_pass_by_ref_mut.rs:150:32
65+
|
66+
LL | async fn a7(x: i32, y: i32, z: &mut i32) {
67+
| ^^^^^^^^ help: consider changing to: `&i32`
68+
69+
error: this argument is a mutable reference, but not used mutably
70+
--> $DIR/needless_pass_by_ref_mut.rs:154:24
71+
|
72+
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
73+
| ^^^^^^^^ help: consider changing to: `&i32`
74+
75+
error: this argument is a mutable reference, but not used mutably
76+
--> $DIR/needless_pass_by_ref_mut.rs:154:45
77+
|
78+
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
79+
| ^^^^^^^^ help: consider changing to: `&i32`
80+
81+
error: aborting due to 13 previous errors
2882

0 commit comments

Comments
 (0)