Skip to content

Make AssocItem aware of its impl kind #145186

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

camsteffen
Copy link
Contributor

The general goal is to have fewer query dependencies by making AssocItem aware of its parent impl kind (inherent vs. trait) without having to query the parent.

  • Introduce enum hir::ImplItemImplKind::{Inherent, Trait} at ImplItem.impl_kind which allows ImplItem to be aware of its containing impl kind, and also move impl-kind-specific fields into corresponding variants.
  • Split AssocItemContainer::Impl into AssocItemContainer::{InherentImpl, TraitImpl}.
  • Use AssocItemContainer in numerous places.

@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_sanitizers

cc @rcvalle

changes to the core type system

cc @compiler-errors, @lcnr

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] build_script_build test:false 0.132
[RUSTC-TIMING] cc test:false 0.799
   Compiling compiler_builtins v0.1.160 (/checkout/library/compiler-builtins/compiler-builtins)
[RUSTC-TIMING] build_script_build test:false 0.384
error: internal compiler error: compiler/rustc_ty_utils/src/ty.rs:93:13: `defaultness` called on ImplItem(ImplItem { ident: is_nan#0, owner_id: DefId(0:144 ~ core[8a11]::f128::{impl#0}::is_nan), generics: Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: library/core/src/num/f128.rs:293:38: 293:38 (#0), span: library/core/src/num/f128.rs:293:24: 293:24 (#0) }, kind: Fn(FnSig { header: FnHeader { safety: Normal(Safe), constness: Const, asyncness: NotAsync, abi: Rust }, decl: FnDecl { inputs: [Ty { hir_id: HirId(DefId(0:144 ~ core[8a11]::f128::{impl#0}::is_nan).11), span: library/core/src/num/f128.rs:293:25: 293:29 (#0), kind: Path(Resolved(None, Path { span: library/core/src/num/f128.rs:293:25: 293:29 (#0), res: SelfTyAlias { alias_to: DefId(0:124 ~ core[8a11]::f128::{impl#0}), forbid_generic: false, is_trait_impl: false }, segments: [PathSegment { ident: Self#0, hir_id: HirId(DefId(0:144 ~ core[8a11]::f128::{impl#0}::is_nan).10), res: SelfTyAlias { alias_to: DefId(0:124 ~ core[8a11]::f128::{impl#0}), forbid_generic: false, is_trait_impl: false }, args: None, infer_args: true }] })) }], output: Return(Ty { hir_id: HirId(DefId(0:144 ~ core[8a11]::f128::{impl#0}::is_nan).12), span: library/core/src/num/f128.rs:293:34: 293:38 (#0), kind: Path(Resolved(None, Path { span: library/core/src/num/f128.rs:293:34: 293:38 (#0), res: PrimTy(Bool), segments: [PathSegment { ident: bool#0, hir_id: HirId(DefId(0:144 ~ core[8a11]::f128::{impl#0}::is_nan).13), res: PrimTy(Bool), args: None, infer_args: false }] })) }), c_variadic: false, implicit_self: Imm, lifetime_elision_allowed: false }, span: library/core/src/num/f128.rs:293:5: 293:38 (#0) }, BodyId { hir_id: HirId(DefId(0:144 ~ core[8a11]::f128::{impl#0}::is_nan).9) }), impl_kind: Inherent { vis_span: library/core/src/num/f128.rs:293:5: 293:8 (#0) }, span: library/core/src/num/f128.rs:293:5: 295:6 (#0), has_delayed_lints: false })


thread 'rustc' (66621) panicked at compiler/rustc_ty_utils/src/ty.rs:93:13:
Box<dyn Any>
stack backtrace:
   0:     0xfff35b87cf7c - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc675da3d88ac3f9e
   1:     0xfff35b8db6b0 - core::fmt::write::h588ea7fbabf8c0fa
   2:     0xfff35b86fc28 - std::io::Write::write_fmt::h920e10838796c3ae
   3:     0xfff35b87ce80 - std::sys::backtrace::BacktraceLock::print::h443d42daf5c8cc07
   4:     0xfff35b880bb8 - std::panicking::default_hook::{{closure}}::hebf2491cbf23a92b
   5:     0xfff35b8809c0 - std::panicking::default_hook::h63195104bac6f053
   6:     0xfff3576834fc - <alloc[143336cde34b9da4]::boxed::Box<rustc_driver_impl[845df1b4239f16ba]::install_ice_hook::{closure#1}> as core[2a423bc60c5820f3]::ops::function::Fn<(&dyn for<'a, 'b> core[2a423bc60c5820f3]::ops::function::Fn<(&'a std[8f23d15b49287849]::panic::PanicHookInfo<'b>,), Output = ()> + core[2a423bc60c5820f3]::marker::Sync + core[2a423bc60c5820f3]::marker::Send, &std[8f23d15b49287849]::panic::PanicHookInfo)>>::call
   7:     0xfff35b8817f4 - std::panicking::panic_with_hook::hb7fde282b40c6066
   8:     0xfff35b3f2c4c - std[8f23d15b49287849]::panicking::begin_panic::<rustc_errors[7fc6e4d4f46b5663]::ExplicitBug>::{closure#0}
   9:     0xfff35b3f2be0 - std[8f23d15b49287849]::sys::backtrace::__rust_end_short_backtrace::<std[8f23d15b49287849]::panicking::begin_panic<rustc_errors[7fc6e4d4f46b5663]::ExplicitBug>::{closure#0}, !>
  10:     0xfff35752a5e8 - std[8f23d15b49287849]::panicking::begin_panic::<rustc_errors[7fc6e4d4f46b5663]::ExplicitBug>
  11:     0xfff35b3cf974 - <rustc_errors[7fc6e4d4f46b5663]::diagnostic::BugAbort as rustc_errors[7fc6e4d4f46b5663]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0xfff35b245c10 - rustc_middle[97c7c871432f06d]::util::bug::opt_span_bug_fmt::<rustc_span[714ee4364157f132]::span_encoding::Span>::{closure#0}
  13:     0xfff35b245aa4 - rustc_middle[97c7c871432f06d]::ty::context::tls::with_opt::<rustc_middle[97c7c871432f06d]::util::bug::opt_span_bug_fmt<rustc_span[714ee4364157f132]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0xfff35b245a60 - rustc_middle[97c7c871432f06d]::ty::context::tls::with_context_opt::<rustc_middle[97c7c871432f06d]::ty::context::tls::with_opt<rustc_middle[97c7c871432f06d]::util::bug::opt_span_bug_fmt<rustc_span[714ee4364157f132]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0xfff35751bd28 - rustc_middle[97c7c871432f06d]::util::bug::bug_fmt
  16:     0xfff3598cf0f8 - rustc_ty_utils[6f6d1dbfc6c89b72]::ty::defaultness
  17:     0xfff359df9050 - rustc_query_impl[e25e55c6f62a5670]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e25e55c6f62a5670]::query_impl::defaultness::dynamic_query::{closure#2}::{closure#0}, rustc_middle[97c7c871432f06d]::query::erase::Erased<[u8; 1usize]>>
  18:     0xfff359d1324c - <rustc_query_impl[e25e55c6f62a5670]::query_impl::defaultness::dynamic_query::{closure#2} as core[2a423bc60c5820f3]::ops::function::FnOnce<(rustc_middle[97c7c871432f06d]::ty::context::TyCtxt, rustc_span[714ee4364157f132]::def_id::DefId)>>::call_once
  19:     0xfff359da1cb0 - <std[8f23d15b49287849]::thread::local::LocalKey<core[2a423bc60c5820f3]::cell::Cell<*const ()>>>::with::<rustc_middle[97c7c871432f06d]::ty::context::tls::enter_context<rustc_query_system[be7a4569482ec0d5]::query::plumbing::try_load_from_disk_and_cache_in_memory<rustc_query_impl[e25e55c6f62a5670]::DynamicConfig<rustc_query_system[be7a4569482ec0d5]::query::caches::DefIdCache<rustc_middle[97c7c871432f06d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e25e55c6f62a5670]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[97c7c871432f06d]::query::erase::Erased<[u8; 1usize]>>::{closure#0}, rustc_middle[97c7c871432f06d]::query::erase::Erased<[u8; 1usize]>>
  20:     0xfff359c4932c - rustc_query_system[be7a4569482ec0d5]::query::plumbing::try_execute_query::<rustc_query_impl[e25e55c6f62a5670]::DynamicConfig<rustc_query_system[be7a4569482ec0d5]::query::caches::DefIdCache<rustc_middle[97c7c871432f06d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e25e55c6f62a5670]::plumbing::QueryCtxt, false>
  21:     0xfff35a09a99c - rustc_query_impl[e25e55c6f62a5670]::query_impl::defaultness::get_query_non_incr::__rust_end_short_backtrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants