diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-07-18 21:45:35 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-07-18 22:21:02 +0200 |
| commit | 5e9e46278e1e69b0c8379f05f986b548572bdba8 (patch) | |
| tree | 8977c365dd691e975453db76b2b24726feccca24 | |
| parent | 8b0540bb46467cb4af35eed437994753957a43c6 (diff) | |
| download | rust-5e9e46278e1e69b0c8379f05f986b548572bdba8.tar.gz rust-5e9e46278e1e69b0c8379f05f986b548572bdba8.zip | |
Update `needless_pass_by_ref_mut` ui test
| -rw-r--r-- | tests/ui/needless_pass_by_ref_mut.rs | 84 | ||||
| -rw-r--r-- | tests/ui/needless_pass_by_ref_mut.stderr | 56 |
2 files changed, 129 insertions, 11 deletions
diff --git a/tests/ui/needless_pass_by_ref_mut.rs b/tests/ui/needless_pass_by_ref_mut.rs index 5e7280995c6..27e1fc075bb 100644 --- a/tests/ui/needless_pass_by_ref_mut.rs +++ b/tests/ui/needless_pass_by_ref_mut.rs @@ -91,15 +91,79 @@ impl<T> Mut<T> { // Should not warn. fn unused(_: &mut u32, _b: &mut u8) {} +// 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}"); + // 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}"); } diff --git a/tests/ui/needless_pass_by_ref_mut.stderr b/tests/ui/needless_pass_by_ref_mut.stderr index 5e9d80bb6c4..caf47bbce86 100644 --- a/tests/ui/needless_pass_by_ref_mut.stderr +++ b/tests/ui/needless_pass_by_ref_mut.stderr @@ -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 |
