@@ -650,17 +650,18 @@ fn characteristic_def_id_of_mono_item<'tcx>(
650650 // its self-type. If the self-type does not provide a characteristic
651651 // DefId, we use the location of the impl after all.
652652
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 {
654656 let self_ty = instance. args . type_at ( 0 ) ;
655657 // This is a default implementation of a trait method.
656658 return characteristic_def_id_of_type ( self_ty) . or ( Some ( def_id) ) ;
657659 }
658660
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 )
664665 {
665666 // Put `Drop::drop` into the same cgu as `drop_in_place`
666667 // since `drop_in_place` is the only thing that can
@@ -672,7 +673,7 @@ fn characteristic_def_id_of_mono_item<'tcx>(
672673 let impl_self_ty = tcx. instantiate_and_normalize_erasing_regions (
673674 instance. args ,
674675 ty:: TypingEnv :: fully_monomorphized ( ) ,
675- tcx. type_of ( impl_def_id ) ,
676+ tcx. type_of ( parent_id ) ,
676677 ) ;
677678 if let Some ( def_id) = characteristic_def_id_of_type ( impl_self_ty) {
678679 return Some ( def_id) ;
0 commit comments