Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #40735

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/doc/unstable-book/src/sort-unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
```
6 changes: 3 additions & 3 deletions src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,13 @@ pub trait Iterator {

/// Creates an iterator that both filters and maps.
///
/// The closure must return an [`Option<T>`]. `filter_map()` creates an
/// The closure must return an [`Option<T>`]. `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
Expand All @@ -534,7 +534,7 @@ pub trait Iterator {
///
/// In other words, it removes the [`Option<T>`] layer automatically. If your
/// mapping is already returning an [`Option<T>`] 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
///
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
///
Expand Down
23 changes: 22 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -4120,7 +4142,6 @@ register_diagnostics! {
// E0068,
// E0085,
// E0086,
E0090,
E0103, // @GuillaumeGomez: I was unable to get this error, try your best!
E0104,
// E0123,
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
}
AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => {
write!(w, "<h2 id='deref-methods'>Methods from \
{}&lt;Target={}&gt;</h2>", trait_, type_)?;
{}&lt;Target = {}&gt;</h2>", trait_, type_)?;
RenderMode::ForDeref { mut_: deref_mut_ }
}
};
Expand Down
8 changes: 0 additions & 8 deletions src/librustdoc/html/static/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions src/test/rustdoc/doc-assoc-item.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub struct Foo<T> {
x: T,
}

pub trait Bar {
type Fuu;

fn foo(foo: Self::Fuu);
}

// @has doc_assoc_item/struct.Foo.html '//*[@class="impl"]' 'impl<T: Bar<Fuu = u32>> Foo<T>'
impl<T: Bar<Fuu = u32>> Foo<T> {
pub fn new(t: T) -> Foo<T> {
Foo {
x: t,
}
}
}
4 changes: 2 additions & 2 deletions src/test/rustdoc/issue-20646.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ pub trait Trait {
}

// @has issue_20646/fn.fun.html \
// '//*[@class="rust fn"]' 'where T: Trait<Output=i32>'
// '//*[@class="rust fn"]' 'where T: Trait<Output = i32>'
pub fn fun<T>(_: T) where T: Trait<Output=i32> {}

pub mod reexport {
// @has issue_20646/reexport/trait.Trait.html \
// '//*[@id="associatedtype.Output"]' \
// 'type Output'
// @has issue_20646/reexport/fn.fun.html \
// '//*[@class="rust fn"]' 'where T: Trait<Output=i32>'
// '//*[@class="rust fn"]' 'where T: Trait<Output = i32>'
pub use issue_20646::{Trait, fun};
}