From a68a0e33d1d6660ad594ae7be3c6c1cca7c1752c Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Wed, 27 Mar 2019 01:22:23 -0400 Subject: [PATCH 1/4] Add documentation about `for` used as higher ranked trait bounds Resolves #55416 --- src/libstd/keyword_docs.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index bef6bc9266197..94751cec41618 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -286,11 +286,13 @@ mod fn_keyword { } // /// The `for` keyword. /// -/// `for` is primarily used in for-in-loops, but it has a few other pieces of syntactic uses such as -/// `impl Trait for Type` (see [`impl`] for more info on that). for-in-loops, or to be more -/// precise, iterator loops, are a simple syntactic sugar over an exceedingly common practice -/// within Rust, which is to loop over an iterator until that iterator returns `None` (or `break` -/// is called). +/// `for` is primarily used in for-in-loops, but it has a few other pieces of syntactic +/// uses. `for` is used when implementing traits as in `impl Trait for Type` (see +/// [`impl`] for more info on that). `for` is also used for [higher-ranked trait bounds] +/// as in `for<'a> &'a T: PartialEq`. for-in-loops, or to be more precise, iterator +/// loops, are a simple syntactic sugar over an exceedingly common practice within Rust, +/// which is to loop over an iterator until that iterator returns `None` (or `break` is +/// called). /// /// ```rust /// for i in 0..5 { From 65b5e572266ace8d9dc817ab5f8c54b675614110 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Wed, 27 Mar 2019 01:52:55 -0400 Subject: [PATCH 2/4] Make into itemized list and fix some wording --- src/libstd/keyword_docs.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 94751cec41618..3eec5468c7de4 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -286,13 +286,16 @@ mod fn_keyword { } // /// The `for` keyword. /// -/// `for` is primarily used in for-in-loops, but it has a few other pieces of syntactic -/// uses. `for` is used when implementing traits as in `impl Trait for Type` (see -/// [`impl`] for more info on that). `for` is also used for [higher-ranked trait bounds] -/// as in `for<'a> &'a T: PartialEq`. for-in-loops, or to be more precise, iterator -/// loops, are a simple syntactic sugar over an exceedingly common practice within Rust, -/// which is to loop over an iterator until that iterator returns `None` (or `break` is -/// called). +/// The `for` keyword is used in many syntactic locations: +/// +/// * `for` is used in for-in-loops (see below). +/// * `for` is used when implementing traits as in `impl Trait for Type` (see [`impl`] for more info +/// on that). +/// * `for` is also used for [higher-ranked trait bounds] as in `for<'a> &'a T: PartialEq`. +/// +/// for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common +/// practice within Rust, which is to loop over an iterator until that iterator returns `None` (or +/// `break` is called). /// /// ```rust /// for i in 0..5 { From f0a76107248ab2366ab5dd2d63cd0ec489e5d8b4 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Wed, 27 Mar 2019 12:03:14 -0400 Subject: [PATCH 3/4] Add higher-ranked trait bounds link --- src/libstd/keyword_docs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 3eec5468c7de4..7223eb3bf0ead 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -352,6 +352,7 @@ mod fn_keyword { } /// For more information on for-loops, see the [Rust book] or the [Reference]. /// /// [`impl`]: keyword.impl.html +/// [higher-ranked trait bounds]: https://doc.rust-lang.org/nightly/reference/trait-bounds.html#higher-ranked-trait-bounds /// [`IntoIterator`]: iter/trait.IntoIterator.html /// [Rust book]: /// https://doc.rust-lang.org/book/2018-edition/ch03-05-control-flow.html#looping-through-a-collection-with-for From 25452501ee53c60445b9774fa69e2dc2134ddc44 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Wed, 27 Mar 2019 21:46:25 -0400 Subject: [PATCH 4/4] Move link to rust book to next line to pass 100 column limit --- src/libstd/keyword_docs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 7223eb3bf0ead..7b0d1549e061a 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -352,7 +352,8 @@ mod fn_keyword { } /// For more information on for-loops, see the [Rust book] or the [Reference]. /// /// [`impl`]: keyword.impl.html -/// [higher-ranked trait bounds]: https://doc.rust-lang.org/nightly/reference/trait-bounds.html#higher-ranked-trait-bounds +/// [higher-ranked trait bounds]: +/// https://doc.rust-lang.org/nightly/reference/trait-bounds.html#higher-ranked-trait-bounds /// [`IntoIterator`]: iter/trait.IntoIterator.html /// [Rust book]: /// https://doc.rust-lang.org/book/2018-edition/ch03-05-control-flow.html#looping-through-a-collection-with-for