Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1d01f1b

Browse files
Update UI test for async blocks for NEEDLESS_PASS_BY_REF_MUT
1 parent 42186af commit 1d01f1b

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

tests/ui/needless_pass_by_ref_mut.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,31 @@ mod foo {
196196
//~| NOTE: this is cfg-gated and may require further changes
197197
}
198198

199+
// Should not warn.
200+
async fn inner_async(x: &mut i32, y: &mut u32) {
201+
async {
202+
*y += 1;
203+
*x += 1;
204+
}
205+
.await;
206+
}
207+
208+
async fn inner_async2(x: &mut i32, y: &mut u32) {
209+
//~^ ERROR: this argument is a mutable reference, but not used mutably
210+
async {
211+
*x += 1;
212+
}
213+
.await;
214+
}
215+
216+
async fn inner_async3(x: &mut i32, y: &mut u32) {
217+
//~^ ERROR: this argument is a mutable reference, but not used mutably
218+
async {
219+
*y += 1;
220+
}
221+
.await;
222+
}
223+
199224
fn main() {
200225
let mut u = 0;
201226
let mut v = vec![0];

tests/ui/needless_pass_by_ref_mut.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,17 @@ LL | fn cfg_warn(s: &mut u32) {}
9494
|
9595
= note: this is cfg-gated and may require further changes
9696

97-
error: aborting due to 15 previous errors
97+
error: this argument is a mutable reference, but not used mutably
98+
--> $DIR/needless_pass_by_ref_mut.rs:208:39
99+
|
100+
LL | async fn inner_async2(x: &mut i32, y: &mut u32) {
101+
| ^^^^^^^^ help: consider changing to: `&u32`
102+
103+
error: this argument is a mutable reference, but not used mutably
104+
--> $DIR/needless_pass_by_ref_mut.rs:216:26
105+
|
106+
LL | async fn inner_async3(x: &mut i32, y: &mut u32) {
107+
| ^^^^^^^^ help: consider changing to: `&i32`
108+
109+
error: aborting due to 17 previous errors
98110

0 commit comments

Comments
 (0)