rust/compiler/rustc_monomorphize/src
Stuart Cook 44eb7a167c
Rollup merge of #144865 - WaffleLapkin:track-tail, r=lqd
Fix tail calls to `#[track_caller]` functions

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:
- we forbid tail calls in functions which are marked with `#[track_caller]` (already implemented)
- tail-calling a `#[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,``` rust-lang/rust#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 rust-lang/rust#144762 (and thus closes rust-lang/rust#144762)
Fixes https://github.com/rust-lang/rust/issues/144755
2025-08-15 16:16:31 +10:00
..
collector Complete functionality and general cleanup 2025-08-14 16:30:15 +00:00
mono_checks Remove all support for wasm's legacy ABI 2025-06-14 09:57:06 +00:00
collector.rs Rollup merge of #144865 - WaffleLapkin:track-tail, r=lqd 2025-08-15 16:16:31 +10:00
errors.rs Add support for shortening Instance and use it 2025-08-06 22:21:49 +00:00
lib.rs Replace some Option<Span> with Span and use DUMMY_SP instead of None 2025-06-05 14:14:59 +00:00
partitioning.rs Complete functionality and general cleanup 2025-08-14 16:30:15 +00:00
util.rs use TypingEnv when no infcx is available 2024-11-18 10:38:56 +01:00