]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: where clause adjustment to fix tests
authorQuietMisdreavus <grey@quietmisdreavus.net>
Thu, 6 Apr 2017 19:19:45 +0000 (14:19 -0500)
committerQuietMisdreavus <grey@quietmisdreavus.net>
Thu, 6 Apr 2017 19:19:45 +0000 (14:19 -0500)
- add spaces to output so stripping lines and breaking spaces renders
  the same
- add commas to where clauses in rustdoc tests to match the new output

src/librustdoc/html/format.rs
src/librustdoc/html/render.rs
src/test/rustdoc/impl-parts.rs
src/test/rustdoc/issue-20727-4.rs
src/test/rustdoc/where.rs

index 7c1139d7135c16b191b4511f94eec9d8d4e6e237..13a31c557021ddd55690ffd80ab116c668766c3f 100644 (file)
@@ -192,9 +192,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             clause.push_str(" where");
         } else {
             if end_newline {
-                clause.push_str("<span class=\"where fmt-newline\">where");
+                clause.push_str(" <span class=\"where fmt-newline\">where");
             } else {
-                clause.push_str("<span class=\"where\">where");
+                clause.push_str(" <span class=\"where\">where");
             }
         }
         for (i, pred) in gens.where_predicates.iter().enumerate() {
@@ -241,8 +241,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             clause.push_str("</span>");
             let padding = repeat("&nbsp;").take(indent + 4).collect::<String>();
             clause = clause.replace("<br>", &format!("<br>{}", padding));
-            clause.insert_str(0, &repeat("&nbsp;").take(indent).collect::<String>());
-            if !end_newline {
+            clause.insert_str(0, &repeat("&nbsp;").take(indent.saturating_sub(1))
+                                                  .collect::<String>());
+            if end_newline {
+                clause.push(' ');
+            } else {
                 clause.insert_str(0, "<br>");
             }
         }
index b1ac6a5127f2a50cdd5507d69808647086a78458..af2beacf58acebb803d4bf2cef5aa289232398b9 100644 (file)
@@ -2710,14 +2710,14 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
             }
             write!(w, ")")?;
             if let Some(g) = g {
-                write!(w, "{}", WhereClause { gens: g, indent: 0, end_newline: true })?
+                write!(w, "{}", WhereClause { gens: g, indent: 0, end_newline: false })?
             }
             write!(w, ";")?;
         }
         doctree::Unit => {
             // Needed for PhantomData.
             if let Some(g) = g {
-                write!(w, "{}", WhereClause { gens: g, indent: 0, end_newline: true })?
+                write!(w, "{}", WhereClause { gens: g, indent: 0, end_newline: false })?
             }
             write!(w, ";")?;
         }
index 89c5e60e3431430611ffd6c0e49bff211575b6b8..48ef4b6be66dea34e4d204f8ce7eba6bce392b74 100644 (file)
@@ -17,7 +17,7 @@ impl AnOibit for .. {}
 pub struct Foo<T> { field: T }
 
 // @has impl_parts/struct.Foo.html '//*[@class="impl"]//code' \
-//     "impl<T: Clone> !AnOibit for Foo<T> where T: Sync"
+//     "impl<T: Clone> !AnOibit for Foo<T> where T: Sync,"
 // @has impl_parts/trait.AnOibit.html '//*[@class="item-list"]//code' \
-//     "impl<T: Clone> !AnOibit for Foo<T> where T: Sync"
+//     "impl<T: Clone> !AnOibit for Foo<T> where T: Sync,"
 impl<T: Clone> !AnOibit for Foo<T> where T: Sync {}
index 9ebd1c448eeb0d4195479782b9e066531b043188..960e40b07098567491d48b8936a0fe4a7b757b09 100644 (file)
@@ -35,7 +35,7 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
 
 pub mod reexport {
     // @has issue_20727_4/reexport/trait.Index.html
-    // @has - '//*[@class="rust trait"]' 'trait Index<Idx> where Idx: ?Sized {'
+    // @has - '//*[@class="rust trait"]' 'trait Index<Idx> where Idx: ?Sized, {'
     // @has - '//*[@class="rust trait"]' 'type Output: ?Sized'
     // @has - '//*[@class="rust trait"]' \
     //        'fn index(&self, index: Idx) -> &Self::Output'
@@ -43,7 +43,7 @@ pub mod reexport {
 
     // @has issue_20727_4/reexport/trait.IndexMut.html
     // @has - '//*[@class="rust trait"]' \
-    //        'trait IndexMut<Idx>: Index<Idx> where Idx: ?Sized {'
+    //        'trait IndexMut<Idx>: Index<Idx> where Idx: ?Sized, {'
     // @has - '//*[@class="rust trait"]' \
     //        'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;'
     pub use issue_20727::IndexMut;
index d8dc115abf91e1039fa8b30561540c43ed79a753..e691f7c5bea01ef8e054f78e1cc71c7c9bcb7492 100644 (file)
@@ -44,5 +44,5 @@ pub enum Foxtrot<F> { Foxtrot1(F) }
 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)"
+//          "type Golf<T> where T: Clone, = (T, T)"
 pub type Golf<T> where T: Clone = (T, T);