about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrik Sverdrup <root@localhost>2015-05-25 23:05:35 +0200
committerUlrik Sverdrup <root@localhost>2015-05-25 23:10:36 +0200
commit06304ed52201ea0cae7a09f2546123c78a60a193 (patch)
treea1da93eb2c1e56f183a6e2f44da71e903bd5014a
parentd1cd689b4867e915e42264175d54c45f22180206 (diff)
downloadrust-06304ed52201ea0cae7a09f2546123c78a60a193.tar.gz
rust-06304ed52201ea0cae7a09f2546123c78a60a193.zip
rustdoc: Show where clauses in type aliases
Yes, it's allowed. Example:

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

Fixes #25769
-rw-r--r--src/librustdoc/html/render.rs5
-rw-r--r--src/test/rustdoc/where.rs4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index d82602c9bd0..65652a4d9c3 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -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)
 }
diff --git a/src/test/rustdoc/where.rs b/src/test/rustdoc/where.rs
index 3ce91d63300..91ec69d9a3c 100644
--- a/src/test/rustdoc/where.rs
+++ b/src/test/rustdoc/where.rs
@@ -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);