-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #122589 - wutchzone:121547, r=compiler-errors
Fix diagnostics for async block cloning Closes #121547 r? diagnostics
- Loading branch information
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//@ edition:2021 | ||
|
||
async fn clone_async_block(value: String) { | ||
for _ in 0..10 { | ||
async { //~ ERROR: use of moved value: `value` [E0382] | ||
drop(value); | ||
//~^ HELP: consider cloning the value if the performance cost is acceptable | ||
}.await | ||
} | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error[E0382]: use of moved value: `value` | ||
--> $DIR/cloning-in-async-block-121547.rs:5:9 | ||
| | ||
LL | async fn clone_async_block(value: String) { | ||
| ----- move occurs because `value` has type `String`, which does not implement the `Copy` trait | ||
LL | for _ in 0..10 { | ||
| -------------- inside of this loop | ||
LL | / async { | ||
LL | | drop(value); | ||
| | ----- use occurs due to use in coroutine | ||
LL | | | ||
LL | | }.await | ||
| |_________^ value moved here, in previous iteration of loop | ||
| | ||
help: consider cloning the value if the performance cost is acceptable | ||
| | ||
LL | drop(value.clone()); | ||
| ++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0382`. |