@@ -1472,8 +1472,6 @@ pub(crate) fn notable_traits_button<'a, 'tcx>(
1472
1472
ty : & ' a clean:: Type ,
1473
1473
cx : & ' a Context < ' tcx > ,
1474
1474
) -> Option < impl fmt:: Display + ' a + Captures < ' tcx > > {
1475
- let mut has_notable_trait = false ;
1476
-
1477
1475
if ty. is_unit ( ) {
1478
1476
// Very common fast path.
1479
1477
return None ;
@@ -1491,27 +1489,19 @@ pub(crate) fn notable_traits_button<'a, 'tcx>(
1491
1489
return None ;
1492
1490
}
1493
1491
1494
- if let Some ( impls) = cx. cache ( ) . impls . get ( & did) {
1495
- for i in impls {
1496
- let impl_ = i. inner_impl ( ) ;
1497
- if impl_. polarity != ty:: ImplPolarity :: Positive {
1498
- continue ;
1499
- }
1500
-
1501
- if !ty. is_doc_subtype_of ( & impl_. for_ , cx. cache ( ) ) {
1492
+ let impls = cx. cache ( ) . impls . get ( & did) ?;
1493
+ let has_notable_trait = impls
1494
+ . iter ( )
1495
+ . map ( Impl :: inner_impl)
1496
+ . filter ( |impl_| {
1497
+ impl_. polarity == ty:: ImplPolarity :: Positive
1502
1498
// Two different types might have the same did,
1503
1499
// without actually being the same.
1504
- continue ;
1505
- }
1506
- if let Some ( trait_) = & impl_. trait_ {
1507
- let trait_did = trait_. def_id ( ) ;
1508
-
1509
- if cx. cache ( ) . traits . get ( & trait_did) . is_some_and ( |t| t. is_notable_trait ( cx. tcx ( ) ) ) {
1510
- has_notable_trait = true ;
1511
- }
1512
- }
1513
- }
1514
- }
1500
+ && ty. is_doc_subtype_of ( & impl_. for_ , cx. cache ( ) )
1501
+ } )
1502
+ . filter_map ( |impl_| impl_. trait_ . as_ref ( ) )
1503
+ . filter_map ( |trait_| cx. cache ( ) . traits . get ( & trait_. def_id ( ) ) )
1504
+ . any ( |t| t. is_notable_trait ( cx. tcx ( ) ) ) ;
1515
1505
1516
1506
has_notable_trait. then ( || {
1517
1507
cx. types_with_notable_traits . borrow_mut ( ) . insert ( ty. clone ( ) ) ;
0 commit comments