Auto merge of #84867 - pnkfelix:rustdoc-revert-deref-recur, r=jyn514
rustdoc: revert deref recur to resume inclusion of impl ExtTrait<Local> for ExtType As discussed here: https://github.com/rust-lang/rust/issues/82465#issuecomment-829290384, Revert PR #80653 to resolve issue #82465. Issue #82465 was we had stopped including certain trait implementations, namely implementations on an imported type of an imported trait *instantiated on a local type*. That bug was injected by PR #80653. Reverting #80653 means we don't list all the methods that you have accessible via recursively applying `Deref`. [Discussion in last week's rustc triage meeting](https://zulip-archive.rust-lang.org/238009tcompilermeetings/19557weekly2021042954818.html#236680594) led us to conclude that the bug was worse than the enhancement, and there was not an obvious fix for the bug itself. So for the short term we remove the enhancement, while in the long term we will work on figuring out a way to have our imported trait implementation cake and eat it too.
This commit is contained in:
commit
d74b36ea2f
8 changed files with 61 additions and 172 deletions
|
@ -1045,17 +1045,12 @@ fn render_assoc_items(
|
|||
RenderMode::Normal
|
||||
}
|
||||
AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => {
|
||||
let id =
|
||||
cx.derive_id(small_url_encode(format!("deref-methods-{:#}", type_.print(cx))));
|
||||
debug!("Adding {} to deref id map", type_.print(cx));
|
||||
cx.deref_id_map.borrow_mut().insert(type_.def_id_full(cache).unwrap(), id.clone());
|
||||
write!(
|
||||
w,
|
||||
"<h2 id=\"{id}\" class=\"small-section-header\">\
|
||||
"<h2 id=\"deref-methods\" class=\"small-section-header\">\
|
||||
Methods from {trait_}<Target = {type_}>\
|
||||
<a href=\"#{id}\" class=\"anchor\"></a>\
|
||||
<a href=\"#deref-methods\" class=\"anchor\"></a>\
|
||||
</h2>",
|
||||
id = id,
|
||||
trait_ = trait_.print(cx),
|
||||
type_ = type_.print(cx),
|
||||
);
|
||||
|
@ -1080,6 +1075,9 @@ fn render_assoc_items(
|
|||
);
|
||||
}
|
||||
}
|
||||
if let AssocItemRender::DerefFor { .. } = what {
|
||||
return;
|
||||
}
|
||||
if !traits.is_empty() {
|
||||
let deref_impl = traits
|
||||
.iter()
|
||||
|
@ -1090,13 +1088,6 @@ fn render_assoc_items(
|
|||
.any(|t| t.inner_impl().trait_.def_id_full(cache) == cx.cache.deref_mut_trait_did);
|
||||
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut);
|
||||
}
|
||||
|
||||
// If we were already one level into rendering deref methods, we don't want to render
|
||||
// anything after recursing into any further deref methods above.
|
||||
if let AssocItemRender::DerefFor { .. } = what {
|
||||
return;
|
||||
}
|
||||
|
||||
let (synthetic, concrete): (Vec<&&Impl>, Vec<&&Impl>) =
|
||||
traits.iter().partition(|t| t.inner_impl().synthetic);
|
||||
let (blanket_impl, concrete): (Vec<&&Impl>, _) =
|
||||
|
@ -2017,14 +2008,9 @@ fn sidebar_deref_methods(cx: &Context<'_>, out: &mut Buffer, impl_: &Impl, v: &V
|
|||
.flat_map(|i| get_methods(i.inner_impl(), true, &mut used_links, deref_mut, c))
|
||||
.collect::<Vec<_>>();
|
||||
if !ret.is_empty() {
|
||||
let deref_id_map = cx.deref_id_map.borrow();
|
||||
let id = deref_id_map
|
||||
.get(&real_target.def_id_full(c).unwrap())
|
||||
.expect("Deref section without derived id");
|
||||
write!(
|
||||
out,
|
||||
"<a class=\"sidebar-title\" href=\"#{}\">Methods from {}<Target={}></a>",
|
||||
id,
|
||||
"<a class=\"sidebar-title\" href=\"#deref-methods\">Methods from {}<Target={}></a>",
|
||||
Escape(&format!("{:#}", impl_.inner_impl().trait_.as_ref().unwrap().print(cx))),
|
||||
Escape(&format!("{:#}", real_target.print(cx))),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue