]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Show where clauses in type aliases
authorUlrik Sverdrup <root@localhost>
Mon, 25 May 2015 21:05:35 +0000 (23:05 +0200)
committerUlrik Sverdrup <root@localhost>
Mon, 25 May 2015 21:10:36 +0000 (23:10 +0200)
Yes, it's allowed. Example:

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

Fixes #25769

src/librustdoc/html/render.rs
src/test/rustdoc/where.rs

index d82602c9bd0744f3cf9e532805b132107ab1487d..65652a4d9c366f243a6a520710278bde1260c43f 100644 (file)
@@ -2429,10 +2429,11 @@ fn render_default_items(w: &mut fmt::Formatter,
 
 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)
 }
index 3ce91d63300074e66943dfbbc92f4abfad9df1bb..91ec69d9a3cbbdbeaaff4adcd705862997122097 100644 (file)
@@ -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);