about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-07 17:18:59 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-07 17:18:59 -0800
commita204dc56c97f35632575b1baa008f2e069b1bed9 (patch)
treeb55c302f46d0adb457d3ce2f250bc0b1209d0996 /src/librustdoc
parenta6bf7676a545f72cef2e3d042b6d0409f295693a (diff)
parent9851b4fbbf327bb1baab3182ce92970d4db22c6c (diff)
downloadrust-a204dc56c97f35632575b1baa008f2e069b1bed9.tar.gz
rust-a204dc56c97f35632575b1baa008f2e069b1bed9.zip
rollup merge of #20722: alexcrichton/audit-show
Conflicts:
	src/libcollections/vec.rs
	src/libcore/fmt/mod.rs
	src/librustdoc/html/format.rs
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/html/format.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index c7ec687bc1a..b3cef19e567 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -51,6 +51,8 @@ pub struct ConciseStability<'a>(pub &'a Option<clean::Stability>);
 pub struct WhereClause<'a>(pub &'a clean::Generics);
 /// Wrapper struct for emitting type parameter bounds.
 pub struct TyParamBounds<'a>(pub &'a [clean::TyParamBound]);
+/// Wrapper struct for emitting a comma-separated list of items
+pub struct CommaSep<'a, T: 'a>(pub &'a [T]);
 
 impl VisSpace {
     pub fn get(&self) -> Option<ast::Visibility> {
@@ -64,6 +66,16 @@ impl UnsafetySpace {
     }
 }
 
+impl<'a, T: fmt::String> fmt::String for CommaSep<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        for (i, item) in self.0.iter().enumerate() {
+            if i != 0 { try!(write!(f, ", ")); }
+            try!(write!(f, "{}", item));
+        }
+        Ok(())
+    }
+}
+
 impl<'a> fmt::String for TyParamBounds<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let &TyParamBounds(bounds) = self;
@@ -450,7 +462,8 @@ impl fmt::String for clean::Type {
                        lifetimes = if decl.lifetimes.len() == 0 {
                            "".to_string()
                        } else {
-                           format!("for &lt;{:#}&gt;", decl.lifetimes)
+                           format!("for &lt;{}&gt;",
+                                   CommaSep(decl.lifetimes.as_slice()))
                        },
                        args = decl.decl.inputs,
                        arrow = decl.decl.output,
@@ -482,7 +495,8 @@ impl fmt::String for clean::Type {
                        lifetimes = if decl.lifetimes.len() == 0 {
                            "".to_string()
                        } else {
-                           format!("for &lt;{:#}&gt;", decl.lifetimes)
+                           format!("for &lt;{}&gt;",
+                                   CommaSep(decl.lifetimes.as_slice()))
                        },
                        args = decl.decl.inputs,
                        bounds = if decl.bounds.len() == 0 {
@@ -512,7 +526,8 @@ impl fmt::String for clean::Type {
                 primitive_link(f, clean::PrimitiveTuple,
                                match typs.as_slice() {
                                     [ref one] => format!("({},)", one),
-                                    many => format!("({:#})", many)
+                                    many => format!("({})",
+                                                    CommaSep(many.as_slice()))
                                }.as_slice())
             }
             clean::Vector(ref t) => {