@@ -2415,7 +2415,7 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
2415
2415
write ! (
2416
2416
w,
2417
2417
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
2418
- {name}{generics}{decl}{where_clause}</pre>",
2418
+ {name}{generics}{decl}{spotlight}{ where_clause}</pre>",
2419
2419
vis = it. visibility. print_with_space( ) ,
2420
2420
constness = f. header. constness. print_with_space( ) ,
2421
2421
asyncness = f. header. asyncness. print_with_space( ) ,
@@ -2425,7 +2425,8 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
2425
2425
generics = f. generics. print( ) ,
2426
2426
where_clause = WhereClause { gens: & f. generics, indent: 0 , end_newline: true } ,
2427
2427
decl = Function { decl: & f. decl, header_len, indent: 0 , asyncness: f. header. asyncness }
2428
- . print( )
2428
+ . print( ) ,
2429
+ spotlight = spotlight_decl( & f. decl) ,
2429
2430
) ;
2430
2431
document ( w, cx, it)
2431
2432
}
@@ -2612,7 +2613,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
2612
2613
let name = m. name . as_ref ( ) . unwrap ( ) ;
2613
2614
let item_type = m. type_ ( ) ;
2614
2615
let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
2615
- write ! ( w, "<h3 id='{id}' class='method'><code>" , id = id) ;
2616
+ write ! ( w, "<h3 id='{id}' class='method'><code>" , id = id, ) ;
2616
2617
render_assoc_item ( w, m, AssocItemLink :: Anchor ( Some ( & id) ) , ItemType :: Impl ) ;
2617
2618
write ! ( w, "</code>" ) ;
2618
2619
render_stability_since ( w, m, t) ;
@@ -2926,7 +2927,7 @@ fn render_assoc_item(
2926
2927
write ! (
2927
2928
w,
2928
2929
"{}{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
2929
- {generics}{decl}{where_clause}",
2930
+ {generics}{decl}{spotlight}{ where_clause}",
2930
2931
if parent == ItemType :: Trait { " " } else { "" } ,
2931
2932
meth. visibility. print_with_space( ) ,
2932
2933
header. constness. print_with_space( ) ,
@@ -2938,6 +2939,7 @@ fn render_assoc_item(
2938
2939
name = name,
2939
2940
generics = g. print( ) ,
2940
2941
decl = Function { decl: d, header_len, indent, asyncness: header. asyncness } . print( ) ,
2942
+ spotlight = spotlight_decl( & d) ,
2941
2943
where_clause = WhereClause { gens: g, indent, end_newline }
2942
2944
)
2943
2945
}
@@ -3559,6 +3561,62 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
3559
3561
}
3560
3562
}
3561
3563
3564
+ fn spotlight_decl ( decl : & clean:: FnDecl ) -> String {
3565
+ let mut out = Buffer :: html ( ) ;
3566
+ let mut trait_ = String :: new ( ) ;
3567
+
3568
+ if let Some ( did) = decl. output . def_id ( ) {
3569
+ let c = cache ( ) ;
3570
+ if let Some ( impls) = c. impls . get ( & did) {
3571
+ for i in impls {
3572
+ let impl_ = i. inner_impl ( ) ;
3573
+ if impl_. trait_ . def_id ( ) . map_or ( false , |d| c. traits [ & d] . is_spotlight ) {
3574
+ if out. is_empty ( ) {
3575
+ out. push_str ( & format ! (
3576
+ "<h3 class=\" important\" >Important traits for {}</h3>\
3577
+ <code class=\" content\" >",
3578
+ impl_. for_. print( )
3579
+ ) ) ;
3580
+ trait_. push_str ( & impl_. for_ . print ( ) . to_string ( ) ) ;
3581
+ }
3582
+
3583
+ //use the "where" class here to make it small
3584
+ out. push_str ( & format ! (
3585
+ "<span class=\" where fmt-newline\" >{}</span>" ,
3586
+ impl_. print( )
3587
+ ) ) ;
3588
+ let t_did = impl_. trait_ . def_id ( ) . unwrap ( ) ;
3589
+ for it in & impl_. items {
3590
+ if let clean:: TypedefItem ( ref tydef, _) = it. inner {
3591
+ out. push_str ( "<span class=\" where fmt-newline\" > " ) ;
3592
+ assoc_type (
3593
+ & mut out,
3594
+ it,
3595
+ & [ ] ,
3596
+ Some ( & tydef. type_ ) ,
3597
+ AssocItemLink :: GotoSource ( t_did, & FxHashSet :: default ( ) ) ,
3598
+ "" ,
3599
+ ) ;
3600
+ out. push_str ( ";</span>" ) ;
3601
+ }
3602
+ }
3603
+ }
3604
+ }
3605
+ }
3606
+ }
3607
+
3608
+ if !out. is_empty ( ) {
3609
+ out. insert_str (
3610
+ 0 ,
3611
+ "<span class=\" important-traits\" ><span class=\" important-traits-tooltip\" >ⓘ<div class='important-traits-tooltiptext'><span class=\" docblock\" >"
3612
+
3613
+ ) ;
3614
+ out. push_str ( "</code></span></div></span></span>" ) ;
3615
+ }
3616
+
3617
+ out. into_inner ( )
3618
+ }
3619
+
3562
3620
fn render_impl (
3563
3621
w : & mut Buffer ,
3564
3622
cx : & Context ,
@@ -3670,7 +3728,8 @@ fn render_impl(
3670
3728
// Only render when the method is not static or we allow static methods
3671
3729
if render_method_item {
3672
3730
let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
3673
- write ! ( w, "<h4 id='{}' class=\" {}{}\" ><code>" , id, item_type, extra_class) ;
3731
+ write ! ( w, "<h4 id='{}' class=\" {}{}\" >" , id, item_type, extra_class) ;
3732
+ write ! ( w, "<code>" ) ;
3674
3733
render_assoc_item ( w, item, link. anchor ( & id) , ItemType :: Impl ) ;
3675
3734
write ! ( w, "</code>" ) ;
3676
3735
render_stability_since_raw ( w, item. stable_since ( ) , outer_version) ;
0 commit comments