Remove temporary GetDefId
impl for Path
This commit is contained in:
parent
4128a3dc1f
commit
a83112fe3e
8 changed files with 63 additions and 93 deletions
|
@ -687,18 +687,12 @@ fn short_item_info(
|
|||
|
||||
// Render the list of items inside one of the sections "Trait Implementations",
|
||||
// "Auto Trait Implementations," "Blanket Trait Implementations" (on struct/enum pages).
|
||||
fn render_impls(
|
||||
cx: &Context<'_>,
|
||||
w: &mut Buffer,
|
||||
traits: &[&&Impl],
|
||||
containing_item: &clean::Item,
|
||||
) {
|
||||
let cache = cx.cache();
|
||||
fn render_impls(cx: &Context<'_>, w: &mut Buffer, impls: &[&&Impl], containing_item: &clean::Item) {
|
||||
let tcx = cx.tcx();
|
||||
let mut impls = traits
|
||||
let mut rendered_impls = impls
|
||||
.iter()
|
||||
.map(|i| {
|
||||
let did = i.trait_did_full(cache).unwrap();
|
||||
let did = i.trait_did().unwrap();
|
||||
let provided_trait_methods = i.inner_impl().provided_trait_methods(tcx);
|
||||
let assoc_link = AssocItemLink::GotoSource(did.into(), &provided_trait_methods);
|
||||
let mut buffer = if w.is_for_html() { Buffer::html() } else { Buffer::new() };
|
||||
|
@ -722,8 +716,8 @@ fn render_impls(
|
|||
buffer.into_inner()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
impls.sort();
|
||||
w.write_str(&impls.join(""));
|
||||
rendered_impls.sort();
|
||||
w.write_str(&rendered_impls.join(""));
|
||||
}
|
||||
|
||||
fn naive_assoc_href(it: &clean::Item, link: AssocItemLink<'_>, cx: &Context<'_>) -> String {
|
||||
|
@ -1068,13 +1062,11 @@ fn render_assoc_items(
|
|||
return;
|
||||
}
|
||||
if !traits.is_empty() {
|
||||
let deref_impl = traits.iter().find(|t| {
|
||||
t.inner_impl().trait_.def_id_full(cache) == cx.tcx().lang_items().deref_trait()
|
||||
});
|
||||
let deref_impl =
|
||||
traits.iter().find(|t| t.trait_did() == cx.tcx().lang_items().deref_trait());
|
||||
if let Some(impl_) = deref_impl {
|
||||
let has_deref_mut = traits.iter().any(|t| {
|
||||
t.inner_impl().trait_.def_id_full(cache) == cx.tcx().lang_items().deref_mut_trait()
|
||||
});
|
||||
let has_deref_mut =
|
||||
traits.iter().any(|t| t.trait_did() == cx.tcx().lang_items().deref_mut_trait());
|
||||
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut);
|
||||
}
|
||||
let (synthetic, concrete): (Vec<&&Impl>, Vec<&&Impl>) =
|
||||
|
@ -1192,45 +1184,39 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) ->
|
|||
|
||||
fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
|
||||
let mut out = Buffer::html();
|
||||
let mut trait_ = String::new();
|
||||
|
||||
if let Some(did) = decl.output.def_id_full(cx.cache()) {
|
||||
if let Some(impls) = cx.cache().impls.get(&did) {
|
||||
for i in impls {
|
||||
let impl_ = i.inner_impl();
|
||||
if impl_.trait_.def_id().map_or(false, |d| {
|
||||
cx.cache().traits.get(&d).map(|t| t.is_notable).unwrap_or(false)
|
||||
}) {
|
||||
if out.is_empty() {
|
||||
if let Some(trait_) = &impl_.trait_ {
|
||||
let trait_did = trait_.def_id();
|
||||
|
||||
if cx.cache().traits.get(&trait_did).map_or(false, |t| t.is_notable) {
|
||||
if out.is_empty() {
|
||||
write!(
|
||||
&mut out,
|
||||
"<div class=\"notable\">Notable traits for {}</div>\
|
||||
<code class=\"content\">",
|
||||
impl_.for_.print(cx)
|
||||
);
|
||||
}
|
||||
|
||||
//use the "where" class here to make it small
|
||||
write!(
|
||||
&mut out,
|
||||
"<div class=\"notable\">Notable traits for {}</div>\
|
||||
<code class=\"content\">",
|
||||
impl_.for_.print(cx)
|
||||
"<span class=\"where fmt-newline\">{}</span>",
|
||||
impl_.print(false, cx)
|
||||
);
|
||||
trait_.push_str(&impl_.for_.print(cx).to_string());
|
||||
}
|
||||
|
||||
//use the "where" class here to make it small
|
||||
write!(
|
||||
&mut out,
|
||||
"<span class=\"where fmt-newline\">{}</span>",
|
||||
impl_.print(false, cx)
|
||||
);
|
||||
let t_did = impl_.trait_.def_id_full(cx.cache()).unwrap();
|
||||
for it in &impl_.items {
|
||||
if let clean::TypedefItem(ref tydef, _) = *it.kind {
|
||||
out.push_str("<span class=\"where fmt-newline\"> ");
|
||||
assoc_type(
|
||||
&mut out,
|
||||
it,
|
||||
&[],
|
||||
Some(&tydef.type_),
|
||||
AssocItemLink::GotoSource(t_did.into(), &FxHashSet::default()),
|
||||
"",
|
||||
cx,
|
||||
);
|
||||
out.push_str(";</span>");
|
||||
for it in &impl_.items {
|
||||
if let clean::TypedefItem(ref tydef, _) = *it.kind {
|
||||
out.push_str("<span class=\"where fmt-newline\"> ");
|
||||
let empty_set = FxHashSet::default();
|
||||
let src_link =
|
||||
AssocItemLink::GotoSource(trait_did.into(), &empty_set);
|
||||
assoc_type(&mut out, it, &[], Some(&tydef.type_), src_link, "", cx);
|
||||
out.push_str(";</span>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1273,7 +1259,7 @@ fn render_impl(
|
|||
) {
|
||||
let cache = cx.cache();
|
||||
let traits = &cache.traits;
|
||||
let trait_ = i.trait_did_full(cache).map(|did| &traits[&did]);
|
||||
let trait_ = i.trait_did().map(|did| &traits[&did]);
|
||||
let mut close_tags = String::new();
|
||||
|
||||
// For trait implementations, the `interesting` output contains all methods that have doc
|
||||
|
@ -1503,7 +1489,7 @@ fn render_impl(
|
|||
if i.items.iter().any(|m| m.name == n) {
|
||||
continue;
|
||||
}
|
||||
let did = i.trait_.as_ref().unwrap().def_id_full(cx.cache()).unwrap();
|
||||
let did = i.trait_.as_ref().unwrap().def_id();
|
||||
let provided_methods = i.provided_trait_methods(cx.tcx());
|
||||
let assoc_link = AssocItemLink::GotoSource(did.into(), &provided_methods);
|
||||
|
||||
|
@ -1887,9 +1873,9 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
|
|||
}
|
||||
|
||||
if v.iter().any(|i| i.inner_impl().trait_.is_some()) {
|
||||
if let Some(impl_) = v.iter().filter(|i| i.inner_impl().trait_.is_some()).find(|i| {
|
||||
i.inner_impl().trait_.def_id_full(cache) == cx.tcx().lang_items().deref_trait()
|
||||
}) {
|
||||
if let Some(impl_) =
|
||||
v.iter().find(|i| i.trait_did() == cx.tcx().lang_items().deref_trait())
|
||||
{
|
||||
sidebar_deref_methods(cx, out, impl_, v);
|
||||
}
|
||||
|
||||
|
@ -1987,9 +1973,7 @@ fn sidebar_deref_methods(cx: &Context<'_>, out: &mut Buffer, impl_: &Impl, v: &V
|
|||
}
|
||||
}
|
||||
}
|
||||
let deref_mut = v.iter().filter(|i| i.inner_impl().trait_.is_some()).any(|i| {
|
||||
i.inner_impl().trait_.def_id_full(c) == cx.tcx().lang_items().deref_mut_trait()
|
||||
});
|
||||
let deref_mut = v.iter().any(|i| i.trait_did() == cx.tcx().lang_items().deref_mut_trait());
|
||||
let inner_impl = target
|
||||
.def_id_full(c)
|
||||
.or_else(|| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue