From 49db656b069c425d5895e4b2b6f6684d80ba24b8 Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Mon, 20 Mar 2017 20:01:18 -0500 Subject: [PATCH 1/7] str: Make docs consistently punctuated --- src/libcore/str/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index cf3e8a684dfab..9985cc2b27ad1 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -332,7 +332,7 @@ impl fmt::Display for Utf8Error { Section: Iterators */ -/// Iterator for the char (representing *Unicode Scalar Values*) of a string +/// Iterator for the char (representing *Unicode Scalar Values*) of a string. /// /// Created with the method [`chars`]. /// From ed5702fc581a9d4d72e53e8d7a2ce4475fa8a064 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 20 Mar 2017 22:49:22 +0100 Subject: [PATCH 2/7] Fix invalid linking in iter docs --- src/libcore/iter/iterator.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index fb98e43aa614b..618edf48abd04 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -518,13 +518,13 @@ pub trait Iterator { /// Creates an iterator that both filters and maps. /// - /// The closure must return an [`Option`]. `filter_map()` creates an + /// The closure must return an [`Option`]. `filter_map` creates an /// iterator which calls this closure on each element. If the closure /// returns [`Some(element)`][`Some`], then that element is returned. If the /// closure returns [`None`], it will try again, and call the closure on the /// next element, seeing if it will return [`Some`]. /// - /// Why `filter_map()` and not just [`filter()`].[`map`]? The key is in this + /// Why `filter_map` and not just [`filter`].[`map`]? The key is in this /// part: /// /// [`filter`]: #method.filter @@ -534,7 +534,7 @@ pub trait Iterator { /// /// In other words, it removes the [`Option`] layer automatically. If your /// mapping is already returning an [`Option`] and you want to skip over - /// [`None`]s, then `filter_map()` is much, much nicer to use. + /// [`None`]s, then `filter_map` is much, much nicer to use. /// /// # Examples /// From f53172287a4ebb57e8372ce2647628887a268696 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 20 Mar 2017 22:41:19 +0100 Subject: [PATCH 3/7] Add whitespace around "=" in assoc items --- src/librustdoc/html/format.rs | 4 ++-- src/librustdoc/html/render.rs | 2 +- src/test/rustdoc/doc-assoc-item.rs | 28 ++++++++++++++++++++++++++++ src/test/rustdoc/issue-20646.rs | 4 ++-- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 src/test/rustdoc/doc-assoc-item.rs diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index a255ba0ad4edf..9f2d02c14dde0 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1096,9 +1096,9 @@ impl fmt::Display for clean::ImportSource { impl fmt::Display for clean::TypeBinding { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if f.alternate() { - write!(f, "{}={:#}", self.name, self.ty) + write!(f, "{} = {:#}", self.name, self.ty) } else { - write!(f, "{}={}", self.name, self.ty) + write!(f, "{} = {}", self.name, self.ty) } } } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 7b60d497932de..10fde67a45674 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2808,7 +2808,7 @@ fn render_assoc_items(w: &mut fmt::Formatter, } AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => { write!(w, "

Methods from \ - {}<Target={}>

", trait_, type_)?; + {}<Target = {}>", trait_, type_)?; RenderMode::ForDeref { mut_: deref_mut_ } } }; diff --git a/src/test/rustdoc/doc-assoc-item.rs b/src/test/rustdoc/doc-assoc-item.rs new file mode 100644 index 0000000000000..36f44295953f0 --- /dev/null +++ b/src/test/rustdoc/doc-assoc-item.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo { + x: T, +} + +pub trait Bar { + type Fuu; + + fn foo(foo: Self::Fuu); +} + +// @has doc_assoc_item/struct.Foo.html '//*[@class="impl"]' 'impl> Foo' +impl> Foo { + pub fn new(t: T) -> Foo { + Foo { + x: t, + } + } +} diff --git a/src/test/rustdoc/issue-20646.rs b/src/test/rustdoc/issue-20646.rs index 87c40d1157974..49fac20035fc0 100644 --- a/src/test/rustdoc/issue-20646.rs +++ b/src/test/rustdoc/issue-20646.rs @@ -23,7 +23,7 @@ pub trait Trait { } // @has issue_20646/fn.fun.html \ -// '//*[@class="rust fn"]' 'where T: Trait' +// '//*[@class="rust fn"]' 'where T: Trait' pub fn fun(_: T) where T: Trait {} pub mod reexport { @@ -31,6 +31,6 @@ pub mod reexport { // '//*[@id="associatedtype.Output"]' \ // 'type Output' // @has issue_20646/reexport/fn.fun.html \ - // '//*[@class="rust fn"]' 'where T: Trait' + // '//*[@class="rust fn"]' 'where T: Trait' pub use issue_20646::{Trait, fun}; } From 6acbbc66f7ff4dcf5db92c9c73c84c2b18d63b05 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Fri, 17 Mar 2017 23:21:21 +0100 Subject: [PATCH 4/7] Add docs for sort_unstable to unstable book --- src/doc/unstable-book/src/sort-unstable.md | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/doc/unstable-book/src/sort-unstable.md b/src/doc/unstable-book/src/sort-unstable.md index aec39de2c9a73..9effcfc774c77 100644 --- a/src/doc/unstable-book/src/sort-unstable.md +++ b/src/doc/unstable-book/src/sort-unstable.md @@ -6,4 +6,35 @@ The tracking issue for this feature is: [#40585] ------------------------ +The default `sort` method on slices is stable. In other words, it guarantees +that the original order of equal elements is preserved after sorting. The +method has several undesirable characteristics: +1. It allocates a sizable chunk of memory. +2. If you don't need stability, it is not as performant as it could be. + +An alternative is the new `sort_unstable` feature, which includes these +methods for sorting slices: + +1. `sort_unstable` +2. `sort_unstable_by` +3. `sort_unstable_by_key` + +Unstable sorting is generally faster and makes no allocations. The majority +of real-world sorting needs doesn't require stability, so these methods can +very often come in handy. + +Another important difference is that `sort` lives in `libstd` and +`sort_unstable` lives in `libcore`. The reason is that the former makes +allocations and the latter doesn't. + +A simple example: + +```rust +#![feature(sort_unstable)] + +let mut v = [-5, 4, 1, -3, 2]; + +v.sort_unstable(); +assert!(v == [-5, -3, 1, 2, 4]); +``` From 8e352f7d866f46e09746d7f8557818984a1f3854 Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Tue, 21 Mar 2017 20:15:55 -0500 Subject: [PATCH 5/7] E0090: Add explanation for error message See #32777 --- src/librustc_typeck/diagnostics.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 644e323a8dbf2..2d24b1fb4f20a 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1223,6 +1223,18 @@ fn main() { ``` "##, +E0090: r##" +The wrong number of lifetimes were supplied. For example: + +```compile_fail,E0090 +fn foo<'a: 'b, 'b: 'a>() {} + +fn main() { + foo::<'static>(); // error, expected 2 lifetime parameters +} +``` +"##, + E0091: r##" You gave an unnecessary type parameter in a type alias. Erroneous code example: @@ -4120,7 +4132,6 @@ register_diagnostics! { // E0068, // E0085, // E0086, - E0090, E0103, // @GuillaumeGomez: I was unable to get this error, try your best! E0104, // E0123, From e2b5a8cf57f83d6e658f36f0cdafdd59896649b8 Mon Sep 17 00:00:00 2001 From: Cldfire Date: Tue, 21 Mar 2017 23:40:41 -0400 Subject: [PATCH 6/7] Remove duplicate style classes --- src/librustdoc/html/static/styles/main.css | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/librustdoc/html/static/styles/main.css b/src/librustdoc/html/static/styles/main.css index 40561597e93e0..74ec3691b3860 100644 --- a/src/librustdoc/html/static/styles/main.css +++ b/src/librustdoc/html/static/styles/main.css @@ -45,14 +45,6 @@ pre { background-color: #fff; } -.sidebar { - background-color: #F1F1F1; -} - -.sidebar .current { - background-color: #fff; -} - .sidebar .location { border-color: #000; background-color: #fff; From 8ea0f18d9a3bdf001be8d668818b8291dd2b37df Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Wed, 22 Mar 2017 00:07:12 -0500 Subject: [PATCH 7/7] E0090: Expand error message explanation --- src/librustc_typeck/diagnostics.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 2d24b1fb4f20a..0136faef28d8c 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1224,7 +1224,7 @@ fn main() { "##, E0090: r##" -The wrong number of lifetimes were supplied. For example: +You gave too few lifetime parameters. Example: ```compile_fail,E0090 fn foo<'a: 'b, 'b: 'a>() {} @@ -1233,6 +1233,16 @@ fn main() { foo::<'static>(); // error, expected 2 lifetime parameters } ``` + +Please check you give the right number of lifetime parameters. Example: + +``` +fn foo<'a: 'b, 'b: 'a>() {} + +fn main() { + foo::<'static, 'static>(); +} +``` "##, E0091: r##"