@@ -1465,8 +1465,6 @@ pub(crate) fn notable_traits_button(
14651465 ty : & clean:: Type ,
14661466 cx : & Context < ' _ > ,
14671467) -> Option < impl fmt:: Display > {
1468- let mut has_notable_trait = false ;
1469-
14701468 if ty. is_unit ( ) {
14711469 // Very common fast path.
14721470 return None ;
@@ -1484,27 +1482,19 @@ pub(crate) fn notable_traits_button(
14841482 return None ;
14851483 }
14861484
1487- if let Some ( impls) = cx. cache ( ) . impls . get ( & did) {
1488- for i in impls {
1489- let impl_ = i. inner_impl ( ) ;
1490- if impl_. polarity != ty:: ImplPolarity :: Positive {
1491- continue ;
1492- }
1493-
1494- if !ty. is_doc_subtype_of ( & impl_. for_ , cx. cache ( ) ) {
1485+ let impls = cx. cache ( ) . impls . get ( & did) ?;
1486+ let has_notable_trait = impls
1487+ . iter ( )
1488+ . map ( Impl :: inner_impl)
1489+ . filter ( |impl_| {
1490+ impl_. polarity == ty:: ImplPolarity :: Positive
14951491 // Two different types might have the same did,
14961492 // without actually being the same.
1497- continue ;
1498- }
1499- if let Some ( trait_) = & impl_. trait_ {
1500- let trait_did = trait_. def_id ( ) ;
1501-
1502- if cx. cache ( ) . traits . get ( & trait_did) . is_some_and ( |t| t. is_notable_trait ( cx. tcx ( ) ) ) {
1503- has_notable_trait = true ;
1504- }
1505- }
1506- }
1507- }
1493+ && ty. is_doc_subtype_of ( & impl_. for_ , cx. cache ( ) )
1494+ } )
1495+ . filter_map ( |impl_| impl_. trait_ . as_ref ( ) )
1496+ . filter_map ( |trait_| cx. cache ( ) . traits . get ( & trait_. def_id ( ) ) )
1497+ . any ( |t| t. is_notable_trait ( cx. tcx ( ) ) ) ;
15081498
15091499 has_notable_trait. then ( || {
15101500 cx. types_with_notable_traits . borrow_mut ( ) . insert ( ty. clone ( ) ) ;
0 commit comments