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]); +``` 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 /// 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`]. /// diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 644e323a8dbf2..0136faef28d8c 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1223,6 +1223,28 @@ fn main() { ``` "##, +E0090: r##" +You gave too few lifetime parameters. Example: + +```compile_fail,E0090 +fn foo<'a: 'b, 'b: 'a>() {} + +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##" You gave an unnecessary type parameter in a type alias. Erroneous code example: @@ -4120,7 +4142,6 @@ register_diagnostics! { // E0068, // E0085, // E0086, - E0090, E0103, // @GuillaumeGomez: I was unable to get this error, try your best! E0104, // E0123, 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/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; 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}; }