diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-14 11:39:38 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-14 11:39:38 +0200 | 
| commit | ad21c6d89822a7444cd4e10fc47c7af1dbc9c0b3 (patch) | |
| tree | 50511e481adb021187feccd4081f19198650b996 /compiler/rustc_monomorphize/src/partitioning.rs | |
| parent | 952584942cdedc7e9e4d4037f2355932f8d75a2e (diff) | |
| parent | d4eb0947f133d8f44594d7551d99a48daff21c02 (diff) | |
| download | rust-ad21c6d89822a7444cd4e10fc47c7af1dbc9c0b3.tar.gz rust-ad21c6d89822a7444cd4e10fc47c7af1dbc9c0b3.zip  | |
Rollup merge of #145266 - camsteffen:reduce-queries, r=petrochenkov
Reduce some queries around associated items
Diffstat (limited to 'compiler/rustc_monomorphize/src/partitioning.rs')
| -rw-r--r-- | compiler/rustc_monomorphize/src/partitioning.rs | 13 | 
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index d76b27d9970..54d77b182f8 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -650,17 +650,18 @@ fn characteristic_def_id_of_mono_item<'tcx>( // its self-type. If the self-type does not provide a characteristic // DefId, we use the location of the impl after all. - if tcx.trait_of_assoc(def_id).is_some() { + let assoc_parent = tcx.assoc_parent(def_id); + + if let Some((_, DefKind::Trait)) = assoc_parent { let self_ty = instance.args.type_at(0); // This is a default implementation of a trait method. return characteristic_def_id_of_type(self_ty).or(Some(def_id)); } - if let Some(impl_def_id) = tcx.impl_of_assoc(def_id) { - if tcx.sess.opts.incremental.is_some() - && tcx - .trait_id_of_impl(impl_def_id) - .is_some_and(|def_id| tcx.is_lang_item(def_id, LangItem::Drop)) + if let Some((impl_def_id, DefKind::Impl { of_trait })) = assoc_parent { + if of_trait + && tcx.sess.opts.incremental.is_some() + && tcx.is_lang_item(tcx.trait_id_of_impl(impl_def_id).unwrap(), LangItem::Drop) { // Put `Drop::drop` into the same cgu as `drop_in_place` // since `drop_in_place` is the only thing that can  | 
