Use render_impl_summary when rendering traits.
This commit is contained in:
parent
ce6472987d
commit
bff4f073c8
2 changed files with 29 additions and 43 deletions
|
@ -1542,15 +1542,10 @@ fn render_impl(
|
|||
}
|
||||
}
|
||||
if render_mode == RenderMode::Normal {
|
||||
let on_trait_page = matches!(*parent.kind, clean::ItemKind::TraitItem(_));
|
||||
let has_impl_items = !(impl_items.is_empty() && default_impl_items.is_empty());
|
||||
let toggled = !on_trait_page && has_impl_items;
|
||||
let is_implementing_trait = i.inner_impl().trait_.is_some();
|
||||
let toggled = !(impl_items.is_empty() && default_impl_items.is_empty());
|
||||
if toggled {
|
||||
close_tags.insert_str(0, "</details>");
|
||||
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\" open>");
|
||||
}
|
||||
if toggled {
|
||||
write!(w, "<summary>")
|
||||
}
|
||||
render_impl_summary(
|
||||
|
@ -1573,23 +1568,21 @@ fn render_impl(
|
|||
}
|
||||
}
|
||||
|
||||
if !on_trait_page {
|
||||
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
|
||||
let mut ids = cx.id_map.borrow_mut();
|
||||
write!(
|
||||
w,
|
||||
"<div class=\"docblock\">{}</div>",
|
||||
Markdown(
|
||||
&*dox,
|
||||
&i.impl_item.links(cx),
|
||||
&mut ids,
|
||||
cx.shared.codes,
|
||||
cx.shared.edition(),
|
||||
&cx.shared.playground
|
||||
)
|
||||
.into_string()
|
||||
);
|
||||
}
|
||||
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
|
||||
let mut ids = cx.id_map.borrow_mut();
|
||||
write!(
|
||||
w,
|
||||
"<div class=\"docblock\">{}</div>",
|
||||
Markdown(
|
||||
&*dox,
|
||||
&i.impl_item.links(cx),
|
||||
&mut ids,
|
||||
cx.shared.codes,
|
||||
cx.shared.edition(),
|
||||
&cx.shared.playground
|
||||
)
|
||||
.into_string()
|
||||
);
|
||||
}
|
||||
}
|
||||
if !default_impl_items.is_empty() || !impl_items.is_empty() {
|
||||
|
@ -1601,7 +1594,7 @@ fn render_impl(
|
|||
w.write_str(&close_tags);
|
||||
}
|
||||
|
||||
fn render_impl_summary(
|
||||
pub(crate) fn render_impl_summary(
|
||||
w: &mut Buffer,
|
||||
cx: &Context<'_>,
|
||||
i: &Impl,
|
||||
|
|
|
@ -15,11 +15,11 @@ use rustc_span::symbol::{kw, sym, Symbol};
|
|||
use super::{
|
||||
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl,
|
||||
render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre,
|
||||
render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context,
|
||||
render_impl_summary, render_stability_since_raw, write_srclink, AssocItemLink, Context,
|
||||
};
|
||||
use crate::clean::{self, GetDefId};
|
||||
use crate::formats::item_type::ItemType;
|
||||
use crate::formats::{AssocItemRender, Impl, RenderMode};
|
||||
use crate::formats::{AssocItemRender, Impl};
|
||||
use crate::html::escape::Escape;
|
||||
use crate::html::format::{print_abi_with_space, print_where_clause, Buffer, PrintWithSpace};
|
||||
use crate::html::highlight;
|
||||
|
@ -691,22 +691,17 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
|||
write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", "");
|
||||
|
||||
for implementor in foreign {
|
||||
let provided_methods = implementor.inner_impl().provided_trait_methods(cx.tcx());
|
||||
let assoc_link =
|
||||
AssocItemLink::GotoSource(implementor.impl_item.def_id, &provided_methods);
|
||||
render_impl(
|
||||
let outer_version = implementor.impl_item.stable_since(cx.tcx());
|
||||
let outer_const_version = implementor.impl_item.const_stable_since(cx.tcx());
|
||||
render_impl_summary(
|
||||
w,
|
||||
cx,
|
||||
&implementor,
|
||||
it,
|
||||
assoc_link,
|
||||
RenderMode::Normal,
|
||||
implementor.impl_item.stable_since(cx.tcx()).as_deref(),
|
||||
implementor.impl_item.const_stable_since(cx.tcx()).as_deref(),
|
||||
outer_version.as_deref(),
|
||||
outer_const_version.as_deref(),
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
false,
|
||||
&[],
|
||||
);
|
||||
}
|
||||
|
@ -1320,19 +1315,17 @@ fn render_implementor(
|
|||
} => implementor_dups[&path.last()].1,
|
||||
_ => false,
|
||||
};
|
||||
render_impl(
|
||||
let outer_version = trait_.stable_since(cx.tcx());
|
||||
let outer_const_version = trait_.const_stable_since(cx.tcx());
|
||||
render_impl_summary(
|
||||
w,
|
||||
cx,
|
||||
implementor,
|
||||
trait_,
|
||||
AssocItemLink::Anchor(None),
|
||||
RenderMode::Normal,
|
||||
trait_.stable_since(cx.tcx()).as_deref(),
|
||||
trait_.const_stable_since(cx.tcx()).as_deref(),
|
||||
outer_version.as_deref(),
|
||||
outer_const_version.as_deref(),
|
||||
false,
|
||||
Some(use_absolute),
|
||||
false,
|
||||
false,
|
||||
aliases,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue