rust-lang / rust-lang/rust-analyzer
When generating implementation for a trait, emit `async fn` for functions that return `impl Future (+ Send)`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
With AFITs + RPITITs being stabilized in 1.75 without RTN, the following pattern will probably become common:
trait AlwaysSend {
fn foo(&self) -> impl Future<Output = ()> + Send;
}
impl AlwaysSend for SomeType {
// We can use `async fn` syntax here, yay!
async fn foo(&self) { /* ... */ }
}
Unfortunately, the “fill missing methods” assist will not generate a nice clean async fn in this case, instead simply copying fn() -> impl Future<Output = ()> + Send.
Note that it doesn’t seem to apply to traits generated with trait-variant, but it’s still unfortunate to have to use procmacros to get a nice IDE experience.
Possibly related to #11315
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.
Research direction
Start with the “fill missing methods” assist described in the issue and compare its behavior with the related #11315 discussion. Done means implementations for trait methods returning impl Future<Output = ...> + Send are generated using async fn syntax where appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100