Support #[track_caller] on EII declarations#158535
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
dc7acb0 to
e1e75ea
Compare
|
Summarizing the Zulip thread for context, there are two directions came up. One requires The discussion landed on propagation, which is what this PR implements. Adding/removing @jdonszelmann whenever you have capacity, could you take a look? |
| // its ABI from the impl's `fn_abi`, so every impl must agree on whether the | ||
| // caller-location argument is present, otherwise it would be silently dropped. | ||
| if tcx | ||
| .body_codegen_attrs(foreign_item) |
There was a problem hiding this comment.
The foreign_item would never be a const or global asm block if this code is reached, right? So you should be able to use codegen_fn_attrs directly.
|
r? bjorn3 |
e1e75ea to
5c33d50
Compare
|
@bors r+ |
Support `#[track_caller]` on EII declarations Tracking issue: rust-lang#125418 Zulip thread: [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Questions.20about.20support.20.60.23.5Btrack_caller.5D.60.20on.20EII.20declaration) `#[track_caller]` is currently rejected on EII declarations by the catch-all in `split_attrs`. This routes it onto the foreign item and derives 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_attr` already 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 in `add_function_aliases` takes its ABI from the impl's `fn_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 (see `tests/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
…uwer Rollup of 17 pull requests Successful merges: - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets) - #158541 (Move `std::io::Write` to `core::io`) - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`) - #155429 (Support `u128`/`i128` c-variadic arguments) - #156370 (Reject linked dylib EII default overrides) - #157153 (allow `Allocator`s to be used as `#[global_allocator]`s) - #158535 (Support `#[track_caller]` on EII declarations) - #158617 (allow mGCA const arguments to fall back to anon consts) - #158645 (Fix splat ICEs and ban it in closures) - #158988 (Redo `TokenStreamIter`) - #158347 (Improve generic parameters handling for #[diagnostic::on_const]) - #158722 (delegation: do not always inherit `ConstArgHasType` predicates) - #158739 (view-types: HIR lowering) - #158883 (tests: fix enum-match.rs to handle LLVM 23) - #158886 (Add documentation for the `no_std` attribute) - #158951 (Merge three `MaxUniverse`s into one) - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
|
@bors try jobs=aarch64-apple |
|
@bors r- |
This comment has been minimized.
This comment has been minimized.
Support `#[track_caller]` on EII declarations try-job: aarch64-apple
|
This pull request was unapproved. |
|
💔 Test for 69d1e2b failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors r- |
|
This pull request was unapproved. |
35163c9 to
e9273fc
Compare
|
A silly mistake. The line numbers in |
|
@bors r+ |
Support `#[track_caller]` on EII declarations Tracking issue: rust-lang#125418 Zulip thread: [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Questions.20about.20support.20.60.23.5Btrack_caller.5D.60.20on.20EII.20declaration) `#[track_caller]` is currently rejected on EII declarations by the catch-all in `split_attrs`. This routes it onto the foreign item and derives 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_attr` already 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 in `add_function_aliases` takes its ABI from the impl's `fn_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 (see `tests/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
…uwer Rollup of 13 pull requests Successful merges: - #159039 (resolve: fix effective visibilities for items in ambiguous glob sets) - #157706 (Deny `todo!()` in tidy) - #156712 (Pointer authentication config and user facing options) - #158535 (Support `#[track_caller]` on EII declarations) - #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder)) - #159002 (Small refactorings in `need_type_info` module) - #159202 (Bump rustc-demangle to 0.1.28) - #159216 (Avoid using probe self_ty for delegation arguments) - #159222 (semicolon_in_expressions_from_macros: Lint on non-local macros too) - #156609 (Consider structurally impossible Sized predicates in MIR) - #158854 (Add `#[rustc_test_entrypoint_marker]`) - #158998 (Some minor ast validation and visiting cleanups) - #159123 (doc: clarify attr parser APIs)
Support `#[track_caller]` on EII declarations Tracking issue: rust-lang#125418 Zulip thread: [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Questions.20about.20support.20.60.23.5Btrack_caller.5D.60.20on.20EII.20declaration) `#[track_caller]` is currently rejected on EII declarations by the catch-all in `split_attrs`. This routes it onto the foreign item and derives 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_attr` already 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 in `add_function_aliases` takes its ABI from the impl's `fn_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 (see `tests/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
…uwer Rollup of 14 pull requests Successful merges: - #159039 (resolve: fix effective visibilities for items in ambiguous glob sets) - #157706 (Deny `todo!()` in tidy) - #158535 (Support `#[track_caller]` on EII declarations) - #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder)) - #158846 (Fix unused variable warnings for diverging expressions) - #159002 (Small refactorings in `need_type_info` module) - #159202 (Bump rustc-demangle to 0.1.28) - #159216 (Avoid using probe self_ty for delegation arguments) - #159222 (semicolon_in_expressions_from_macros: Lint on non-local macros too) - #156609 (Consider structurally impossible Sized predicates in MIR) - #157993 (Expose more info about ADTs and functions in rustc_public) - #158854 (Add `#[rustc_test_entrypoint_marker]`) - #158998 (Some minor ast validation and visiting cleanups) - #159123 (doc: clarify attr parser APIs)
Support `#[track_caller]` on EII declarations Tracking issue: rust-lang#125418 Zulip thread: [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Questions.20about.20support.20.60.23.5Btrack_caller.5D.60.20on.20EII.20declaration) `#[track_caller]` is currently rejected on EII declarations by the catch-all in `split_attrs`. This routes it onto the foreign item and derives 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_attr` already 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 in `add_function_aliases` takes its ABI from the impl's `fn_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 (see `tests/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
…uwer Rollup of 15 pull requests Successful merges: - #159039 (resolve: fix effective visibilities for items in ambiguous glob sets) - #157706 (Deny `todo!()` in tidy) - #156047 (Fix trait method resolution on an adjusted never type) - #158535 (Support `#[track_caller]` on EII declarations) - #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder)) - #158846 (Fix unused variable warnings for diverging expressions) - #159002 (Small refactorings in `need_type_info` module) - #159202 (Bump rustc-demangle to 0.1.28) - #159216 (Avoid using probe self_ty for delegation arguments) - #156609 (Consider structurally impossible Sized predicates in MIR) - #157993 (Expose more info about ADTs and functions in rustc_public) - #158804 (Clarify `as_uninit_mut` may point to uninitialized memory) - #158854 (Add `#[rustc_test_entrypoint_marker]`) - #158998 (Some minor ast validation and visiting cleanups) - #159123 (doc: clarify attr parser APIs)
…uwer Rollup of 13 pull requests Successful merges: - #157706 (Deny `todo!()` in tidy) - #158535 (Support `#[track_caller]` on EII declarations) - #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder)) - #158846 (Fix unused variable warnings for diverging expressions) - #159002 (Small refactorings in `need_type_info` module) - #159202 (Bump rustc-demangle to 0.1.28) - #159216 (Avoid using probe self_ty for delegation arguments) - #156609 (Consider structurally impossible Sized predicates in MIR) - #157993 (Expose more info about ADTs and functions in rustc_public) - #158804 (Clarify `as_uninit_mut` may point to uninitialized memory) - #158854 (Add `#[rustc_test_entrypoint_marker]`) - #158998 (Some minor ast validation and visiting cleanups) - #159123 (doc: clarify attr parser APIs)
Rollup merge of #158535 - cezarbbb:eii-track-caller, r=bjorn3 Support `#[track_caller]` on EII declarations Tracking issue: #125418 Zulip thread: [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Questions.20about.20support.20.60.23.5Btrack_caller.5D.60.20on.20EII.20declaration) `#[track_caller]` is currently rejected on EII declarations by the catch-all in `split_attrs`. This routes it onto the foreign item and derives 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_attr` already 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 in `add_function_aliases` takes its ABI from the impl's `fn_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 (see `tests/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
View all comments
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