Skip to content

feat: emit async modifier for functions returning impl Future - #22410

Open
Albab-Hasan wants to merge 1 commit into
rust-lang:masterfrom
Albab-Hasan:async-modifier-impl-future
Open

feat: emit async modifier for functions returning impl Future#22410
Albab-Hasan wants to merge 1 commit into
rust-lang:masterfrom
Albab-Hasan:async-modifier-impl-future

Conversation

@Albab-Hasan

Copy link
Copy Markdown
Contributor

the async semantic token modifier was only emitted for async fn. functions in embedded async crates like embassy commonly return impl Future or a concrete type that implements Future without the async keyword.

returns_impl_future in hir is extended to fall through to an impls_trait check when the return type is not impl Trait syntax covering concrete structs and type aliases that implement Future. the Sized lang item is optional in the impl Trait path; not a hard failure so its absence in minimal crate environments dosent silently return false.

closes #22407

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2026
@ChayimFriedman2

Copy link
Copy Markdown
Contributor

I object. These functions are not declared async, and hover should be faithful.

@Albab-Hasan

Copy link
Copy Markdown
Contributor Author

fair

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2026
@Albab-Hasan

Copy link
Copy Markdown
Contributor Author

@ChayimFriedman2 can you take a look at this pls

#21908

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

Hmm, now I see that this is not about hover but about highlighting. So maybe, I need to form an opinion on this.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2026
@rustbot

This comment has been minimized.

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

@rust-lang/rust-analyzer, my personal opinion now is that we should do this. What do you think?

@lnicola

lnicola commented Aug 10, 2026

Copy link
Copy Markdown
Member

Both seems like defensible positions, but I'm generally in favor of DWIM, so it sounds fine to me.

@lnicola

lnicola commented Aug 18, 2026

Copy link
Copy Markdown
Member

@Albab-Hasan can you rebase?

the `async` semantic token modifier was only emitted for `async fn`. functions in embedded async crates like embassy commonly return `impl Future` or a concrete type that implements `Future` without the `async` keyword, causing inconsistent highlighting.

`returns_impl_future` in `hir` is extended to fall through to an `impls_trait` check when the return type is not `impl
Trait` syntax, covering concrete structs and type aliases that implement `Future`. the `Sized` lang item is now treated
as optional in the impl Trait path rather than a hard failure, so its absence in minimal crate environments no longer
silently returns false.

closes rust-lang#22407
@Albab-Hasan
Albab-Hasan force-pushed the async-modifier-impl-future branch from b4d9fa4 to b0450b4 Compare August 19, 2026 02:30
@rustbot

rustbot commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emit semantic token modifier async for impl Future

4 participants