Update needless_pass_by_ref_mut ui test

This commit is contained in:
Guillaume Gomez 2023-07-18 21:45:35 +02:00
parent 8b0540bb46
commit 5e9e46278e
2 changed files with 130 additions and 12 deletions

View file

@ -91,15 +91,79 @@ impl<T> Mut<T> {
// Should not warn.
fn unused(_: &mut u32, _b: &mut u8) {}
fn main() {
let mut u = 0;
let mut v = vec![0];
foo(&mut v, &0, &mut u);
foo2(&mut v);
foo3(&mut v);
foo4(&mut v);
foo5(&mut v);
alias_check(&mut v);
alias_check2(&mut v);
println!("{u}");
// Should not warn.
async fn f1(x: &mut i32) {
*x += 1;
}
// Should not warn.
async fn f2(x: &mut i32, y: String) {
*x += 1;
}
// Should not warn.
async fn f3(x: &mut i32, y: String, z: String) {
*x += 1;
}
// Should not warn.
async fn f4(x: &mut i32, y: i32) {
*x += 1;
}
// Should not warn.
async fn f5(x: i32, y: &mut i32) {
*y += 1;
}
// Should not warn.
async fn f6(x: i32, y: &mut i32, z: &mut i32) {
*y += 1;
*z += 1;
}
// Should not warn.
async fn f7(x: &mut i32, y: i32, z: &mut i32, a: i32) {
*x += 1;
*z += 1;
}
// Should warn.
async fn a1(x: &mut i32) {
println!("{:?}", x);
}
// Should warn.
async fn a2(x: &mut i32, y: String) {
println!("{:?}", x);
}
// Should warn.
async fn a3(x: &mut i32, y: String, z: String) {
println!("{:?}", x);
}
// Should warn.
async fn a4(x: &mut i32, y: i32) {
println!("{:?}", x);
}
// Should warn.
async fn a5(x: i32, y: &mut i32) {
println!("{:?}", x);
}
// Should warn.
async fn a6(x: i32, y: &mut i32) {
println!("{:?}", x);
}
// Should warn.
async fn a7(x: i32, y: i32, z: &mut i32) {
println!("{:?}", z);
}
// Should warn.
async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
println!("{:?}", z);
}
fn main() {
// let mut u = 0;
// let mut v = vec![0];
// foo(&mut v, &0, &mut u);
// foo2(&mut v);
// foo3(&mut v);
// foo4(&mut v);
// foo5(&mut v);
// alias_check(&mut v);
// alias_check2(&mut v);
// println!("{u}");
}

View file

@ -24,5 +24,59 @@ error: this argument is a mutable reference, but not used mutably
LL | fn badger(&mut self, vec: &mut Vec<i32>) -> usize {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
error: aborting due to 4 previous errors
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:126:16
|
LL | async fn a1(x: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:130:16
|
LL | async fn a2(x: &mut i32, y: String) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:134:16
|
LL | async fn a3(x: &mut i32, y: String, z: String) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:138:16
|
LL | async fn a4(x: &mut i32, y: i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:142:24
|
LL | async fn a5(x: i32, y: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:146:24
|
LL | async fn a6(x: i32, y: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:150:32
|
LL | async fn a7(x: i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:154:24
|
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:154:45
|
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: aborting due to 13 previous errors