@@ -2410,7 +2410,7 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
2410
2410
f. generics. print( )
2411
2411
)
2412
2412
. len ( ) ;
2413
- write ! ( w, "<pre class='rust fn'>" ) ;
2413
+ write ! ( w, "{} <pre class='rust fn'>" , render_spotlight_traits ( it ) ) ;
2414
2414
render_attributes ( w, it, false ) ;
2415
2415
write ! (
2416
2416
w,
@@ -2612,7 +2612,12 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
2612
2612
let name = m. name . as_ref ( ) . unwrap ( ) ;
2613
2613
let item_type = m. type_ ( ) ;
2614
2614
let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
2615
- write ! ( w, "<h3 id='{id}' class='method'><code>" , id = id) ;
2615
+ write ! (
2616
+ w,
2617
+ "<h3 id='{id}' class='method'>{extra}<code>" ,
2618
+ extra = render_spotlight_traits( m) ,
2619
+ id = id
2620
+ ) ;
2616
2621
render_assoc_item ( w, m, AssocItemLink :: Anchor ( Some ( & id) ) , ItemType :: Impl ) ;
2617
2622
write ! ( w, "</code>" ) ;
2618
2623
render_stability_since ( w, m, t) ;
@@ -3559,6 +3564,76 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
3559
3564
}
3560
3565
}
3561
3566
3567
+ fn render_spotlight_traits ( item : & clean:: Item ) -> String {
3568
+ match item. inner {
3569
+ clean:: FunctionItem ( clean:: Function { ref decl, .. } )
3570
+ | clean:: TyMethodItem ( clean:: TyMethod { ref decl, .. } )
3571
+ | clean:: MethodItem ( clean:: Method { ref decl, .. } )
3572
+ | clean:: ForeignFunctionItem ( clean:: Function { ref decl, .. } ) => spotlight_decl ( decl) ,
3573
+ _ => String :: new ( ) ,
3574
+ }
3575
+ }
3576
+
3577
+ fn spotlight_decl ( decl : & clean:: FnDecl ) -> String {
3578
+ let mut out = Buffer :: html ( ) ;
3579
+ let mut trait_ = String :: new ( ) ;
3580
+
3581
+ if let Some ( did) = decl. output . def_id ( ) {
3582
+ let c = cache ( ) ;
3583
+ if let Some ( impls) = c. impls . get ( & did) {
3584
+ for i in impls {
3585
+ let impl_ = i. inner_impl ( ) ;
3586
+ if impl_. trait_ . def_id ( ) . map_or ( false , |d| c. traits [ & d] . is_spotlight ) {
3587
+ if out. is_empty ( ) {
3588
+ out. push_str ( & format ! (
3589
+ "<h3 class=\" important\" >Important traits for {}</h3>\
3590
+ <code class=\" content\" >",
3591
+ impl_. for_. print( )
3592
+ ) ) ;
3593
+ trait_. push_str ( & impl_. for_ . print ( ) . to_string ( ) ) ;
3594
+ }
3595
+
3596
+ //use the "where" class here to make it small
3597
+ out. push_str ( & format ! (
3598
+ "<span class=\" where fmt-newline\" >{}</span>" ,
3599
+ impl_. print( )
3600
+ ) ) ;
3601
+ let t_did = impl_. trait_ . def_id ( ) . unwrap ( ) ;
3602
+ for it in & impl_. items {
3603
+ if let clean:: TypedefItem ( ref tydef, _) = it. inner {
3604
+ out. push_str ( "<span class=\" where fmt-newline\" > " ) ;
3605
+ assoc_type (
3606
+ & mut out,
3607
+ it,
3608
+ & [ ] ,
3609
+ Some ( & tydef. type_ ) ,
3610
+ AssocItemLink :: GotoSource ( t_did, & FxHashSet :: default ( ) ) ,
3611
+ "" ,
3612
+ ) ;
3613
+ out. push_str ( ";</span>" ) ;
3614
+ }
3615
+ }
3616
+ }
3617
+ }
3618
+ }
3619
+ }
3620
+
3621
+ if !out. is_empty ( ) {
3622
+ out. insert_str (
3623
+ 0 ,
3624
+ & format ! (
3625
+ "<div class=\" important-traits\" ><div class='tooltip'>ⓘ\
3626
+ <span class='tooltiptext'>Important traits for {}</span></div>\
3627
+ <div class=\" content hidden\" >",
3628
+ trait_
3629
+ ) ,
3630
+ ) ;
3631
+ out. push_str ( "</code></div></div>" ) ;
3632
+ }
3633
+
3634
+ out. into_inner ( )
3635
+ }
3636
+
3562
3637
fn render_impl (
3563
3638
w : & mut Buffer ,
3564
3639
cx : & Context ,
@@ -3665,12 +3740,14 @@ fn render_impl(
3665
3740
( true , " hidden" )
3666
3741
} ;
3667
3742
match item. inner {
3668
- clean:: MethodItem ( clean:: Method { .. } )
3669
- | clean:: TyMethodItem ( clean:: TyMethod { .. } ) => {
3743
+ clean:: MethodItem ( clean:: Method { ref decl , .. } )
3744
+ | clean:: TyMethodItem ( clean:: TyMethod { ref decl , .. } ) => {
3670
3745
// Only render when the method is not static or we allow static methods
3671
3746
if render_method_item {
3672
3747
let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
3673
- write ! ( w, "<h4 id='{}' class=\" {}{}\" ><code>" , id, item_type, extra_class) ;
3748
+ write ! ( w, "<h4 id='{}' class=\" {}{}\" >" , id, item_type, extra_class) ;
3749
+ write ! ( w, "{}" , spotlight_decl( decl) ) ;
3750
+ write ! ( w, "<code>" ) ;
3674
3751
render_assoc_item ( w, item, link. anchor ( & id) , ItemType :: Impl ) ;
3675
3752
write ! ( w, "</code>" ) ;
3676
3753
render_stability_since_raw ( w, item. stable_since ( ) , outer_version) ;
0 commit comments