Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,13 +1960,19 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
.filter(|i| i.inner_impl().trait_.is_some())
.find(|i| i.inner_impl().trait_.def_id_full(cache) == cx.cache.deref_trait_did)
{
sidebar_deref_methods(cx, out, impl_, v);
sidebar_deref_methods(cx, out, impl_, v, FxHashSet::default());
}
}
}
}

fn sidebar_deref_methods(cx: &Context<'_>, out: &mut Buffer, impl_: &Impl, v: &Vec<Impl>) {
fn sidebar_deref_methods(
cx: &Context<'_>,
out: &mut Buffer,
impl_: &Impl,
v: &Vec<Impl>,
mut already_seen: FxHashSet<DefId>,
) {
let c = cx.cache();

debug!("found Deref: {:?}", impl_);
Expand Down Expand Up @@ -2032,7 +2038,15 @@ fn sidebar_deref_methods(cx: &Context<'_>, out: &mut Buffer, impl_: &Impl, v: &V
.filter(|i| i.inner_impl().trait_.is_some())
.find(|i| i.inner_impl().trait_.def_id_full(c) == c.deref_trait_did)
{
sidebar_deref_methods(cx, out, target_deref_impl, target_impls);
if already_seen.insert(target_did.clone()) {
sidebar_deref_methods(
cx,
out,
target_deref_impl,
target_impls,
already_seen,
);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please instead just remove this whole block, rustdoc no longer renders recursive Deref after #84867 and removing the block should fix #85037. Please add a test for that issue too.

}
Expand Down
22 changes: 22 additions & 0 deletions src/test/rustdoc/issue-85095.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use std::ops::Deref;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give this file a descriptive name instead of the issue number? "recursive-deref" or something is fine.


pub struct A;
pub struct B;

// @has issue_85095/struct.A.html '//code' 'impl Deref for A'
impl Deref for A {
type Target = B;

fn deref(&self) -> &Self::Target {
panic!()
}
}

// @has issue_85095/struct.B.html '//code' 'impl Deref for B'
impl Deref for B {
type Target = A;

fn deref(&self) -> &Self::Target {
panic!()
}
}