Skip to content

Make inline attributes apply to the generated poll in async fn#149245

Open
xacrimon wants to merge 1 commit intorust-lang:mainfrom
xacrimon:acrimon/async-fn-inline-attr
Open

Make inline attributes apply to the generated poll in async fn#149245
xacrimon wants to merge 1 commit intorust-lang:mainfrom
xacrimon:acrimon/async-fn-inline-attr

Conversation

@xacrimon
Copy link
Copy Markdown
Contributor

@xacrimon xacrimon commented Nov 23, 2025

This PR adds lowering code (similar to how track_caller forwarding works) to async fn items and async || closures such that any inline attributes put on them are inherited by the generated coroutine (corresponding to the poll() implementation) and are not applied to the outer function. This behavior matches the accepted FCP in the first linked issue.

Code like the following now correctly codegen 3 functions

  • async_fn_test::consumer
  • async_fn_test::hi::{closure#0}
  • core::ptr::drop_in_place::<async_fn_test::hi::{closure#0}>
#[inline(never)]
pub async fn hi() -> i32 {
    1337
}

pub fn consumer(cx: &mut Context<'_>) -> Option<i32> {
    let fut = hi();
    let pinned = pin!(fut);
    match pinned.poll(cx) {
        Poll::Ready(value) => Some(value),
        Poll::Pending => None,
    }
}

Fixes #129347 and fixes #106765.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 23, 2025
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Nov 23, 2025

r? @JonathanBrouwer

rustbot has assigned @JonathanBrouwer.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

This comment has been minimized.

@xacrimon xacrimon force-pushed the acrimon/async-fn-inline-attr branch from 46d6c3e to d89022a Compare November 23, 2025 20:55
@rust-log-analyzer

This comment has been minimized.

@xacrimon xacrimon force-pushed the acrimon/async-fn-inline-attr branch 5 times, most recently from 9478bfd to fa35f7b Compare November 23, 2025 23:25
@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@rustbot author
CI is failing

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 25, 2025
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Nov 25, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@bors
Copy link
Copy Markdown
Collaborator

bors commented Dec 11, 2025

☔ The latest upstream changes (presumably #149853) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Jan 2, 2026

☔ The latest upstream changes made this pull request unmergeable. Please resolve the merge conflicts.

@Mark-Simulacrum Mark-Simulacrum added the relnotes Marks issues that should be documented in the release notes of the next release. label Jan 25, 2026
@Enselic
Copy link
Copy Markdown
Member

Enselic commented Mar 20, 2026

Triage: Are you still working on this @xacrimon?

@xacrimon xacrimon force-pushed the acrimon/async-fn-inline-attr branch from fa35f7b to 7054408 Compare April 5, 2026 16:59
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 5, 2026

This PR was rebased onto a different main 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

A-attributes Area: Attributes (`#[…]`, `#![…]`) relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#[inline(never)] does not work for async functions #[inline(never)] does not work for async fn

7 participants