]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoBless MIR tests that inline functions qualifying for NRVO
Dylan MacKenzie [Fri, 15 May 2020 21:53:20 +0000 (14:53 -0700)]
Bless MIR tests that inline functions qualifying for NRVO

4 years agoDumb NRVO
Dylan MacKenzie [Thu, 14 May 2020 17:11:15 +0000 (10:11 -0700)]
Dumb NRVO

4 years agoAuto merge of #72276 - RalfJung:rollup-nkfu3is, r=RalfJung
bors [Sat, 16 May 2020 17:47:21 +0000 (17:47 +0000)]
Auto merge of #72276 - RalfJung:rollup-nkfu3is, r=RalfJung

Rollup of 5 pull requests

Successful merges:

 - #72045 (Incomplete features can also be unsound)
 - #72047 (Literal error reporting cleanup)
 - #72060 (move `ty::List` into a new submodule)
 - #72094 (cmdline: Make target features individually overridable)
 - #72254 (Remove redundant backtick in error message.)

Failed merges:

r? @ghost

4 years agoRollup merge of #72254 - ehuss:double-backtick, r=dtolnay
Ralf Jung [Sat, 16 May 2020 17:46:37 +0000 (19:46 +0200)]
Rollup merge of #72254 - ehuss:double-backtick, r=dtolnay

Remove redundant backtick in error message.

The value passed in already has backticks surrounding the text.

4 years agoRollup merge of #72094 - petrochenkov:overfeature, r=nikic
Ralf Jung [Sat, 16 May 2020 17:46:36 +0000 (19:46 +0200)]
Rollup merge of #72094 - petrochenkov:overfeature, r=nikic

cmdline: Make target features individually overridable

Fixes https://github.com/rust-lang/rust/issues/56527

Previously `-C target-feature=+avx2 -C target-feature=+fma` was equivalent to `-C target-feature=+fma` because the later `-C target-feature` option fully overridden previous `-C target-feature`.
With this PR `-C target-feature=+avx2 -C target-feature=+fma` is equivalent to `-C target-feature=+avx2,+fma` and the options are combined.

I'm not sure where the comma-separated features in a single option came from (clang uses a scheme with single feature per-option), but logically these features are entirely independent options.
So they should be overridable individually as well to be more useful in hierarchical build system, and more consistent with other rustc options and clang behavior as well.

Target feature options have a few other issues (https://github.com/rust-lang/rust/issues/44815), but fixing those is going to be a bit more invasive.

4 years agoRollup merge of #72060 - lcnr:move-list, r=estebank
Ralf Jung [Sat, 16 May 2020 17:46:34 +0000 (19:46 +0200)]
Rollup merge of #72060 - lcnr:move-list, r=estebank

move `ty::List` into a new submodule

`rustc_middle/ty` is currently right below the 3000 lines tidy file length limit.

Moves `rustc_middle::ty::List` to the private module `rustc_middle::ty::list` and adds
a `pub use self::list::List` at its previous location.

4 years agoRollup merge of #72047 - Julian-Wollersberger:literal_error_reporting_cleanup, r...
Ralf Jung [Sat, 16 May 2020 17:46:31 +0000 (19:46 +0200)]
Rollup merge of #72047 - Julian-Wollersberger:literal_error_reporting_cleanup, r=petrochenkov

Literal error reporting cleanup

While doing some performance work, I noticed some code duplication in `librustc_parser/lexer/mod.rs`, so I cleaned it up.

This PR is probably best reviewed commit by commit.

I'm not sure what the API stability practices for `librustc_lexer` are. Four public methods in `unescape.rs` can be removed, but two are used by clippy, so I left them in for now.
I could open a PR for Rust-Analyzer when this one lands.

But how do I open a PR for clippy? (Git submodules are frustrating to work with)

4 years agoRollup merge of #72045 - RalfJung:incomplete-unsound, r=petrochenkov
Ralf Jung [Sat, 16 May 2020 17:46:29 +0000 (19:46 +0200)]
Rollup merge of #72045 - RalfJung:incomplete-unsound, r=petrochenkov

Incomplete features can also be unsound

Some incomplete features do not just ICE, they are also currently unsound (e.g. https://github.com/rust-lang/rust/pull/72029, and also `specialization` -- which is not yet marked incomplete but [should be](https://github.com/rust-lang/rust/pull/71420)). This makes the message reflect that.

While at it I also added a link to the tracking issue, which hopefully should explain what is incomplete/unsound about the feature.

4 years agoAuto merge of #72262 - Dylan-DPC:rollup-x56q1jj, r=Dylan-DPC
bors [Sat, 16 May 2020 14:15:18 +0000 (14:15 +0000)]
Auto merge of #72262 - Dylan-DPC:rollup-x56q1jj, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #71625 (Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology)
 - #71919 (Update transitive dependency to work towards removing syn <1.0 dep)
 - #72166 (Simpler slice `Iterator` methods)
 - #72216 (Remove `lang_items\(\).*\.unwrap\(\)`)
 - #72230 (Updated documentation of Prefix::VerbatimDisk)
 - #72234 (Implement Default for proc_macro::TokenStream)
 - #72258 (Fix typo Arbintrary to Arbitrary)

Failed merges:

r? @ghost

4 years agoRollup merge of #72258 - Rustin-Liu:rustin-patch-typo, r=dtolnay
Dylan DPC [Sat, 16 May 2020 10:43:08 +0000 (12:43 +0200)]
Rollup merge of #72258 - Rustin-Liu:rustin-patch-typo, r=dtolnay

Fix typo Arbintrary to Arbitrary

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
Closes #72122.

4 years agoRollup merge of #72234 - dtolnay:default, r=petrochenkov
Dylan DPC [Sat, 16 May 2020 10:43:06 +0000 (12:43 +0200)]
Rollup merge of #72234 - dtolnay:default, r=petrochenkov

Implement Default for proc_macro::TokenStream

Hopefully this is uncontroversial. The only reason we've made it this far without is that proc-macro2 snuck this in for their TokenStream.

4 years agoRollup merge of #72230 - SOF3:patch-1, r=kennytm
Dylan DPC [Sat, 16 May 2020 10:43:05 +0000 (12:43 +0200)]
Rollup merge of #72230 - SOF3:patch-1, r=kennytm

Updated documentation of Prefix::VerbatimDisk

PrefixComponent with Prefix::VerbatimDisk does not contain the trailing slash. The documentation here is also inconsistent with the documentation on other variants that reflect the `PrefixComponent::as_os_str()` return value.

4 years agoRollup merge of #72216 - doctorn:require-lang-item, r=lcnr
Dylan DPC [Sat, 16 May 2020 10:43:03 +0000 (12:43 +0200)]
Rollup merge of #72216 - doctorn:require-lang-item, r=lcnr

Remove `lang_items\(\).*\.unwrap\(\)`

Follows up #72170 to remove the remaining uses of `lang_items\(\).*\.unwrap\(\)` (avoids a bunch of potential ICEs when working in `#![no_core]`).

Resolves #72195

4 years agoRollup merge of #72166 - nnethercote:simpler-slice-Iterator-methods, r=cuviper
Dylan DPC [Sat, 16 May 2020 10:43:01 +0000 (12:43 +0200)]
Rollup merge of #72166 - nnethercote:simpler-slice-Iterator-methods, r=cuviper

Simpler slice `Iterator` methods

These reduce the amount of LLVM IR generated, helping compile times.

r? @cuviper

4 years agoRollup merge of #71919 - Xanewok:bump-syn-1, r=Xanewok
Dylan DPC [Sat, 16 May 2020 10:42:59 +0000 (12:42 +0200)]
Rollup merge of #71919 - Xanewok:bump-syn-1, r=Xanewok

Update transitive dependency to work towards removing syn <1.0 dep

This bumps a couple of transitive dependencies in hopes of eventually not transitively depending on syn <1.0 and friends. The only upstream changes that this is blocked on seems to be https://github.com/mattico/elasticlunr-rs/pull/27 and https://github.com/rust-lang/mdBook/pull/1210.

While working on https://github.com/rust-lang/rust/pull/71875 I noticed we still use syn 0.15 here and there so this is a drive-by PR which aims to help with things a bit.

4 years agoRollup merge of #71625 - Diggsey:improve-manually-drop-docs, r=RalfJung
Dylan DPC [Sat, 16 May 2020 10:42:55 +0000 (12:42 +0200)]
Rollup merge of #71625 - Diggsey:improve-manually-drop-docs, r=RalfJung

Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology

cc @RalfJung

Follow-up from https://github.com/rust-lang/unsafe-code-guidelines/issues/233

4 years agoAuto merge of #71872 - nnethercote:less-aggressive-arena-growth, r=oli-obk
bors [Sat, 16 May 2020 10:32:46 +0000 (10:32 +0000)]
Auto merge of #71872 - nnethercote:less-aggressive-arena-growth, r=oli-obk

Be less aggressive with `DroplessArena`/`TypedArena` growth.

`DroplessArena` and `TypedArena` use an aggressive growth strategy: the first chunk is 4 KiB, the second is 8 KiB, and it keeps on doubling indefinitely. DHAT profiles show that sometimes this results in large chunks (e.g. 16-128 MiB) that are barely filled.

This commit changes things so that the doubling stops at 2 MiB. This is large enough that chunk allocations are still rare (you might get 100s instead of 10s of them) but avoids lots of unused space in the worst case. It makes the same change to `TypedArena`, too.

4 years agoAuto merge of #71665 - RalfJung:miri-intern-no-ice, r=oli-obk
bors [Sat, 16 May 2020 07:14:52 +0000 (07:14 +0000)]
Auto merge of #71665 - RalfJung:miri-intern-no-ice, r=oli-obk

Miri interning: replace ICEs by proper errors

Fixes https://github.com/rust-lang/rust/issues/71316

I also did some refactoring, as I kept being confused by all the parameters to `intern_shallow`, some of which have invalid combinations (such as a mutable const). So instead `InternMode` now contains all the information that is needed and invalid combinations are ruled out by the type system.

Also I removed interpreter errors from interning. We already ignored almost all errors, and the `ValidationFailure` errors that we handled separately actually cannot ever happen here. The only interpreter failure that was actually reachable was the UB on dangling pointers -- and arguably, a dangling raw pointer is not UB, so the error was not even correct. It's just that the rest of the compiler does not like "dangling" `AllocId`.

It should be possible to review the 3 commits separately.

r? @oli-obk
Cc @rust-lang/wg-const-eval

4 years agoFix typo Arbintrary to Arbitrary
Rustin-Liu [Sat, 16 May 2020 06:40:45 +0000 (14:40 +0800)]
Fix typo Arbintrary to Arbitrary

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
4 years agoAuto merge of #72079 - semarie:openbsd-stacker, r=Mark-Simulacrum
bors [Sat, 16 May 2020 03:55:49 +0000 (03:55 +0000)]
Auto merge of #72079 - semarie:openbsd-stacker, r=Mark-Simulacrum

update stacker to 0.1.9 to unbreak build on OpenBSD

the version 0.1.8 of stacker (what is currently pinned in Cargo.lock) doesn't build on OpenBSD (see https://github.com/rust-lang/stacker/pull/34).

update the version to 0.1.9

4 years agoRemove redundant backtick in error message.
Eric Huss [Sat, 16 May 2020 03:51:12 +0000 (20:51 -0700)]
Remove redundant backtick in error message.

The value passed in already has backticks surrounding the text.

4 years agoAuto merge of #72251 - Dylan-DPC:rollup-4mik3o7, r=Dylan-DPC
bors [Sat, 16 May 2020 00:44:57 +0000 (00:44 +0000)]
Auto merge of #72251 - Dylan-DPC:rollup-4mik3o7, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #71662 (Implement FromStr for OsString)
 - #71677 (Add explicit references to the BuildHasher trait)
 - #71724 (Doc alias improvements)
 - #71948 (Suggest to await future before ? operator)
 - #72090 (rustc_driver: factor out computing the exit code)
 - #72206 (Cleanup stale 'FIXME(#64197)')
 - #72218 (make sure even unleashed miri does not do pointer stuff)
 - #72220 ([const-prop] Don't replace Rvalues that are already constants)
 - #72224 (doc: add links to rotate_(left|right))

Failed merges:

r? @ghost

4 years agoRollup merge of #72224 - lzutao:links, r=Dylan-DPC
Dylan DPC [Sat, 16 May 2020 00:37:29 +0000 (02:37 +0200)]
Rollup merge of #72224 - lzutao:links, r=Dylan-DPC

doc: add links to rotate_(left|right)

4 years agoRollup merge of #72220 - wesleywiser:const_prop_eval_consts, r=oli-obk
Dylan DPC [Sat, 16 May 2020 00:37:28 +0000 (02:37 +0200)]
Rollup merge of #72220 - wesleywiser:const_prop_eval_consts, r=oli-obk

[const-prop] Don't replace Rvalues that are already constants

This cleans up a few mir-opt tests which have slight changes to spans for `consts` as a result of replacing them with new Rvalues.

4 years agoRollup merge of #72218 - RalfJung:test-unleashed-ptrs, r=oli-obk
Dylan DPC [Sat, 16 May 2020 00:37:26 +0000 (02:37 +0200)]
Rollup merge of #72218 - RalfJung:test-unleashed-ptrs, r=oli-obk

make sure even unleashed miri does not do pointer stuff

r? @oli-obk

4 years agoRollup merge of #72206 - sergey-melnychuk:cleanup-stale-fixme, r=petrochenkov
Dylan DPC [Sat, 16 May 2020 00:37:24 +0000 (02:37 +0200)]
Rollup merge of #72206 - sergey-melnychuk:cleanup-stale-fixme, r=petrochenkov

Cleanup stale 'FIXME(#64197)'

(My first PR in rust-lang, any feedback is welcome. Please don't hesitate to let me know if I'm trying to do something pointless!)

Trivial cleanup of a stale `FIXME`, `StringReader.pos` is no longer exposed. For testing added `pos()` method that returns cloned value of `pos`.

4 years agoRollup merge of #72090 - RalfJung:rustc_driver-exit-code, r=oli-obk
Dylan DPC [Sat, 16 May 2020 00:37:23 +0000 (02:37 +0200)]
Rollup merge of #72090 - RalfJung:rustc_driver-exit-code, r=oli-obk

rustc_driver: factor out computing the exit code

In a recent Miri PR I [added a convenience wrapper](https://github.com/rust-lang/miri/pull/1405/files#diff-c3d602c5c8035a16699ce9c015bfeceaR125) around `catch_fatal_errors` and `run_compiler` that @oli-obk suggested I could upstream. However, after seeing what could be shared between `rustc_driver::main`, clippy and Miri, really the only thing I found is computing the exit code -- so that's what this PR does.

What prevents using the Miri convenience function in `rustc_driver::main` and clippy is that they do extra work inside `catch_fatal_errors`, and while I could abstract that away, clippy actually *computes the callbacks* inside there, and I fond no good way to abstract that and thus gave up. Maybe the clippy thing could be moved out, I am not sure if it ever can actually raise a `FatalErrorMarker` -- someone more knowledgeable in clippy would have to do that.

4 years agoRollup merge of #71948 - csmoe:issue-61076, r=oli-obk
Dylan DPC [Sat, 16 May 2020 00:37:21 +0000 (02:37 +0200)]
Rollup merge of #71948 - csmoe:issue-61076, r=oli-obk

Suggest to await future before ? operator

Closes https://github.com/rust-lang/rust/issues/71811
cc #61076

4 years agoRollup merge of #71724 - GuillaumeGomez:doc-alias-improvements, r=ollie27
Dylan DPC [Sat, 16 May 2020 00:37:19 +0000 (02:37 +0200)]
Rollup merge of #71724 - GuillaumeGomez:doc-alias-improvements, r=ollie27

Doc alias improvements

After [this message](https://github.com/rust-lang/rust/issues/50146#issuecomment-496601755), I realized that the **doc alias**. So this PR does the followings:

 * Align the alias discovery on items added into the search-index. It brings a few nice advantages:
   * Instead of cloning the data between the two (in rustdoc source code), we now have the search-index one and aliases which reference to the first one. So we go from one big map containing a lot of duplicated data to just integers...
 * In the front-end (main.js), I improved the code around aliases to allow them to go through the same transformation as other items when we show the search results.
 * Improve the search tester in order to perform multiple requests into one file (I think it's better in this case than having a file for each case considering how many there are...)
    * I also had to add the new function inside the tester (`handleAliases`)

Once this PR is merged, I intend to finally stabilize this feature.

r? @ollie27

cc @rust-lang/rustdoc

4 years agoRollup merge of #71677 - Mark-Simulacrum:hasher-docs, r=Amanieu
Dylan DPC [Sat, 16 May 2020 00:37:14 +0000 (02:37 +0200)]
Rollup merge of #71677 - Mark-Simulacrum:hasher-docs, r=Amanieu

Add explicit references to the BuildHasher trait

Fixes #71652

4 years agoRollup merge of #71662 - glandium:osstring_from_str, r=sfackler
Dylan DPC [Sat, 16 May 2020 00:37:07 +0000 (02:37 +0200)]
Rollup merge of #71662 - glandium:osstring_from_str, r=sfackler

Implement FromStr for OsString

4 years agoImprove the documentation for ManuallyDrop to resolve conflicting usage of terminology.
Diggory Blake [Mon, 27 Apr 2020 21:50:55 +0000 (22:50 +0100)]
Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology.

4 years agoImplement Default for proc_macro::TokenStream
David Tolnay [Fri, 15 May 2020 16:12:41 +0000 (09:12 -0700)]
Implement Default for proc_macro::TokenStream

4 years agoUpdated documentation of Prefix::VerbatimDisk
SOFe [Fri, 15 May 2020 14:41:36 +0000 (22:41 +0800)]
Updated documentation of Prefix::VerbatimDisk

PrefixComponent with Prefix::VerbatimDisk does not contain the trailing slash. The documentation here is also inconsistent with the documentation on other variants that reflect the `PrefixComponent::as_os_str()` return value.

4 years agoRemove lang_items\(\).*\.unwrap\(\)
Nathan Corbyn [Thu, 14 May 2020 21:06:44 +0000 (22:06 +0100)]
Remove lang_items\(\).*\.unwrap\(\)

4 years agoAuto merge of #69659 - CAD97:step-rework-take-3, r=Amanieu
bors [Fri, 15 May 2020 11:24:50 +0000 (11:24 +0000)]
Auto merge of #69659 - CAD97:step-rework-take-3, r=Amanieu

Rework the std::iter::Step trait

Previous attempts: #43127 #62886 #68807
Tracking issue: #42168

This PR reworks the `Step` trait to be phrased in terms of the *successor* and *predecessor* operations. With this, `Step` hopefully has a consistent identity that can have a path towards stabilization. The proposed trait:

```rust
/// Objects that have a notion of *successor* and *predecessor* operations.
///
/// The *successor* operation moves towards values that compare greater.
/// The *predecessor* operation moves towards values that compare lesser.
///
/// # Safety
///
/// This trait is `unsafe` because its implementation must be correct for
/// the safety of `unsafe trait TrustedLen` implementations, and the results
/// of using this trait can otherwise be trusted by `unsafe` code to be correct
/// and fulful the listed obligations.
pub unsafe trait Step: Clone + PartialOrd + Sized {
    /// Returns the number of *successor* steps required to get from `start` to `end`.
    ///
    /// Returns `None` if the number of steps would overflow `usize`
    /// (or is infinite, or if `end` would never be reached).
    ///
    /// # Invariants
    ///
    /// For any `a`, `b`, and `n`:
    ///
    /// * `steps_between(&a, &b) == Some(n)` if and only if `Step::forward(&a, n) == Some(b)`
    /// * `steps_between(&a, &b) == Some(n)` if and only if `Step::backward(&a, n) == Some(a)`
    /// * `steps_between(&a, &b) == Some(n)` only if `a <= b`
    ///   * Corollary: `steps_between(&a, &b) == Some(0)` if and only if `a == b`
    ///   * Note that `a <= b` does _not_ imply `steps_between(&a, &b) != None`;
    ///     this is the case wheen it would require more than `usize::MAX` steps to get to `b`
    /// * `steps_between(&a, &b) == None` if `a > b`
    fn steps_between(start: &Self, end: &Self) -> Option<usize>;

    /// Returns the value that would be obtained by taking the *successor*
    /// of `self` `count` times.
    ///
    /// If this would overflow the range of values supported by `Self`, returns `None`.
    ///
    /// # Invariants
    ///
    /// For any `a`, `n`, and `m`:
    ///
    /// * `Step::forward_checked(a, n).and_then(|x| Step::forward_checked(x, m)) == Step::forward_checked(a, m).and_then(|x| Step::forward_checked(x, n))`
    ///
    /// For any `a`, `n`, and `m` where `n + m` does not overflow:
    ///
    /// * `Step::forward_checked(a, n).and_then(|x| Step::forward_checked(x, m)) == Step::forward_checked(a, n + m)`
    ///
    /// For any `a` and `n`:
    ///
    /// * `Step::forward_checked(a, n) == (0..n).try_fold(a, |x, _| Step::forward_checked(&x, 1))`
    ///   * Corollary: `Step::forward_checked(&a, 0) == Some(a)`
    fn forward_checked(start: Self, count: usize) -> Option<Self>;

    /// Returns the value that would be obtained by taking the *successor*
    /// of `self` `count` times.
    ///
    /// If this would overflow the range of values supported by `Self`,
    /// this function is allowed to panic, wrap, or saturate.
    /// The suggested behavior is to panic when debug assertions are enabled,
    /// and to wrap or saturate otherwise.
    ///
    /// Unsafe code should not rely on the correctness of behavior after overflow.
    ///
    /// # Invariants
    ///
    /// For any `a`, `n`, and `m`, where no overflow occurs:
    ///
    /// * `Step::forward(Step::forward(a, n), m) == Step::forward(a, n + m)`
    ///
    /// For any `a` and `n`, where no overflow occurs:
    ///
    /// * `Step::forward_checked(a, n) == Some(Step::forward(a, n))`
    /// * `Step::forward(a, n) == (0..n).fold(a, |x, _| Step::forward(x, 1))`
    ///   * Corollary: `Step::forward(a, 0) == a`
    /// * `Step::forward(a, n) >= a`
    /// * `Step::backward(Step::forward(a, n), n) == a`
    fn forward(start: Self, count: usize) -> Self {
        Step::forward_checked(start, count).expect("overflow in `Step::forward`")
    }

    /// Returns the value that would be obtained by taking the *successor*
    /// of `self` `count` times.
    ///
    /// # Safety
    ///
    /// It is undefined behavior for this operation to overflow the
    /// range of values supported by `Self`. If you cannot guarantee that this
    /// will not overflow, use `forward` or `forward_checked` instead.
    ///
    /// # Invariants
    ///
    /// For any `a`:
    ///
    /// * if there exists `b` such that `b > a`, it is safe to call `Step::forward_unchecked(a, 1)`
    /// * if there exists `b`, `n` such that `steps_between(&a, &b) == Some(n)`,
    ///   it is safe to call `Step::forward_unchecked(a, m)` for any `m <= n`.
    ///
    /// For any `a` and `n`, where no overflow occurs:
    ///
    /// * `Step::forward_unchecked(a, n)` is equivalent to `Step::forward(a, n)`
    #[unstable(feature = "unchecked_math", reason = "niche optimization path", issue = "none")]
    unsafe fn forward_unchecked(start: Self, count: usize) -> Self {
        Step::forward(start, count)
    }

    /// Returns the value that would be obtained by taking the *successor*
    /// of `self` `count` times.
    ///
    /// If this would overflow the range of values supported by `Self`, returns `None`.
    ///
    /// # Invariants
    ///
    /// For any `a`, `n`, and `m`:
    ///
    /// * `Step::backward_checked(a, n).and_then(|x| Step::backward_checked(x, m)) == n.checked_add(m).and_then(|x| Step::backward_checked(a, x))`
    /// * `Step::backward_checked(a, n).and_then(|x| Step::backward_checked(x, m)) == try { Step::backward_checked(a, n.checked_add(m)?) }`
    ///
    /// For any `a` and `n`:
    ///
    /// * `Step::backward_checked(a, n) == (0..n).try_fold(a, |x, _| Step::backward_checked(&x, 1))`
    ///   * Corollary: `Step::backward_checked(&a, 0) == Some(a)`
    fn backward_checked(start: Self, count: usize) -> Option<Self>;

    /// Returns the value that would be obtained by taking the *predecessor*
    /// of `self` `count` times.
    ///
    /// If this would overflow the range of values supported by `Self`,
    /// this function is allowed to panic, wrap, or saturate.
    /// The suggested behavior is to panic when debug assertions are enabled,
    /// and to wrap or saturate otherwise.
    ///
    /// Unsafe code should not rely on the correctness of behavior after overflow.
    ///
    /// # Invariants
    ///
    /// For any `a`, `n`, and `m`, where no overflow occurs:
    ///
    /// * `Step::backward(Step::backward(a, n), m) == Step::backward(a, n + m)`
    ///
    /// For any `a` and `n`, where no overflow occurs:
    ///
    /// * `Step::backward_checked(a, n) == Some(Step::backward(a, n))`
    /// * `Step::backward(a, n) == (0..n).fold(a, |x, _| Step::backward(x, 1))`
    ///   * Corollary: `Step::backward(a, 0) == a`
    /// * `Step::backward(a, n) <= a`
    /// * `Step::forward(Step::backward(a, n), n) == a`
    fn backward(start: Self, count: usize) -> Self {
        Step::backward_checked(start, count).expect("overflow in `Step::backward`")
    }

    /// Returns the value that would be obtained by taking the *predecessor*
    /// of `self` `count` times.
    ///
    /// # Safety
    ///
    /// It is undefined behavior for this operation to overflow the
    /// range of values supported by `Self`. If you cannot guarantee that this
    /// will not overflow, use `backward` or `backward_checked` instead.
    ///
    /// # Invariants
    ///
    /// For any `a`:
    ///
    /// * if there exists `b` such that `b < a`, it is safe to call `Step::backward_unchecked(a, 1)`
    /// * if there exists `b`, `n` such that `steps_between(&b, &a) == Some(n)`,
    ///   it is safe to call `Step::backward_unchecked(a, m)` for any `m <= n`.
    ///
    /// For any `a` and `n`, where no overflow occurs:
    ///
    /// * `Step::backward_unchecked(a, n)` is equivalent to `Step::backward(a, n)`
    #[unstable(feature = "unchecked_math", reason = "niche optimization path", issue = "none")]
    unsafe fn backward_unchecked(start: Self, count: usize) -> Self {
        Step::backward(start, count)
    }
}
```

Note that all of these are associated functions and not callable via method syntax; the calling syntax is always `Step::forward(start, n)`. This version of the trait additionally changes the stepping functions to talk their arguments by value.

As opposed to previous attempts which provided a "step by one" method directly, this version of the trait only exposes "step by n". There are a few reasons for this:

- `Range*`, the primary consumer of `Step`, assumes that the "step by n" operation is cheap. If a single step function is provided, it will be a lot more enticing to implement "step by n" as n repeated calls to "step by one". While this is not strictly incorrect, this behavior would be surprising for anyone used to using `Range<{primitive integer}>`.
- With a trivial default impl, this can be easily added backwards-compatibly later.
- The debug-wrapping "step by n" needs to exist for `RangeFrom` to be consistent between "step by n" and "step by one" operation. (Note: the behavior is not changed by this PR, but making the behavior consistent is made tenable by this PR.)

Three "kinds" of step are provided: `_checked`, which returns an `Option` indicating attempted overflow; (unsuffixed), which provides "safe overflow" behavior (is allowed to panic, wrap, or saturate, depending on what is most convenient for a given type); and `_unchecked`, which is a version which assumes overflow does not happen.

Review is appreciated to check that:

- The invariants as described on the `Step` functions are enough to specify the "common sense" consistency for successor/predecessor.
- Implementation of `Step` functions is correct in the face of overflow and the edges of representable integers.
- Added tests of `Step` functions are asserting the correct behavior (and not just the implemented behavior).

4 years agoimplement type_implments_trait query
csmoe [Thu, 14 May 2020 15:07:46 +0000 (23:07 +0800)]
implement type_implments_trait query

4 years agodoc: add links to rotate_(left|right)
Lzu Tao [Fri, 15 May 2020 04:49:23 +0000 (04:49 +0000)]
doc: add links to rotate_(left|right)

4 years agoAuto merge of #72222 - Dylan-DPC:rollup-vaw44dg, r=Dylan-DPC
bors [Fri, 15 May 2020 02:56:38 +0000 (02:56 +0000)]
Auto merge of #72222 - Dylan-DPC:rollup-vaw44dg, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #71809 (Use `LocalDefId` in `DumpVisitor::nest_tables`)
 - #72062 (Add built in PSP target)
 - #72146 (Provide separate option for std debug asserts)
 - #72172 (Forbid stage arguments to check)
 - #72173 (Make intra links work inside trait impl block)
 - #72200 (Add prioritize_on attribute to triagebot)
 - #72214 (Minor fixes to comments)

Failed merges:

r? @ghost

4 years agoRollup merge of #72214 - JOE1994:nitpicky, r=jonas-schievink
Dylan DPC [Thu, 14 May 2020 23:57:24 +0000 (01:57 +0200)]
Rollup merge of #72214 - JOE1994:nitpicky, r=jonas-schievink

Minor fixes to comments

* In 'src/librustc_ast_passes/node_count.rs'
  * typo fix ('rought' -> 'rough')
* In 'src/librustc_middle/middle/region.rs',
  * fixed broken link to 'rustc-dev-guide'
  * typo fix ('aluded' -> 'alluded')

Thank you for reviewing this PR :)

4 years agoRollup merge of #72200 - spastorino:add-prioritize_on-to-triagebot, r=Mark-Simulacrum
Dylan DPC [Thu, 14 May 2020 23:57:22 +0000 (01:57 +0200)]
Rollup merge of #72200 - spastorino:add-prioritize_on-to-triagebot, r=Mark-Simulacrum

Add prioritize_on attribute to triagebot

r? @Mark-Simulacrum

4 years agoRollup merge of #72173 - xliiv:54172-intra-for-trait-impl, r=GuillaumeGomez
Dylan DPC [Thu, 14 May 2020 23:57:20 +0000 (01:57 +0200)]
Rollup merge of #72173 - xliiv:54172-intra-for-trait-impl, r=GuillaumeGomez

Make intra links work inside trait impl block

Closes #54172

4 years agoRollup merge of #72172 - Mark-Simulacrum:check-no-stage, r=alexcrichton
Dylan DPC [Thu, 14 May 2020 23:57:19 +0000 (01:57 +0200)]
Rollup merge of #72172 - Mark-Simulacrum:check-no-stage, r=alexcrichton

Forbid stage arguments to check

Users generally expect that check builds are fast, and that's only true in stage
0 (stages beyond that need us to build a compiler, which is slow).

Closes #69337

r? @alexcrichton

4 years agoRollup merge of #72146 - Mark-Simulacrum:separate-std-asserts, r=alexcrichton
Dylan DPC [Thu, 14 May 2020 23:57:17 +0000 (01:57 +0200)]
Rollup merge of #72146 - Mark-Simulacrum:separate-std-asserts, r=alexcrichton

Provide separate option for std debug asserts

On local one-off benchmarking of libcore metadata-only, debug asserts in std are a significant hit (15s to 20s). Provide an option for compiler developers to disable them. A build with a nightly compiler is around 10s, for reference.

4 years agoRollup merge of #72062 - overdrivenpotato:psp, r=jonas-schievink
Dylan DPC [Thu, 14 May 2020 23:57:15 +0000 (01:57 +0200)]
Rollup merge of #72062 - overdrivenpotato:psp, r=jonas-schievink

Add built in PSP target

This adds a new target, `mipsel-sony-psp`, corresponding to the Sony PSP. The linker script is necessary to handle special sections, which are required by the target. This has been tested with my [rust-psp] crate and I can confirm it works as intended.

The linker script is taken from [here]. It has been slightly adapted to work with rust and LLD.

The `stdarch` submodule was also updated in order for `libcore` to build successfully.

[rust-psp]: https://github.com/overdrivenpotato/rust-psp
[here]: https://github.com/pspdev/pspsdk/blob/master/src/base/linkfile.prx.in

4 years agoRollup merge of #71809 - marmeladema:fix-issue-71104, r=eddyb
Dylan DPC [Thu, 14 May 2020 23:57:07 +0000 (01:57 +0200)]
Rollup merge of #71809 - marmeladema:fix-issue-71104, r=eddyb

Use `LocalDefId` in `DumpVisitor::nest_tables`

This is a partial fix for #71104

4 years agoAuto merge of #71321 - matthewjasper:alloc-min-spec, r=sfackler
bors [Thu, 14 May 2020 23:22:47 +0000 (23:22 +0000)]
Auto merge of #71321 - matthewjasper:alloc-min-spec, r=sfackler

Use min_specialization in liballoc

- Remove a type parameter from `[A]RcFromIter`.
- Remove an implementation of `[A]RcFromIter` that didn't actually
  specialize anything.
- Remove unused implementation of `IsZero` for `Option<&mut T>`.
- Change specializations of `[A]RcEqIdent` to use a marker trait version
of `Eq`.
- Remove `BTreeClone`. I couldn't find a way to make this work with
  `min_specialization`.
- Add `rustc_unsafe_specialization_marker` to `Copy` and `TrustedLen`.

After this only libcore is the only standard library crate using `feature(specialization)`.
cc #31844

4 years ago[const-prop] Don't replace Rvalues that are already constants
Wesley Wiser [Thu, 23 Apr 2020 21:09:21 +0000 (17:09 -0400)]
[const-prop] Don't replace Rvalues that are already constants

4 years agoAdd prioritize_on attribute to triagebot
Santiago Pastorino [Thu, 14 May 2020 16:03:33 +0000 (13:03 -0300)]
Add prioritize_on attribute to triagebot

4 years agomake sure even unleashed miri does not do pointer stuff
Ralf Jung [Thu, 14 May 2020 21:29:50 +0000 (23:29 +0200)]
make sure even unleashed miri does not do pointer stuff

4 years agoimprove step_integer_impls macro
CAD97 [Thu, 14 May 2020 20:57:02 +0000 (16:57 -0400)]
improve step_integer_impls macro

4 years agoMinor fixes to comments
JOE1994 [Thu, 14 May 2020 20:39:36 +0000 (16:39 -0400)]
Minor fixes to comments
* In 'src/librustc_ast_passes/node_count.rs'
  * typo fix ('rought' -> 'rough')
* In 'src/librustc_middle/middle/region.rs',
  * fixed broken link to 'rustc-dev-guide'
  * typo fix ('aluded' -> 'alluded')

Thank you for reviewing this PR :)

4 years agoAuto merge of #72202 - Dylan-DPC:rollup-6lbxh1s, r=Dylan-DPC
bors [Thu, 14 May 2020 19:35:24 +0000 (19:35 +0000)]
Auto merge of #72202 - Dylan-DPC:rollup-6lbxh1s, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #71910 (Fix unused_parens false positive when using binary operations)
 - #72087 (Fix hang in lexical_region_resolve)
 - #72126 (Change `WorkProduct::saved_files` to an `Option`.)
 - #72127 (add long error explanation for E0228)
 - #72141 (Warn against thread::sleep in async fn)
 - #72170 (use `require_lang_item` over `unwrap`.)
 - #72191 (Clean up E0589 explanation)
 - #72194 (Don't ICE on missing `Unsize` impl)

Failed merges:

r? @ghost

4 years agocleanup stale FIXME(#64197)
sergey-melnychuk [Thu, 14 May 2020 18:02:40 +0000 (20:02 +0200)]
cleanup stale FIXME(#64197)

4 years agoRollup merge of #72194 - doctorn:dispatch-from-dyn-ice, r=estebank
Dylan DPC [Thu, 14 May 2020 16:21:59 +0000 (18:21 +0200)]
Rollup merge of #72194 - doctorn:dispatch-from-dyn-ice, r=estebank

Don't ICE on missing `Unsize` impl

Previously code of the form

```rust
#![feature(unsize, dispatch_from_dyn)]

use std::marker::Unsize;
use std::ops::DispatchFromDyn;

pub struct Foo<'a, T: ?Sized> {
    _inner: &'a &'a T,
}

impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T> {}
```

would generate an ICE due to the missing `Unsize` impl being run through the `suggest_change_mut` suggestion. This PR adds an early exit and a pointer to the appropriate docs regarding `Unsize` instead:

```
error[E0277]: the trait bound `&'a T: std::marker::Unsize<&'a U>` is not satisfied
  --> src/test/ui/issues/issue-71036.rs:11:1
   |
11 | impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T> {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unsize<&'a U>` is not implemented for `&'a T`
   |
   = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information
   = note: required because of the requirements on the impl of `std::ops::DispatchFromDyn<&'a &'a U>` for `&'a &'a T`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
```

r? @estebank

Resolves #71036

4 years agoRollup merge of #72191 - GuillaumeGomez:cleanup-e0589, r=Dylan-DPC
Dylan DPC [Thu, 14 May 2020 16:21:57 +0000 (18:21 +0200)]
Rollup merge of #72191 - GuillaumeGomez:cleanup-e0589, r=Dylan-DPC

Clean up E0589 explanation

r? @Dylan-DPC

4 years agoRollup merge of #72170 - lcnr:lang_item, r=oli-obk
Dylan DPC [Thu, 14 May 2020 16:21:55 +0000 (18:21 +0200)]
Rollup merge of #72170 - lcnr:lang_item, r=oli-obk

use `require_lang_item` over `unwrap`.

Does not yet replace all uses of `lang_items\(\)\.*\.unwrap\(\)`, as there are more
than I expected :sweat_smile:

Fixes #72099

r? @RalfJung

*edit: The goal of this this PR is to change ICE from missing lang items to a fatal error.*

4 years agoRollup merge of #72141 - kornelski:dontsleep, r=joshtriplett
Dylan DPC [Thu, 14 May 2020 16:21:53 +0000 (18:21 +0200)]
Rollup merge of #72141 - kornelski:dontsleep, r=joshtriplett

Warn against thread::sleep in async fn

I've seen `thread::sleep` wrecking havoc in async servers. There's already an [issue for clippy](https://github.com/rust-lang/rust-clippy/issues/4377), but the std docs could warn against it too.

4 years agoRollup merge of #72127 - jademcgough:long-error-explanation-E0228, r=petrochenkov
Dylan DPC [Thu, 14 May 2020 16:21:51 +0000 (18:21 +0200)]
Rollup merge of #72127 - jademcgough:long-error-explanation-E0228, r=petrochenkov

add long error explanation for E0228

Add long explanation for the E0228 error code
Part of #61137

Let me know if this is wrong at all (or can be written more clearly), I'm still learning Rust.

4 years agoRollup merge of #72126 - nnethercote:change-WorkProduct-saved_files, r=alexcrichton
Dylan DPC [Thu, 14 May 2020 16:21:50 +0000 (18:21 +0200)]
Rollup merge of #72126 - nnethercote:change-WorkProduct-saved_files, r=alexcrichton

Change `WorkProduct::saved_files` to an `Option`.

Because there is at most one file.

r? @bjorn3

4 years agoRollup merge of #72087 - matthewjasper:regionck-hang, r=nikomatsakis
Dylan DPC [Thu, 14 May 2020 16:21:48 +0000 (18:21 +0200)]
Rollup merge of #72087 - matthewjasper:regionck-hang, r=nikomatsakis

Fix hang in lexical_region_resolve

Regionck was stuck in a loop where a region value was changing between two equal regions.

Closes #72051

4 years agoRollup merge of #71910 - mibac138:necessary-paren, r=cuviper
Dylan DPC [Thu, 14 May 2020 16:21:46 +0000 (18:21 +0200)]
Rollup merge of #71910 - mibac138:necessary-paren, r=cuviper

Fix unused_parens false positive when using binary operations

Fixes #71290

r? @cuviper who provided instructions

4 years agoDon't ICE on missing `Unsize` impl
Nathan Corbyn [Thu, 14 May 2020 10:37:58 +0000 (11:37 +0100)]
Don't ICE on missing `Unsize` impl

4 years agoAuto merge of #72187 - RalfJung:rollup-a7a9jdi, r=RalfJung
bors [Thu, 14 May 2020 12:28:23 +0000 (12:28 +0000)]
Auto merge of #72187 - RalfJung:rollup-a7a9jdi, r=RalfJung

Rollup of 12 pull requests

Successful merges:

 - #71525 (`prefix` should not be mutable.)
 - #71741 (Pointer printing: do not print 0 offset)
 - #71870 (Be slightly more precise about any::type_name()'s guarantees.)
 - #71909 (Document From trait for Option implementations)
 - #71964 (Fix bootstrap failing on win32)
 - #72137 (Clean up E0581 explanation)
 - #72138 (Add doc comment for `rustc_middle::mir::mono::Linkage`)
 - #72150 (Remove UnnormalizedProjection)
 - #72151 (Update books)
 - #72163 (docs: remove comment referencing non-existent method)
 - #72169 (Clean up E0582 explanation)
 - #72183 (Fix Arc::decr_strong_count doc test)

Failed merges:

r? @ghost

4 years agoRewrite link script from scratch
Marko Mijalkovic [Thu, 14 May 2020 10:19:36 +0000 (06:19 -0400)]
Rewrite link script from scratch

This absolves previous licensing issues.

4 years agoClean up E0589 explanation
Guillaume Gomez [Thu, 14 May 2020 09:51:39 +0000 (11:51 +0200)]
Clean up E0589 explanation

4 years ago* Update aliases data struct from HashMap to BTreeMap to have more deterministic...
Guillaume Gomez [Wed, 13 May 2020 15:03:37 +0000 (17:03 +0200)]
* Update aliases data struct from HashMap to BTreeMap to have more deterministic results
  * Update Javascript to take this change into account
* Update CrateData::aliases field to take a reference instead (it allowed to remove a conversion loop)

4 years agoMake current crate aliases go first
Guillaume Gomez [Thu, 7 May 2020 19:42:41 +0000 (21:42 +0200)]
Make current crate aliases go first

4 years agoMove doc alias discovery into the Attributes struct and some code improvements
Guillaume Gomez [Mon, 4 May 2020 13:26:17 +0000 (15:26 +0200)]
Move doc alias discovery into the Attributes struct and some code improvements

4 years agoRollup merge of #72183 - tmiasko:decr-strong-count, r=Mark-Simulacrum
Ralf Jung [Thu, 14 May 2020 08:23:06 +0000 (10:23 +0200)]
Rollup merge of #72183 - tmiasko:decr-strong-count, r=Mark-Simulacrum

Fix Arc::decr_strong_count doc test

4 years agoRollup merge of #72169 - GuillaumeGomez:cleanup-e0582, r=Dylan-DPC
Ralf Jung [Thu, 14 May 2020 08:23:05 +0000 (10:23 +0200)]
Rollup merge of #72169 - GuillaumeGomez:cleanup-e0582, r=Dylan-DPC

Clean up E0582 explanation

r? @Dylan-DPC

4 years agoRollup merge of #72163 - tshepang:nonexistent-link, r=matthewjasper
Ralf Jung [Thu, 14 May 2020 08:23:03 +0000 (10:23 +0200)]
Rollup merge of #72163 - tshepang:nonexistent-link, r=matthewjasper

docs: remove comment referencing non-existent method

4 years agoRollup merge of #72151 - ehuss:update-books, r=ehuss
Ralf Jung [Thu, 14 May 2020 08:23:01 +0000 (10:23 +0200)]
Rollup merge of #72151 - ehuss:update-books, r=ehuss

Update books

## book

2 commits in e37c0e84e2ef73d3a4ebffda8011db6814a3b02d..6247be15a7f7509559f7981ee2209b9e0cc121df
2020-04-26 09:31:36 -0500 to 2020-05-03 10:55:09 -0500
- Fix guessing game listing explanation (rust-lang/book#2321)
- Update ch01-01-installation.md (rust-lang/book#2325)

## edition-guide

1 commits in 8204c1d123472cd17f0c1c5c77300ae802eb0271..49270740c7a4bff2763e6bc730b191d45b7d5167
2020-04-09 18:55:50 -0700 to 2020-05-11 08:50:29 -0500
- Use rust-lang/rust linkchecker on CI. (rust-lang/edition-guide#197)

## embedded-book

1 commits in 40beccdf1bb8eb9184a2e3b42db8b8c6e394247f..366c50a03bed928589771eba8a6f18e0c0c01d23
2020-04-26 17:44:14 +0000 to 2020-05-07 09:04:42 +0000
- Add HAL patterns/guidelines/recommendations  (rust-embedded/book#235)

## nomicon

3 commits in 4d2d275997746d35eabfc4d992dfbdcce2f626ed..d1517d4e3f29264c5c67bce2658516bb5202c800
2020-04-27 10:24:52 -0400 to 2020-05-12 13:47:00 -0400
- Rename Unique::empty to Unique::dangling
- Use simpler link syntax
- Replace catch_panic by catch_unwind

## reference

3 commits in ed22e6fbfcb6ce436e9ea3b4bb4a55b2fb50a57e..892b928b565e35d25b6f9c47faee03b94bc41489
2020-04-24 12:46:22 -0700 to 2020-05-11 11:13:51 -0700
- clarify that str data must still be initialized
- remove language-level UB for non-UTF-8 str
- Replace incorrect term "parent modules" with "ancestor modules". (rust-lang/reference#806)

## rust-by-example

2 commits in ffc99581689fe2455908aaef5f5cf50dd03bb8f5..ab072b14393cbd9e8a1d1d75879bf51e27217bbb
2020-04-24 15:05:04 -0300 to 2020-05-09 08:46:39 -0300
- Fix link of formatting traits (rust-lang/rust-by-example#1346)
- Remove stale footnote (rust-lang/rust-by-example#1345)

4 years agoRollup merge of #72150 - jackh726:unnorm_projection, r=nikomatsakis
Ralf Jung [Thu, 14 May 2020 08:22:59 +0000 (10:22 +0200)]
Rollup merge of #72150 - jackh726:unnorm_projection, r=nikomatsakis

Remove UnnormalizedProjection

This was only used for the old chalk integration with chalk-engine

r? @nikomatsakis

4 years agoRollup merge of #72138 - wesleywiser:add_doc_comment, r=matthewjasper
Ralf Jung [Thu, 14 May 2020 08:22:57 +0000 (10:22 +0200)]
Rollup merge of #72138 - wesleywiser:add_doc_comment, r=matthewjasper

Add doc comment for `rustc_middle::mir::mono::Linkage`

4 years agoRollup merge of #72137 - GuillaumeGomez:cleanup-e0581, r=Dylan-DPC
Ralf Jung [Thu, 14 May 2020 08:22:55 +0000 (10:22 +0200)]
Rollup merge of #72137 - GuillaumeGomez:cleanup-e0581, r=Dylan-DPC

Clean up E0581 explanation

r? @Dylan-DPC

4 years agoRollup merge of #71964 - jcotton42:bootstrap_decode_none_windows, r=Mark-Simulacrum
Ralf Jung [Thu, 14 May 2020 08:22:54 +0000 (10:22 +0200)]
Rollup merge of #71964 - jcotton42:bootstrap_decode_none_windows, r=Mark-Simulacrum

Fix bootstrap failing on win32

```powershell
python x.py -h # or really any x.py command
```
would fail with
```
info: Downloading and building bootstrap before processing --help
      command. See src/bootstrap/README.md for help with common
      commands.
Updating only changed submodules
Submodules updated in 0.15 seconds
Traceback (most recent call last):
  File "x.py", line 11, in <module>
    bootstrap.main()
  File "C:\Users\Joshua\Projects\forks\rust\src\bootstrap\bootstrap.py", line 960, in main
    bootstrap(help_triggered)
  File "C:\Users\Joshua\Projects\forks\rust\src\bootstrap\bootstrap.py", line 925, in bootstrap
    build.build = args.build or build.build_triple()
  File "C:\Users\Joshua\Projects\forks\rust\src\bootstrap\bootstrap.py", line 731, in build_triple
    return default_build_triple()
  File "C:\Users\Joshua\Projects\forks\rust\src\bootstrap\bootstrap.py", line 184, in default_build_triple
    ostype = require(["uname", "-s"], exit=required).decode(default_encoding)
AttributeError: 'NoneType' object has no attribute 'decode'
```

This PR defers the `decode` call until after we're sure `ostype` and `cputype` are not `None`, as they would be on Windows since `uname` doesn't exist

4 years agoRollup merge of #71909 - Dolpheyn:doc-from-trait-for-option, r=steveklabnik
Ralf Jung [Thu, 14 May 2020 08:22:52 +0000 (10:22 +0200)]
Rollup merge of #71909 - Dolpheyn:doc-from-trait-for-option, r=steveklabnik

Document From trait for Option implementations

Add documentation for ```From``` trait for ```std::option::Option``` implementations

This PR solves a part of #51430 ( CC @skade )

This is my first PR ever in contributing for OSS. I'm happy to learn and make any changes if necessary :)

4 years agoRollup merge of #71870 - ltratt:more_specific_type_name_doc, r=kennytm
Ralf Jung [Thu, 14 May 2020 08:22:50 +0000 (10:22 +0200)]
Rollup merge of #71870 - ltratt:more_specific_type_name_doc, r=kennytm

Be slightly more precise about any::type_name()'s guarantees.

The first commit in this PR rephrases the current documentation for `any::type_name()` to be a little more specific about the guarantees (or lack thereof) that this function makes. The second commit explicitly documents that lifetimes are currently not included in the output (since this bit me particularly hard recently).

4 years agoRollup merge of #71741 - RalfJung:pointer-print, r=oli-obk
Ralf Jung [Thu, 14 May 2020 08:22:48 +0000 (10:22 +0200)]
Rollup merge of #71741 - RalfJung:pointer-print, r=oli-obk

Pointer printing: do not print 0 offset

r? @eddyb Cc @oli-obk

4 years agoRollup merge of #71525 - ldm0:intosug, r=Mark-Simulacrum
Ralf Jung [Thu, 14 May 2020 08:22:40 +0000 (10:22 +0200)]
Rollup merge of #71525 - ldm0:intosug, r=Mark-Simulacrum

`prefix` should not be mutable.

Change the process from for loop to find, which makes the `prefix` able to be immutable.

4 years agoAuto merge of #69756 - wesleywiser:simplify_try, r=oli-obk
bors [Thu, 14 May 2020 06:22:40 +0000 (06:22 +0000)]
Auto merge of #69756 - wesleywiser:simplify_try, r=oli-obk

Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1

I also added test cases to make sure the optimization can fire on all of
these cases:

```rust
fn case_1(o: Option<u8>) -> Option<u8> {
  match o {
    Some(u) => Some(u),
    None => None,
  }
}

fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
  match r {
    Ok(u) => Ok(u),
    Err(i) => Err(i),
  }
}

fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
  let u = r?;
  Ok(u)
}

```

Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:

- We can now run the pass on mir-opt-level=1

- We no longer depend on the copy propagation pass running which is
  unlikely to stabilize anytime soon.

Fixes #66855

4 years agoAuto merge of #72058 - RalfJung:no-dist-lldb, r=Mark-Simulacrum
bors [Thu, 14 May 2020 02:50:34 +0000 (02:50 +0000)]
Auto merge of #72058 - RalfJung:no-dist-lldb, r=Mark-Simulacrum

bootstrap: remove lldb dist packaging

The lldb-preview rustup package is missing on every single target, and has never been shipped beyond x86_64-apple-darwin. It was removed in #62592 which landed around a year ago, and there's not been demand that we re-enable it since, so we're now removing support entirely to cleanup the code a bit.

The hope is that this will also kill the useless "lldb-preview" row on https://rust-lang.github.io/rustup-components-history/.

4 years agoFix Arc::decr_strong_count doc test
Tomasz Miąsko [Thu, 14 May 2020 00:00:00 +0000 (00:00 +0000)]
Fix Arc::decr_strong_count doc test

4 years agoImprove Step::forward/backward for optimization
CAD97 [Wed, 13 May 2020 21:57:06 +0000 (17:57 -0400)]
Improve Step::forward/backward for optimization

The previous definition did not optimize down to a single add operation,
but this version does appear to.

4 years agoAuto merge of #72118 - flip1995:clippyup, r=oli-obk
bors [Wed, 13 May 2020 21:15:09 +0000 (21:15 +0000)]
Auto merge of #72118 - flip1995:clippyup, r=oli-obk

Update Clippy to 43a1777

Updates Clippy to https://github.com/rust-lang/rust-clippy/commit/43a1777b89cf6791f9e20878b4e5e3ae907867a5

We should establish a process on how often and when to update Clippy. (After X feature PRs? Once per week? Only on bug fixes and in the release week? ...?)

r? @oli-obk

4 years agodocs: fix link
Tshepang Lekhonkhobe [Wed, 13 May 2020 21:02:56 +0000 (23:02 +0200)]
docs: fix link

source https://github.com/rust-lang/rust/pull/72163#issuecomment-628234966

4 years agoadd spans to `require_lang_items`
Bastian Kauschke [Wed, 13 May 2020 19:38:58 +0000 (21:38 +0200)]
add spans to `require_lang_items`

4 years agoImprove comments in iter::Step
CAD97 [Wed, 13 May 2020 18:49:45 +0000 (14:49 -0400)]
Improve comments in iter::Step

4 years agoMake intra links work inside trait impl block
Tymoteusz Jankowski [Wed, 13 May 2020 14:54:16 +0000 (16:54 +0200)]
Make intra links work inside trait impl block

4 years agoForbid stage arguments to check
Mark Rousskov [Wed, 13 May 2020 15:32:43 +0000 (11:32 -0400)]
Forbid stage arguments to check

Users generally expect that check builds are fast, and that's only true in stage
0 (stages beyond that need us to build a compiler, which is slow).

4 years agoAuto merge of #72013 - nnethercote:make-RawVec-grow-mostly-non-generic, r=Amanieu
bors [Wed, 13 May 2020 14:29:56 +0000 (14:29 +0000)]
Auto merge of #72013 - nnethercote:make-RawVec-grow-mostly-non-generic, r=Amanieu

Make `RawVec::grow` mostly non-generic.

`cargo-llvm-lines` shows that, in various benchmarks, `RawVec::grow` is
instantiated 10s or 100s of times and accounts for 1-8% of lines of
generated LLVM IR.

This commit moves most of `RawVec::grow` into a separate function that
isn't parameterized by `T`, which means it doesn't need to be
instantiated many times. This reduces compile time significantly.

r? @ghost

4 years agoUpdate src/libcore/option.rs
Faris Sufyan [Wed, 13 May 2020 13:13:35 +0000 (21:13 +0800)]
Update src/libcore/option.rs

Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
4 years agoUpdate src/libcore/option.rs
Faris Sufyan [Wed, 13 May 2020 13:13:27 +0000 (21:13 +0800)]
Update src/libcore/option.rs

Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
4 years agoUpdate src/libcore/option.rs
Faris Sufyan [Wed, 13 May 2020 13:13:17 +0000 (21:13 +0800)]
Update src/libcore/option.rs

Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
4 years agoUpdate src/libcore/option.rs
Faris Sufyan [Wed, 13 May 2020 13:13:08 +0000 (21:13 +0800)]
Update src/libcore/option.rs

Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
4 years agoUpdate src/libcore/option.rs
Faris Sufyan [Wed, 13 May 2020 13:12:50 +0000 (21:12 +0800)]
Update src/libcore/option.rs

Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
4 years agoUpdate src/libcore/option.rs
Faris Sufyan [Wed, 13 May 2020 13:12:35 +0000 (21:12 +0800)]
Update src/libcore/option.rs

Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
4 years agoUpdate src/libcore/option.rs
Faris Sufyan [Wed, 13 May 2020 13:05:53 +0000 (21:05 +0800)]
Update src/libcore/option.rs

Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
4 years agoUpdate src/libcore/option.rs
Faris Sufyan [Wed, 13 May 2020 13:04:52 +0000 (21:04 +0800)]
Update src/libcore/option.rs

Co-authored-by: Steve Klabnik <steve@steveklabnik.com>