@@ -650,14 +650,9 @@ fn traits_implemented_by(cx: &DocContext<'_>, type_: DefId, module: DefId) -> Fx
650
650
let ty = cx. tcx . type_of ( type_) ;
651
651
let iter = in_scope_traits. iter ( ) . flat_map ( |& trait_| {
652
652
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
- }
660
653
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_| {
661
656
let trait_ref = cx. tcx . impl_trait_ref ( impl_) . expect ( "this is not an inherent impl" ) ;
662
657
// Check if these are the same type.
663
658
let impl_type = trait_ref. self_ty ( ) ;
@@ -668,7 +663,7 @@ fn traits_implemented_by(cx: &DocContext<'_>, type_: DefId, module: DefId) -> Fx
668
663
type_
669
664
) ;
670
665
// Fast path: if this is a primitive simple `==` will work
671
- saw_impl = impl_type == ty
666
+ let saw_impl = impl_type == ty
672
667
|| match impl_type. kind ( ) {
673
668
// Check if these are the same def_id
674
669
ty:: Adt ( def, _) => {
@@ -678,8 +673,9 @@ fn traits_implemented_by(cx: &DocContext<'_>, type_: DefId, module: DefId) -> Fx
678
673
ty:: Foreign ( def_id) => * def_id == type_,
679
674
_ => false ,
680
675
} ;
681
- } ) ;
682
- if saw_impl { Some ( trait_) } else { None }
676
+
677
+ if saw_impl { Some ( trait_) } else { None }
678
+ } )
683
679
} ) ;
684
680
iter. collect ( )
685
681
}
0 commit comments