Skip to content

Commit d555772

Browse files
emberianJorge Aparicio
authored and
Jorge Aparicio
committed
rustdoc: fix rendering of associated types
1 parent cc5ecaf commit d555772

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/librustdoc/html/render.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,18 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
18111811
Ok(())
18121812
}
18131813

1814+
fn assoc_type(w: &mut fmt::Formatter, it: &clean::Item,
1815+
typ: &clean::TyParam) -> fmt::Result {
1816+
try!(write!(w, "type {}", it.name.as_ref().unwrap()));
1817+
if typ.bounds.len() > 0 {
1818+
try!(write!(w, ": {}", TyParamBounds(&*typ.bounds)))
1819+
}
1820+
if let Some(ref default) = typ.default {
1821+
try!(write!(w, " = {}", default));
1822+
}
1823+
Ok(())
1824+
}
1825+
18141826
fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
18151827
fn method(w: &mut fmt::Formatter, it: &clean::Item, unsafety: ast::Unsafety,
18161828
g: &clean::Generics, selfty: &clean::SelfTy,
@@ -1827,17 +1839,6 @@ fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
18271839
decl = Method(selfty, d),
18281840
where_clause = WhereClause(g))
18291841
}
1830-
fn assoc_type(w: &mut fmt::Formatter, it: &clean::Item,
1831-
typ: &clean::TyParam) -> fmt::Result {
1832-
try!(write!(w, "type {}", it.name.as_ref().unwrap()));
1833-
if typ.bounds.len() > 0 {
1834-
try!(write!(w, ": {}", TyParamBounds(&*typ.bounds)))
1835-
}
1836-
if let Some(ref default) = typ.default {
1837-
try!(write!(w, " = {}", default));
1838-
}
1839-
Ok(())
1840-
}
18411842
match meth.inner {
18421843
clean::TyMethodItem(ref m) => {
18431844
method(w, meth, m.unsafety, &m.generics, &m.self_, &m.decl)
@@ -2122,6 +2123,15 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result {
21222123
try!(write!(w, "type {} = {}", name, tydef.type_));
21232124
try!(write!(w, "</code></h4>\n"));
21242125
}
2126+
clean::AssociatedTypeItem(ref typaram) => {
2127+
let name = item.name.as_ref().unwrap();
2128+
try!(write!(w, "<h4 id='assoc_type.{}' class='{}'>{}<code>",
2129+
*name,
2130+
shortty(item),
2131+
ConciseStability(&item.stability)));
2132+
try!(assoc_type(w, item, typaram));
2133+
try!(write!(w, "</code></h4>\n"));
2134+
}
21252135
_ => panic!("can't make docs for trait item with name {}", item.name)
21262136
}
21272137
match item.doc_value() {

0 commit comments

Comments
 (0)