@@ -1465,8 +1465,6 @@ pub(crate) fn notable_traits_button(
1465
1465
ty : & clean:: Type ,
1466
1466
cx : & Context < ' _ > ,
1467
1467
) -> Option < impl fmt:: Display > {
1468
- let mut has_notable_trait = false ;
1469
-
1470
1468
if ty. is_unit ( ) {
1471
1469
// Very common fast path.
1472
1470
return None ;
@@ -1484,27 +1482,19 @@ pub(crate) fn notable_traits_button(
1484
1482
return None ;
1485
1483
}
1486
1484
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
1495
1491
// Two different types might have the same did,
1496
1492
// 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 ( ) ) ) ;
1508
1498
1509
1499
has_notable_trait. then ( || {
1510
1500
cx. types_with_notable_traits . borrow_mut ( ) . insert ( ty. clone ( ) ) ;
0 commit comments