@@ -2384,7 +2384,7 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
23842384 f. generics. print( )
23852385 )
23862386 . len ( ) ;
2387- write ! ( w, "<pre class='rust fn'>" ) ;
2387+ write ! ( w, "{} <pre class='rust fn'>" , render_spotlight_traits ( it ) ) ;
23882388 render_attributes ( w, it, false ) ;
23892389 write ! (
23902390 w,
@@ -2587,7 +2587,13 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
25872587 let item_type = m. type_ ( ) ;
25882588 let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
25892589 let ns_id = cx. derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
2590- write ! ( w, "<h3 id='{id}' class='method'><code id='{ns_id}'>" , id = id, ns_id = ns_id) ;
2590+ write ! (
2591+ w,
2592+ "<h3 id='{id}' class='method'>{extra}<code id='{ns_id}'>" ,
2593+ extra = render_spotlight_traits( m) ,
2594+ id = id,
2595+ ns_id = ns_id
2596+ ) ;
25912597 render_assoc_item ( w, m, AssocItemLink :: Anchor ( Some ( & id) ) , ItemType :: Impl ) ;
25922598 write ! ( w, "</code>" ) ;
25932599 render_stability_since ( w, m, t) ;
@@ -3550,6 +3556,76 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
35503556 }
35513557}
35523558
3559+ fn render_spotlight_traits ( item : & clean:: Item ) -> String {
3560+ match item. inner {
3561+ clean:: FunctionItem ( clean:: Function { ref decl, .. } )
3562+ | clean:: TyMethodItem ( clean:: TyMethod { ref decl, .. } )
3563+ | clean:: MethodItem ( clean:: Method { ref decl, .. } )
3564+ | clean:: ForeignFunctionItem ( clean:: Function { ref decl, .. } ) => spotlight_decl ( decl) ,
3565+ _ => String :: new ( ) ,
3566+ }
3567+ }
3568+
3569+ fn spotlight_decl ( decl : & clean:: FnDecl ) -> String {
3570+ let mut out = Buffer :: html ( ) ;
3571+ let mut trait_ = String :: new ( ) ;
3572+
3573+ if let Some ( did) = decl. output . def_id ( ) {
3574+ let c = cache ( ) ;
3575+ if let Some ( impls) = c. impls . get ( & did) {
3576+ for i in impls {
3577+ let impl_ = i. inner_impl ( ) ;
3578+ if impl_. trait_ . def_id ( ) . map_or ( false , |d| c. traits [ & d] . is_spotlight ) {
3579+ if out. is_empty ( ) {
3580+ out. push_str ( & format ! (
3581+ "<h3 class=\" important\" >Important traits for {}</h3>\
3582+ <code class=\" content\" >",
3583+ impl_. for_. print( )
3584+ ) ) ;
3585+ trait_. push_str ( & impl_. for_ . print ( ) . to_string ( ) ) ;
3586+ }
3587+
3588+ //use the "where" class here to make it small
3589+ out. push_str ( & format ! (
3590+ "<span class=\" where fmt-newline\" >{}</span>" ,
3591+ impl_. print( )
3592+ ) ) ;
3593+ let t_did = impl_. trait_ . def_id ( ) . unwrap ( ) ;
3594+ for it in & impl_. items {
3595+ if let clean:: TypedefItem ( ref tydef, _) = it. inner {
3596+ out. push_str ( "<span class=\" where fmt-newline\" > " ) ;
3597+ assoc_type (
3598+ & mut out,
3599+ it,
3600+ & [ ] ,
3601+ Some ( & tydef. type_ ) ,
3602+ AssocItemLink :: GotoSource ( t_did, & FxHashSet :: default ( ) ) ,
3603+ "" ,
3604+ ) ;
3605+ out. push_str ( ";</span>" ) ;
3606+ }
3607+ }
3608+ }
3609+ }
3610+ }
3611+ }
3612+
3613+ if !out. is_empty ( ) {
3614+ out. insert_str (
3615+ 0 ,
3616+ & format ! (
3617+ "<div class=\" important-traits\" ><div class='tooltip'>ⓘ\
3618+ <span class='tooltiptext'>Important traits for {}</span></div>\
3619+ <div class=\" content hidden\" >",
3620+ trait_
3621+ ) ,
3622+ ) ;
3623+ out. push_str ( "</code></div></div>" ) ;
3624+ }
3625+
3626+ out. into_inner ( )
3627+ }
3628+
35533629fn render_impl (
35543630 w : & mut Buffer ,
35553631 cx : & Context ,
@@ -3656,13 +3732,14 @@ fn render_impl(
36563732 ( true , " hidden" )
36573733 } ;
36583734 match item. inner {
3659- clean:: MethodItem ( clean:: Method { .. } )
3660- | clean:: TyMethodItem ( clean:: TyMethod { .. } ) => {
3735+ clean:: MethodItem ( clean:: Method { ref decl , .. } )
3736+ | clean:: TyMethodItem ( clean:: TyMethod { ref decl , .. } ) => {
36613737 // Only render when the method is not static or we allow static methods
36623738 if render_method_item {
36633739 let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
36643740 let ns_id = cx. derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
36653741 write ! ( w, "<h4 id='{}' class=\" {}{}\" >" , id, item_type, extra_class) ;
3742+ write ! ( w, "{}" , spotlight_decl( decl) ) ;
36663743 write ! ( w, "<code id='{}'>" , ns_id) ;
36673744 render_assoc_item ( w, item, link. anchor ( & id) , ItemType :: Impl ) ;
36683745 write ! ( w, "</code>" ) ;
0 commit comments