rust-lang / rust-lang/rust-analyzer

When generating implementation for a trait, emit `async fn` for functions that return `impl Future (+ Send)`

Open
#16,195 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.