Code
fn foo_tasks() -> Vec<impl Future<Output = Result<i32, ()>>> { /*... logical stuffs ...*/ }
let async_tasks = foo_tasks();
if upper_condi {
let task_results_upper = try_join_all(async_tasks).await?;
// ...
Err(())?;
}
if lower_condi {
let task_results_lower = try_join_all(async_tasks).await?;
// ...
Err(())?;
}
Current output
error[E0382]: use of moved value: `async_tasks`
| let async_tasks = foo_tasks();
| ----------- move occurs because `async_tasks` has type `Vec<impl Future<Output = Result<i32, ()>>>`, which does not implement the `Copy` trait
...
|
| let task_results_upper = try_join_all(async_tasks).await?;
----------- value moved here
...
| let task_results_lower = try_join_all(async_tasks).await?;
| ^^^^^^^^^^^ value used here after move
Desired output
Rationale and extra context
No response
Other cases
Rust Version
$ rustc --version --verbose
rustc 1.94.0 (4a4ef493e 2026-03-02)
binary: rustc
commit-hash: 4a4ef493e3a1488c6e321570238084b38948f6db
commit-date: 2026-03-02
host: x86_64-unknown-linux-gnu
release: 1.94.0
LLVM version: 21.1.8
Anything else?
I expect putting ? directly on Err() can do a short-circuit to the current function so that receiving a smoother programming experience. Directly putting ? on Err() reaching for quick leave demonstrates that I know what I am doing, which this operation is indeed logical, but the actual compiler implementation apply the match { ... } to ?-operator.
I can fixed this rustc error by replacing Err(())? into return Err(()) in my project, but I create this issue for letting rustc team recognizing this logical issue for imrpovement.
Code
Current output
Desired output
Rationale and extra context
No response
Other cases
Rust Version
Anything else?
I expect putting
?directly onErr()can do a short-circuit to the current function so that receiving a smoother programming experience. Directly putting?onErr()reaching for quick leave demonstrates that I know what I am doing, which this operation is indeed logical, but the actual compiler implementation apply thematch { ... }to?-operator.I can fixed this rustc error by replacing
Err(())?intoreturn Err(())in my project, but I create this issue for letting rustc team recognizing this logical issue for imrpovement.