Skip to content

Commit 8a9b951

Browse files
Fix rendering on sidebar and update tests
1 parent d755238 commit 8a9b951

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/librustdoc/html/render.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4126,14 +4126,14 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
41264126
.filter(|i| i.inner_impl().trait_.is_some())
41274127
.find(|i| i.inner_impl().trait_.def_id() == c.deref_trait_did)
41284128
{
4129-
if let Some(target) = impl_
4129+
if let Some((target, real_target)) = impl_
41304130
.inner_impl()
41314131
.items
41324132
.iter()
41334133
.filter_map(|item| match item.inner {
41344134
clean::TypedefItem(ref t, true) => Some(match *t {
4135-
clean::Typedef { item_type: Some(ref type_), .. } => type_,
4136-
_ => &t.type_,
4135+
clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
4136+
_ => (&t.type_, &t.type_),
41374137
}),
41384138
_ => None,
41394139
})
@@ -4153,7 +4153,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
41534153
"{:#}",
41544154
impl_.inner_impl().trait_.as_ref().unwrap().print()
41554155
)),
4156-
Escape(&format!("{:#}", target.print()))
4156+
Escape(&format!("{:#}", real_target.print()))
41574157
));
41584158
out.push_str("</a>");
41594159
let mut ret = impls

src/test/rustdoc/deref-typedef.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
#![crate_name = "foo"]
22

33
// @has 'foo/struct.Bar.html'
4-
// @has '-' '//*[@id="deref-methods"]' 'Methods from Deref<Target = FooB>'
5-
// @has '-' '//*[@class="impl-items"]//*[@id="method.happy"]' 'pub fn happy(&self)'
6-
// @has '-' '//*[@class="sidebar-title"]' 'Methods from Deref<Target=FooB>'
7-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.happy"]' 'happy'
4+
// @has '-' '//*[@id="deref-methods"]' 'Methods from Deref<Target = FooC>'
5+
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_a"]' 'pub fn foo_a(&self)'
6+
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)'
7+
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)'
8+
// @has '-' '//*[@class="sidebar-title"]' 'Methods from Deref<Target=FooC>'
9+
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_a"]' 'foo_a'
10+
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_b"]' 'foo_b'
11+
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_c"]' 'foo_c'
12+
813
pub struct FooA;
914
pub type FooB = FooA;
15+
pub type FooC = FooB;
1016

1117
impl FooA {
12-
pub fn happy(&self) {}
18+
pub fn foo_a(&self) {}
19+
}
20+
21+
impl FooB {
22+
pub fn foo_b(&self) {}
23+
}
24+
25+
impl FooC {
26+
pub fn foo_c(&self) {}
1327
}
1428

1529
pub struct Bar;
1630
impl std::ops::Deref for Bar {
17-
type Target = FooB;
18-
fn deref(&self) -> &FooB { unimplemented!() }
31+
type Target = FooC;
32+
fn deref(&self) -> &Self::Target { unimplemented!() }
1933
}

0 commit comments

Comments
 (0)