Skip to content

Commit

Permalink
rustdoc: Show where clauses in type aliases
Browse files Browse the repository at this point in the history
Yes, it's allowed. Example:

    type MapFn<I, B> where I: Iterator = Map<I, fn(I::Item) -> B>;

Fixes #25769
  • Loading branch information
Ulrik Sverdrup committed May 25, 2015
1 parent d1cd689 commit 06304ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustdoc/html/render.rs
Expand Up @@ -2429,10 +2429,11 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,

fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
t: &clean::Typedef) -> fmt::Result {
try!(write!(w, "<pre class='rust typedef'>type {}{} = {};</pre>",
try!(write!(w, "<pre class='rust typedef'>type {}{}{where_clause} = {type_};</pre>",
it.name.as_ref().unwrap(),
t.generics,
t.type_));
where_clause = WhereClause(&t.generics),
type_ = t.type_));

document(w, it)
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc/where.rs
Expand Up @@ -42,3 +42,7 @@ pub enum Foxtrot<F> { Foxtrot1(F) }
// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
// "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
impl<F> MyTrait for Foxtrot<F> where F: MyTrait {}

// @has foo/type.Golf.html '//pre[@class="rust typedef"]' \
// "type Golf<T> where T: Clone = (T, T)"
pub type Golf<T> where T: Clone = (T, T);

0 comments on commit 06304ed

Please sign in to comment.