@@ -2565,8 +2565,9 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
25652565 }
25662566
25672567 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 {
25702571 let shortty = shortty ( item) ;
25712572 let name = item. name . as_ref ( ) . unwrap ( ) ;
25722573
@@ -2618,16 +2619,33 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
26182619 }
26192620
26202621 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+ }
26222636 } else {
26232637 document_short ( w, item, link) ?;
26242638 Ok ( ( ) )
26252639 }
26262640 }
26272641
2642+ let traits = & cache ( ) . traits ;
2643+ let trait_ = i. trait_did ( ) . and_then ( |did| traits. get ( & did) ) ;
2644+
26282645 write ! ( w, "<div class='impl-items'>" ) ?;
26292646 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_) ?;
26312649 }
26322650
26332651 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
26452663 let assoc_link = AssocItemLink :: GotoSource ( did, & i. provided_trait_methods ) ;
26462664
26472665 doctraititem ( w, cx, trait_item, assoc_link, render_static, true ,
2648- outer_version) ?;
2666+ outer_version, None ) ?;
26492667 }
26502668 Ok ( ( ) )
26512669 }
26522670
26532671 // If we've implemented a trait, then also emit documentation for all
26542672 // 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) ?;
26592675 }
26602676 write ! ( w, "</div>" ) ?;
26612677 Ok ( ( ) )
0 commit comments