@@ -650,17 +650,18 @@ fn characteristic_def_id_of_mono_item<'tcx>(
650
650
// its self-type. If the self-type does not provide a characteristic
651
651
// DefId, we use the location of the impl after all.
652
652
653
- if tcx. trait_of_assoc ( def_id) . is_some ( ) {
653
+ let parent_id = tcx. parent ( def_id) ;
654
+ let parent_def_kind = tcx. def_kind ( parent_id) ;
655
+ if parent_def_kind == DefKind :: Trait {
654
656
let self_ty = instance. args . type_at ( 0 ) ;
655
657
// This is a default implementation of a trait method.
656
658
return characteristic_def_id_of_type ( self_ty) . or ( Some ( def_id) ) ;
657
659
}
658
660
659
- if let Some ( impl_def_id) = tcx. impl_of_assoc ( def_id) {
660
- if tcx. sess . opts . incremental . is_some ( )
661
- && tcx
662
- . trait_id_of_impl ( impl_def_id)
663
- . is_some_and ( |def_id| tcx. is_lang_item ( def_id, LangItem :: Drop ) )
661
+ if let DefKind :: Impl { of_trait } = parent_def_kind {
662
+ if of_trait
663
+ && tcx. sess . opts . incremental . is_some ( )
664
+ && tcx. is_lang_item ( tcx. impl_trait_id ( parent_id) , LangItem :: Drop )
664
665
{
665
666
// Put `Drop::drop` into the same cgu as `drop_in_place`
666
667
// since `drop_in_place` is the only thing that can
@@ -672,7 +673,7 @@ fn characteristic_def_id_of_mono_item<'tcx>(
672
673
let impl_self_ty = tcx. instantiate_and_normalize_erasing_regions (
673
674
instance. args ,
674
675
ty:: TypingEnv :: fully_monomorphized ( ) ,
675
- tcx. type_of ( impl_def_id ) ,
676
+ tcx. type_of ( parent_id ) ,
676
677
) ;
677
678
if let Some ( def_id) = characteristic_def_id_of_type ( impl_self_ty) {
678
679
return Some ( def_id) ;
0 commit comments