async closure argument type inference error has wrong span
Open
@chenyukang is already working on this.
Since Sep 9, 2026.
A-async-closures
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
fn main() {
async |_| {};
}
Current output
error[E0282]: type annotations needed
--> src/main.rs:2:15
|
2 | async |_| {};
| ^^ cannot infer type
Desired output
error[E0282]: type annotations needed
--> src/main.rs:2:7
|
2 | async |_| {};
| ^
|
help: consider giving this closure parameter an explicit type
|
2 | async |_: /* Type */| {};
| ++++++++++++
Rationale and extra context
diagnostics for non-async closures are better and already use this improved error
Other cases
Rust Version
1.88.0-nightly
(2025-03-29 1799887bb281d1ab4928)
Anything else?
@rustbot label A-async-closures
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.