-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Fix tail calls to #[track_caller]
functions
#144865
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
base: master
Are you sure you want to change the base?
Conversation
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
e747cdd
to
a487936
Compare
This comment has been minimized.
This comment has been minimized.
a487936
to
6fff1d6
Compare
This comment has been minimized.
This comment has been minimized.
I do not get it, both tests pass for me locally ?_? |
6fff1d6
to
15219a0
Compare
Update: @jieyouxu figured this out. It looks like the test suite that failed was running with |
not too familiar with tail calls but the diff looks good to me r? compiler |
r? lqd maybe (since you were excited about tail calls ^^') |
We want
#[track_caller]
to be semver independent, i.e. it should not be a breaking change to add or remove it. Since it changes ABI of a function (adding an additional argument) we have to be careful to preserve this property when adding tail calls.The only way to achieve this that I can see is:
#[track_caller]
(already implemented)#[track_caller]
marked function downgrades the tail-call to a normal call (or equivalently tail-calls the shim made by fn def to fn ptr cast) (this pr)Ideally the downgrade would be performed by a MIR pass, but that requires post mono MIR opts (cc @saethlin, #131650). For now I've changed code in cg_ssa to accomodate this behaviour (+ added a hack to mono collector so that the shim is actually generated)
Additionally I added a lint, although I don't think it's strictly necessary.
Alternative to #144762 (and thus closes #144762)
Fixes #144755