Skip to content

What is the stability guarantee of #[track_caller] locations? #88302

@scottmcm

Description

@scottmcm
Member

This is inspired by #87401

The general version of that bug is that any time a call to a trait method that might have had #[track_caller] in its impl is moved or wrapped, then the location can change. When, if ever, is a change to a location a breaking change?

Activity

added
T-langRelevant to the language team
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on Aug 24, 2021
Aaron1011

Aaron1011 commented on Aug 26, 2021

@Aaron1011
Contributor

I would argue that the stability guarantees should be the same as for the output of Backtrace - that is, no guarantees at all. Both allow a program to observe private details about libcore/libstd, but we want to reserve the right to change those details at any time.

the8472

the8472 commented on Aug 26, 2021

@the8472
Member

I think to do this correctly we need better backtrace support, similar to java's stack walker. That was introduced because their internal #[track_caller] equivalent (Reflection.getCallerClass()) that they used for security checks proved too brittle as the language evolved.

In other words prior art shows that relying on fixed-count stack frame inspection for important functionality is a maintenance burden and traversal with filtering is a more robust approach.

m-ou-se

m-ou-se commented on Sep 1, 2021

@m-ou-se
Member

We discussed this in the library api meeting just now. We agreed that #[track_caller] is not a promise that that attribute will stay there in the future. We can imagine such a promise might be made in the public documentation of a function, but that's not an implicit guarantee.

#[track_caller] is an important part of the quality of the standard library. Not having it in certain situations might be bad, but it's not a stability guarantee by itself.

scottmcm

scottmcm commented on Nov 27, 2021

@scottmcm
MemberAuthor

Given that this is answered in #88302 (comment), I'll close it.

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

    T-langRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @m-ou-se@the8472@Aaron1011@scottmcm

        Issue actions

          What is the stability guarantee of `#[track_caller]` locations? · Issue #88302 · rust-lang/rust