@@ -2565,8 +2565,9 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2565
2565
}
2566
2566
2567
2567
fn doctraititem ( w : & mut fmt:: Formatter , cx : & Context , item : & clean:: Item ,
2568
- link : AssocItemLink , render_static : bool , is_default_item : bool ,
2569
- outer_version : Option < & str > ) -> fmt:: Result {
2568
+ link : AssocItemLink , render_static : bool ,
2569
+ is_default_item : bool , outer_version : Option < & str > ,
2570
+ trait_ : Option < & clean:: Trait > ) -> fmt:: Result {
2570
2571
let shortty = shortty ( item) ;
2571
2572
let name = item. name . as_ref ( ) . unwrap ( ) ;
2572
2573
@@ -2618,16 +2619,33 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2618
2619
}
2619
2620
2620
2621
if !is_default_item && ( !is_static || render_static) {
2621
- document ( w, cx, item)
2622
+
2623
+ if item. doc_value ( ) . is_some ( ) {
2624
+ document ( w, cx, item)
2625
+ } else {
2626
+ // In case the item isn't documented,
2627
+ // provide short documentation from the trait
2628
+ if let Some ( t) = trait_ {
2629
+ if let Some ( it) = t. items . iter ( )
2630
+ . find ( |i| i. name == item. name ) {
2631
+ document_short ( w, it, link) ?;
2632
+ }
2633
+ }
2634
+ Ok ( ( ) )
2635
+ }
2622
2636
} else {
2623
2637
document_short ( w, item, link) ?;
2624
2638
Ok ( ( ) )
2625
2639
}
2626
2640
}
2627
2641
2642
+ let traits = & cache ( ) . traits ;
2643
+ let trait_ = i. trait_did ( ) . and_then ( |did| traits. get ( & did) ) ;
2644
+
2628
2645
write ! ( w, "<div class='impl-items'>" ) ?;
2629
2646
for trait_item in & i. inner_impl ( ) . items {
2630
- doctraititem ( w, cx, trait_item, link, render_header, false , outer_version) ?;
2647
+ doctraititem ( w, cx, trait_item, link, render_header,
2648
+ false , outer_version, trait_) ?;
2631
2649
}
2632
2650
2633
2651
fn render_default_items ( w : & mut fmt:: Formatter ,
@@ -2645,17 +2663,15 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2645
2663
let assoc_link = AssocItemLink :: GotoSource ( did, & i. provided_trait_methods ) ;
2646
2664
2647
2665
doctraititem ( w, cx, trait_item, assoc_link, render_static, true ,
2648
- outer_version) ?;
2666
+ outer_version, None ) ?;
2649
2667
}
2650
2668
Ok ( ( ) )
2651
2669
}
2652
2670
2653
2671
// If we've implemented a trait, then also emit documentation for all
2654
2672
// default items which weren't overridden in the implementation block.
2655
- if let Some ( did) = i. trait_did ( ) {
2656
- if let Some ( t) = cache ( ) . traits . get ( & did) {
2657
- render_default_items ( w, cx, t, & i. inner_impl ( ) , render_header, outer_version) ?;
2658
- }
2673
+ if let Some ( t) = trait_ {
2674
+ render_default_items ( w, cx, t, & i. inner_impl ( ) , render_header, outer_version) ?;
2659
2675
}
2660
2676
write ! ( w, "</div>" ) ?;
2661
2677
Ok ( ( ) )
0 commit comments