Store DefId instead of EiiDecl in EiiImplResolution::Known#158235
Conversation
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_hir/src/attrs |
|
|
ddb4f2a to
499975b
Compare
This comment has been minimized.
This comment has been minimized.
499975b to
c65973d
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment was marked as resolved.
This comment was marked as resolved.
|
r? bjorn3 |
c65973d to
b645391
Compare
Applied. After this PR the Known branch only reads |
b645391 to
48a980d
Compare
|
@bors r+ |
Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known` Fixes the `FIXME(eii)` about removing the extern target from the encoded decl. `Known(EiiDecl)` serialized the same `EiiDecl` N+1 times per entry (once as the declaration, once per Known impl). Changing to `Known(DefId)` eliminates that redundancy — the `EiiDecl` is recoverable via `tcx.externally_implementable_items()` or a local lookup map, consistent with how Rust metadata uses `DefId` as a reference elsewhere. I believe there are benefits in both performance and size(full `EiiDecl` to single `DefId`, and O(N) to O(1) lookup). Also fixes a soundness gap(I think?) in `check_attr.rs` where the `Known` branch skipped `impl_unsafe` checking, and replaces an `.expect()` in `codegen_attrs.rs` with `a let Some` pattern. tracking issues: rust-lang#125418 r? @jdonszelmann
…uwer Rollup of 22 pull requests Successful merges: - #156047 (Fix trait method resolution on an adjusted never type) - #157824 (Comptime inherent impls) - #158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`) - #158723 (Support EII on Windows MSVC) - #158993 (rerun in original typing mode if we meet any opaques in post analysis) - #159160 (Make `HasTokens` a sub-trait of `HasAttrs`.) - #159183 (Introduce InstanceKind::LlvmIntrinsic) - #159251 (Bump rustc-perf submodule) - #155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing) - #159155 (unstable book: Document `diagnostic_on_unknown` feature) - #159235 (Add regression test for #95719) - #159243 (inline Once wait and wait_force) - #159255 (Replace shortened type with `_` instead of `...` as placeholder) - #159259 (Add regression test for #144033) - #159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable) - #159269 (disable range-len-try-from.rs on s390x) - #159272 (slice: make swap delegate to swap_unchecked) - #159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`) - #159275 (remove obsolete comment) - #159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants) - #159283 (Remove obsolete verbose flag from deref/ref suggestions) - #159290 (rustc-dev-guide subtree update)
…uwer Rollup of 22 pull requests Successful merges: - #156047 (Fix trait method resolution on an adjusted never type) - #157824 (Comptime inherent impls) - #158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`) - #158723 (Support EII on Windows MSVC) - #158993 (rerun in original typing mode if we meet any opaques in post analysis) - #159160 (Make `HasTokens` a sub-trait of `HasAttrs`.) - #159183 (Introduce InstanceKind::LlvmIntrinsic) - #159251 (Bump rustc-perf submodule) - #155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing) - #159155 (unstable book: Document `diagnostic_on_unknown` feature) - #159235 (Add regression test for #95719) - #159243 (inline Once wait and wait_force) - #159255 (Replace shortened type with `_` instead of `...` as placeholder) - #159259 (Add regression test for #144033) - #159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable) - #159269 (disable range-len-try-from.rs on s390x) - #159272 (slice: make swap delegate to swap_unchecked) - #159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`) - #159275 (remove obsolete comment) - #159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants) - #159283 (Remove obsolete verbose flag from deref/ref suggestions) - #159290 (rustc-dev-guide subtree update)
Rollup merge of #158235 - cezarbbb:eii-metadata-opt, r=bjorn3 Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known` Fixes the `FIXME(eii)` about removing the extern target from the encoded decl. `Known(EiiDecl)` serialized the same `EiiDecl` N+1 times per entry (once as the declaration, once per Known impl). Changing to `Known(DefId)` eliminates that redundancy — the `EiiDecl` is recoverable via `tcx.externally_implementable_items()` or a local lookup map, consistent with how Rust metadata uses `DefId` as a reference elsewhere. I believe there are benefits in both performance and size(full `EiiDecl` to single `DefId`, and O(N) to O(1) lookup). Also fixes a soundness gap(I think?) in `check_attr.rs` where the `Known` branch skipped `impl_unsafe` checking, and replaces an `.expect()` in `codegen_attrs.rs` with `a let Some` pattern. tracking issues: #125418 r? @jdonszelmann
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#156047 (Fix trait method resolution on an adjusted never type) - rust-lang/rust#157824 (Comptime inherent impls) - rust-lang/rust#158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`) - rust-lang/rust#158723 (Support EII on Windows MSVC) - rust-lang/rust#158993 (rerun in original typing mode if we meet any opaques in post analysis) - rust-lang/rust#159160 (Make `HasTokens` a sub-trait of `HasAttrs`.) - rust-lang/rust#159183 (Introduce InstanceKind::LlvmIntrinsic) - rust-lang/rust#159251 (Bump rustc-perf submodule) - rust-lang/rust#155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing) - rust-lang/rust#159155 (unstable book: Document `diagnostic_on_unknown` feature) - rust-lang/rust#159235 (Add regression test for rust-lang/rust#95719) - rust-lang/rust#159243 (inline Once wait and wait_force) - rust-lang/rust#159255 (Replace shortened type with `_` instead of `...` as placeholder) - rust-lang/rust#159259 (Add regression test for rust-lang/rust#144033) - rust-lang/rust#159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable) - rust-lang/rust#159269 (disable range-len-try-from.rs on s390x) - rust-lang/rust#159272 (slice: make swap delegate to swap_unchecked) - rust-lang/rust#159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`) - rust-lang/rust#159275 (remove obsolete comment) - rust-lang/rust#159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants) - rust-lang/rust#159283 (Remove obsolete verbose flag from deref/ref suggestions) - rust-lang/rust#159290 (rustc-dev-guide subtree update)
Fixes the
FIXME(eii)about removing the extern target from the encoded decl.Known(EiiDecl)serialized the sameEiiDeclN+1 times per entry (once as the declaration, once per Known impl). Changing toKnown(DefId)eliminates that redundancy — theEiiDeclis recoverable viatcx.externally_implementable_items()or a local lookup map, consistent with how Rust metadata usesDefIdas a reference elsewhere.I believe there are benefits in both performance and size(full
EiiDeclto singleDefId, and O(N) to O(1) lookup).Also fixes a soundness gap(I think?) in
check_attr.rswhere theKnownbranch skippedimpl_unsafechecking, and replaces an.expect()incodegen_attrs.rswitha let Somepattern.tracking issues: #125418
r? @jdonszelmann