about summary refs log tree commit diff
path: root/src/test/rustdoc
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2016-11-12 10:38:36 +0200
committerGitHub <noreply@github.com>2016-11-12 10:38:36 +0200
commit2db360eec1685a7bf33cf48ff9b9ab1757dcb358 (patch)
tree9a1a082687486baa9bd72c8f35ebfa651a148dda /src/test/rustdoc
parentb33873f5411d4ad6a3bd5a4a18dffce8a960a316 (diff)
parent61cc8700dfcecde9e7de132356f3c32eb01b147e (diff)
downloadrust-2db360eec1685a7bf33cf48ff9b9ab1757dcb358.tar.gz
rust-2db360eec1685a7bf33cf48ff9b9ab1757dcb358.zip
Rollup merge of #37190 - QuietMisdreavus:rustdoc-where-newline, r=GuillaumeGomez
rustdoc: add line breaks to where clauses a la rustfmt

Much like my last PR for rustdoc (#36679), this adds line breaks to certain statements based on their line length. Here the focus was on where clauses.

Some examples:
- [Where clause in a trait function](https://shiva.icesoldier.me/custom-std/std/iter/trait.Iterator.html?search=#method.unzip) (also in the trait header block at the top of the page)
- [Where clause on a bare function](https://shiva.icesoldier.me/doc-custom2/petgraph/visit/fn.depth_first_search.html)
- [Where clauses in trait impls on a struct](https://shiva.icesoldier.me/custom-std/std/collections/struct.HashMap.html) (scroll to the bottom) These are regularly not on their own line, but will be given their own line now if their "prefix text" doesn't give them enough room to sensibly print their constraints. HashMap's trait impls provide some examples of both behaviors.

The libstd links above are the whole docs rendered with this, and the "bare function" link above is in another set that pulls some notable crates together. `petgraph` was the one that brought this request up, and that collection also includes [itertools](https://shiva.icesoldier.me/doc-custom2/itertools/trait.Itertools.html) which provided an easy sample to test with.

r? @GuillaumeGomez
Diffstat (limited to 'src/test/rustdoc')
-rw-r--r--src/test/rustdoc/line-breaks.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/rustdoc/line-breaks.rs b/src/test/rustdoc/line-breaks.rs
index cc608a24475..a1eabb515a5 100644
--- a/src/test/rustdoc/line-breaks.rs
+++ b/src/test/rustdoc/line-breaks.rs
@@ -10,6 +10,9 @@
 
 #![crate_name = "foo"]
 
+use std::ops::Add;
+use std::fmt::Display;
+
 //@count foo/fn.function_with_a_really_long_name.html //pre/br 2
 pub fn function_with_a_really_long_name(parameter_one: i32,
                                         parameter_two: i32)
@@ -19,3 +22,19 @@ pub fn function_with_a_really_long_name(parameter_one: i32,
 
 //@count foo/fn.short_name.html //pre/br 0
 pub fn short_name(param: i32) -> i32 { param + 1 }
+
+//@count foo/fn.where_clause.html //pre/br 4
+pub fn where_clause<T, U>(param_one: T,
+                          param_two: U)
+    where T: Add<U> + Display + Copy,
+          U: Add<T> + Display + Copy,
+          T::Output: Display + Add<U::Output> + Copy,
+          <T::Output as Add<U::Output>>::Output: Display,
+          U::Output: Display + Copy
+{
+    let x = param_one + param_two;
+    println!("{} + {} = {}", param_one, param_two, x);
+    let y = param_two + param_one;
+    println!("{} + {} = {}", param_two, param_one, y);
+    println!("{} + {} = {}", x, y, x + y);
+}