Skip to content

Tracking Issue for #[track_caller] on closures #87417

Open

Description

@Aaron1011

View all comments

This is a tracking issue for the RFC "XXX" (rust-lang/rfcs#NNN).
The feature gate for the issue is #![feature(closure_track_caller)].

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

XXX --- list all the "unresolved questions" found in the RFC to ensure they are
not forgotten

  • Should async {}, etc support track caller on their lowered closures?

Implementation history

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jul 23, 2021
  2. kartva commented on Oct 5, 2022

    @kartva
    Contributor

    What's the status of this issue? I'd be happy to try and pursue stabilization if it's ready.

  3. Aaron1011 commented on Oct 22, 2022

    @Aaron1011
    ContributorAuthor

    Even if this is stabilized, you'll still need the unstable stmt_expr_attributes to actually write it on a closure expression: #15701

  4. mpfaff commented on Jan 22, 2023

    @mpfaff

    Even if this is stabilized, you'll still need the unstable stmt_expr_attributes to actually write it on a closure expression: #15701

    That seems to be the case only if the closure is not passed immediately as a function argument:

    // This works
    let x = std::convert::identity(#[track_caller] || {});
    // But this does not
    let x = #[track_caller] || {};

    Maybe I'm misunderstanding the terminology, but in the case that does work, the closure is still an expression, no?

  5. Aaron1011 commented on Jan 22, 2023

    @Aaron1011
    ContributorAuthor

    You're right - this seems like a bug in the stmt_expr_attributes feature gate (or maybe an intentional partial stabilization).

  6. tmandry commented on Mar 28, 2023

    @tmandry
    Member

    Nominating for lang team discussion. We may not be ready to approve attributes on closures generally. However, this being unstable led to the backing out of#[track_caller] support on async fn in #104741 (originally implemented in #104219) unless the closure_track_caller feature gate is enabled, because it uses that feature under the hood.

    @rustbot label I-lang-nominated I-async-nominated

    @rust-lang/lang, can we get consensus on stabilizing support for #[track_caller] on async fn only, and does that need an FCP?

    The only possible question I see is whether caller tracking should occur during initial call or subsequent polling; this follows the approach adopted and FCP'd in #87064 and adds it to poll. One implication of this is that combinators would need to add #[track_caller] to their poll implementations to be able to "see through" them to user code. @rust-lang/wg-async in case there are any concerns about this.

    Additionally, how close are we to consensus on stabilizing closure_track_caller if a stabilization PR were to come up?

  7. added
    I-async-nominatedNominated for discussion during an async working group meeting.
    I-lang-nominatedNominated for discussion during a lang team meeting.
    on Mar 28, 2023
  8. 22 remaining items

  9. added
    P-lang-drag-1Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang
    on Jul 22, 2026
  10. added a commit that references this issue on Sep 2, 2026
  11. added a commit that references this issue on Sep 2, 2026
  12. added 2 commits that reference this issue on Sep 2, 2026
  13. added 3 commits that reference this issue on Sep 2, 2026
  14. added a commit that references this issue on Sep 2, 2026
  15. added a commit that references this issue on Sep 3, 2026
  16. added a commit that references this issue on Sep 3, 2026
  17. added a commit that references this issue on Sep 3, 2026
  18. added
    I-lang-radarItems that are on lang's radar and will need eventual work or consideration.
    on Oct 7, 2026
  19. theemathas commented on Oct 7, 2026

    @theemathas
    Contributor

    Note: After my work at #163396 is done and then merged, #[track_caller] async fn will track the caller, but #[track_caller] async closures will track the poller/awaiter. This is due to implementation difficulties with the latter.

    This means that async_fn_track_caller and closure_track_caller together won't be able to be simultaneously stabilized as-is after my PR, as doing so would stabilize #[track_caller] async closures, which currently don't work properly. (Such closures are currently gated behind both features, requiring both features to be enabled.)

    Maybe #[track_caller] async closures should be moved to a new feature gate?

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-closuresArea: Closures (`|…| { … }`)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-track_caller`#![feature(track_caller)]`I-lang-nominatedNominated for discussion during a lang team meeting.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.P-lang-drag-1Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-langS-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRT-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