@@ -650,14 +650,9 @@ fn traits_implemented_by(cx: &DocContext<'_>, type_: DefId, module: DefId) -> Fx
650650 let ty = cx. tcx . type_of ( type_) ;
651651 let iter = in_scope_traits. iter ( ) . flat_map ( |& trait_| {
652652 trace ! ( "considering explicit impl for trait {:?}" , trait_) ;
653- let mut saw_impl = false ;
654- // Look at each trait implementation to see if it's an impl for `did`
655- cx. tcx . for_each_relevant_impl ( trait_, ty, |impl_| {
656- // FIXME: this is inefficient, find a way to short-circuit for_each_* so this doesn't take as long
657- if saw_impl {
658- return ;
659- }
660653
654+ // Look at each trait implementation to see if it's an impl for `did`
655+ cx. tcx . find_map_relevant_impl ( trait_, ty, |impl_| {
661656 let trait_ref = cx. tcx . impl_trait_ref ( impl_) . expect ( "this is not an inherent impl" ) ;
662657 // Check if these are the same type.
663658 let impl_type = trait_ref. self_ty ( ) ;
@@ -668,7 +663,7 @@ fn traits_implemented_by(cx: &DocContext<'_>, type_: DefId, module: DefId) -> Fx
668663 type_
669664 ) ;
670665 // Fast path: if this is a primitive simple `==` will work
671- saw_impl = impl_type == ty
666+ let saw_impl = impl_type == ty
672667 || match impl_type. kind ( ) {
673668 // Check if these are the same def_id
674669 ty:: Adt ( def, _) => {
@@ -678,8 +673,9 @@ fn traits_implemented_by(cx: &DocContext<'_>, type_: DefId, module: DefId) -> Fx
678673 ty:: Foreign ( def_id) => * def_id == type_,
679674 _ => false ,
680675 } ;
681- } ) ;
682- if saw_impl { Some ( trait_) } else { None }
676+
677+ if saw_impl { Some ( trait_) } else { None }
678+ } )
683679 } ) ;
684680 iter. collect ( )
685681}
0 commit comments