Skip to content

Commit

Permalink
Update UI test for async blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 10, 2023
1 parent 4a104ed commit d168b14
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
25 changes: 25 additions & 0 deletions tests/ui/needless_pass_by_ref_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,31 @@ mod foo {
//~| NOTE: this is cfg-gated and may require further changes
}

// Should not warn.
async fn inner_async(x: &mut i32, y: &mut u32) {
async {
*y += 1;
*x += 1;
}
.await;
}

async fn inner_async2(x: &mut i32, y: &mut u32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
async {
*x += 1;
}
.await;
}

async fn inner_async3(x: &mut i32, y: &mut u32) {
//~^ ERROR: this argument is a mutable reference, but not used mutably
async {
*y += 1;
}
.await;
}

fn main() {
let mut u = 0;
let mut v = vec![0];
Expand Down
14 changes: 13 additions & 1 deletion tests/ui/needless_pass_by_ref_mut.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,17 @@ LL | fn cfg_warn(s: &mut u32) {}
|
= note: this is cfg-gated and may require further changes

error: aborting due to 15 previous errors
error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:208:39
|
LL | async fn inner_async2(x: &mut i32, y: &mut u32) {
| ^^^^^^^^ help: consider changing to: `&u32`

error: this argument is a mutable reference, but not used mutably
--> $DIR/needless_pass_by_ref_mut.rs:216:26
|
LL | async fn inner_async3(x: &mut i32, y: &mut u32) {
| ^^^^^^^^ help: consider changing to: `&i32`

error: aborting due to 17 previous errors

0 comments on commit d168b14

Please sign in to comment.