Support #[track_caller] on EII declarations#158535
Open
cezarbbb wants to merge 1 commit into
Open
Conversation
Collaborator
|
|
This comment has been minimized.
This comment has been minimized.
dc7acb0 to
e1e75ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracking issue: #125418
Zulip thread: Zulip
#[track_caller]is currently rejected on EII declarations by the catch-all insplit_attrs. This routes it onto the foreign item andderives it onto every implementation during codegen.
The foreign item is the symbol callers link against, so it must carry the flag for call sites to append the caller location. It is routed onto the foreign item only, not the default impl —
check_attralready rejects#[track_caller]on EII implementations (EiiWithTrackCaller), since the attribute is part of the ABI.The flag is then derived onto each implementation in
codegen_attrs: if the foreign item is#[track_caller], every impl gets the flag too. The shim inadd_function_aliasestakes its ABI from the impl'sfn_abi, so if any impl lacked the flag the caller-location argument would be silently dropped rather than reported as a type error. Deriving it keeps default and explicit impls in sync without requiring users to repeat the attribute.#[track_caller]on a foreign item is an already-supported path (seetests/ui/rfcs/rfc-2091-track-caller/track-caller-ffi.rs); this just wires it into EII. Statics are unaffected —#[track_caller]isn't a valid target on statics and is rejected as before.r? @jdonszelmann @bjorn3