Add flag for whether an item is default or not.
We don't want to render default item docs but previously `doctraititem` naively delegated to the trait definition in those cases. Updated tests to also check that this doesn't strip default item docs from the trait definition.
This commit is contained in:
parent
d95ca2822c
commit
ec5e0f81cf
@ -2489,7 +2489,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
}
|
||||
|
||||
fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
|
||||
link: AssocItemLink, render_static: bool,
|
||||
link: AssocItemLink, render_static: bool, is_default_item: bool,
|
||||
outer_version: Option<&str>) -> fmt::Result {
|
||||
let shortty = shortty(item);
|
||||
let name = item.name.as_ref().unwrap();
|
||||
@ -2540,7 +2540,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
_ => panic!("can't make docs for trait item with name {:?}", item.name)
|
||||
}
|
||||
|
||||
if !is_static || render_static {
|
||||
if !is_default_item && (!is_static || render_static) {
|
||||
document(w, cx, item)
|
||||
} else {
|
||||
Ok(())
|
||||
@ -2549,7 +2549,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
|
||||
write!(w, "<div class='impl-items'>")?;
|
||||
for trait_item in &i.impl_.items {
|
||||
doctraititem(w, cx, trait_item, link, render_header, outer_version)?;
|
||||
doctraititem(w, cx, trait_item, link, render_header, false, outer_version)?;
|
||||
}
|
||||
|
||||
fn render_default_items(w: &mut fmt::Formatter,
|
||||
@ -2566,7 +2566,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
let did = i.trait_.as_ref().unwrap().def_id().unwrap();
|
||||
let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
|
||||
|
||||
doctraititem(w, cx, trait_item, assoc_link, render_static,
|
||||
doctraititem(w, cx, trait_item, assoc_link, render_static, true,
|
||||
outer_version)?;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -8,6 +8,10 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// @has manual_impl/trait.T.html
|
||||
// @has - '//*[@class="docblock"]' 'Docs associated with the trait definition.'
|
||||
// @has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
|
||||
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
|
||||
/// Docs associated with the trait definition.
|
||||
pub trait T {
|
||||
/// Docs associated with the trait a_method definition.
|
||||
|
Loading…
Reference in New Issue
Block a user