Skip to content

#[track_caller] async fn in trait definition doesn't apply to impls, with no warning #163406

Description

@theemathas

This issue is similar to #161961.

Related tracking issue: #110011

I tried this code:

struct Thing;

trait Trait {
    #[track_caller]
    async fn method(&self);
}

impl Trait for Thing {
    async fn method(&self) {
        panic!();
    }
}

#[tokio::main]
async fn main() {
    Thing.method().await;
}

This code should either produce a warning, or the panic should point to the line where method is called and awaited.

Instead, this code does not produce any warnings, and the panic points to the line where panic!() was written. Adding #![feature(async_fn_track_caller)] to the top doesn't change this behavior.

This is incorrect, as the reference says that #[track_caller] on a function in a trait definition should apply to that function in all impl blocks.

Also, there should probably be an ungated_async_fn_track_caller FCW for this code.

Meta

Reproducible on the playground with version 1.101.0-nightly (2026-09-26 75a75c3e0a67d3fa3d03)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-panicArea: Panicking machineryC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions