Skip to content

Commit

Permalink
Fix rendering on sidebar and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 15, 2020
1 parent d755238 commit 8a9b951
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/librustdoc/html/render.rs
Expand Up @@ -4126,14 +4126,14 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
.filter(|i| i.inner_impl().trait_.is_some())
.find(|i| i.inner_impl().trait_.def_id() == c.deref_trait_did)
{
if let Some(target) = impl_
if let Some((target, real_target)) = impl_
.inner_impl()
.items
.iter()
.filter_map(|item| match item.inner {
clean::TypedefItem(ref t, true) => Some(match *t {
clean::Typedef { item_type: Some(ref type_), .. } => type_,
_ => &t.type_,
clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
_ => (&t.type_, &t.type_),
}),
_ => None,
})
Expand All @@ -4153,7 +4153,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
"{:#}",
impl_.inner_impl().trait_.as_ref().unwrap().print()
)),
Escape(&format!("{:#}", target.print()))
Escape(&format!("{:#}", real_target.print()))
));
out.push_str("</a>");
let mut ret = impls
Expand Down
28 changes: 21 additions & 7 deletions src/test/rustdoc/deref-typedef.rs
@@ -1,19 +1,33 @@
#![crate_name = "foo"]

// @has 'foo/struct.Bar.html'
// @has '-' '//*[@id="deref-methods"]' 'Methods from Deref<Target = FooB>'
// @has '-' '//*[@class="impl-items"]//*[@id="method.happy"]' 'pub fn happy(&self)'
// @has '-' '//*[@class="sidebar-title"]' 'Methods from Deref<Target=FooB>'
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.happy"]' 'happy'
// @has '-' '//*[@id="deref-methods"]' 'Methods from Deref<Target = FooC>'
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_a"]' 'pub fn foo_a(&self)'
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)'
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)'
// @has '-' '//*[@class="sidebar-title"]' 'Methods from Deref<Target=FooC>'
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_a"]' 'foo_a'
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_b"]' 'foo_b'
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_c"]' 'foo_c'

pub struct FooA;
pub type FooB = FooA;
pub type FooC = FooB;

impl FooA {
pub fn happy(&self) {}
pub fn foo_a(&self) {}
}

impl FooB {
pub fn foo_b(&self) {}
}

impl FooC {
pub fn foo_c(&self) {}
}

pub struct Bar;
impl std::ops::Deref for Bar {
type Target = FooB;
fn deref(&self) -> &FooB { unimplemented!() }
type Target = FooC;
fn deref(&self) -> &Self::Target { unimplemented!() }
}

0 comments on commit 8a9b951

Please sign in to comment.