Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scottmcm opened this issue Aug 24, 2021 · 4 comments
Closed

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

scottmcm opened this issue Aug 24, 2021 · 4 comments
Labels
T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@scottmcm
Copy link
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?

@scottmcm scottmcm added I-nominated T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Aug 24, 2021
@Aaron1011
Copy link
Member

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
Copy link
Member

the8472 commented Aug 26, 2021

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
Copy link
Member

m-ou-se commented Sep 1, 2021

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
Copy link
Member Author

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
Labels
T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants