Skip to content

Commit cc136a0

Browse files
Update needless_pass_by_ref_mut ui test
1 parent fa29cef commit cc136a0

File tree

2 files changed

+103
-11
lines changed

2 files changed

+103
-11
lines changed

tests/ui/needless_pass_by_ref_mut.rs

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,65 @@ 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+
115+
// Should warn.
116+
async fn a1(x: &mut i32) {
117+
println!("{:?}", x);
118+
}
119+
// Should warn.
120+
async fn a2(x: &mut i32, y: String) {
121+
println!("{:?}", x);
122+
}
123+
// Should warn.
124+
async fn a3(x: &mut i32, y: String, z: String) {
125+
println!("{:?}", x);
126+
}
127+
// Should warn.
128+
async fn a4(x: &mut i32, y: i32) {
129+
println!("{:?}", x);
130+
}
131+
// Should warn.
132+
async fn a5(x: i32, y: &mut i32) {
133+
println!("{:?}", x);
134+
}
135+
// Should warn.
136+
async fn a6(x: i32, y: &mut i32) {
137+
println!("{:?}", x);
138+
}
139+
// Should warn.
140+
async fn a7(x: i32, y: i32, z: &mut i32) {
141+
println!("{:?}", z);
142+
}
143+
94144
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}");
145+
// let mut u = 0;
146+
// let mut v = vec![0];
147+
// foo(&mut v, &0, &mut u);
148+
// foo2(&mut v);
149+
// foo3(&mut v);
150+
// foo4(&mut v);
151+
// foo5(&mut v);
152+
// alias_check(&mut v);
153+
// alias_check2(&mut v);
154+
// println!("{u}");
105155
}

tests/ui/needless_pass_by_ref_mut.stderr

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,47 @@ 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:116: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:120: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:124: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:128: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:132: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:136: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:140:32
65+
|
66+
LL | async fn a7(x: i32, y: i32, z: &mut i32) {
67+
| ^^^^^^^^ help: consider changing to: `&i32`
68+
69+
error: aborting due to 11 previous errors
2870

0 commit comments

Comments
 (0)