Skip to content

#[track_caller] on async closures silently do nothing unless async_fn_track_caller is enabled. #161961

Description

@theemathas

I tried this code:

#![feature(closure_track_caller)]

#[tokio::main]
async fn main() {
    let closure = {
        #[track_caller]
        async || {
            panic!();
        }
    };
    closure().await;
}

I expected either:

  • the ungated_async_fn_track_caller lint fires; or
  • the panic output points to the closure().await line (line 11)

Instead, no warning is given, and the panic output points to the panic!(); line (line 8):

thread 'main' (13) panicked at src/main.rs:8:13:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Enabling the async_fn_track_caller feature causes the panic output to correctly point to line 11 instead.

The ungated_async_fn_track_caller lint (implemented in #104741) is supposed to warn the user if a #[track_caller] doesn't do anything due to not enabling the async_fn_track_caller feature. It does not work properly here.

Tracking issue for closure_track_caller: #87417

Tracking issue for async_fn_track_caller: #110011

Meta

Reproducible on the playground with version 1.100.0-nightly (2026-08-26 bff8e12ff5e6bcd53dfb)

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-closures`async || {}`A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-panicArea: Panicking machineryC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions