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 13 pull requests #62920

Closed
wants to merge 37 commits into from
Closed

Commits on Jun 30, 2019

  1. Configuration menu
    Copy the full SHA
    962bf69 View commit details
    Browse the repository at this point in the history

Commits on Jul 9, 2019

  1. Configuration menu
    Copy the full SHA
    5397dfc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    01d93bf View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    283f676 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b62a77b View commit details
    Browse the repository at this point in the history
  5. Update src/liballoc/slice.rs

    Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
    SimonSapin and Centril authored Jul 9, 2019
    Configuration menu
    Copy the full SHA
    d0635ee View commit details
    Browse the repository at this point in the history
  6. Update src/liballoc/slice.rs

    Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
    SimonSapin and Centril authored Jul 9, 2019
    Configuration menu
    Copy the full SHA
    bbc9366 View commit details
    Browse the repository at this point in the history
  7. Update src/liballoc/str.rs

    Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
    SimonSapin and Centril authored Jul 9, 2019
    Configuration menu
    Copy the full SHA
    5f7768a View commit details
    Browse the repository at this point in the history

Commits on Jul 15, 2019

  1. Configuration menu
    Copy the full SHA
    8c050fc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    dfbf464 View commit details
    Browse the repository at this point in the history
  3. 3 Configuration menu
    Copy the full SHA
    88eced5 View commit details
    Browse the repository at this point in the history

Commits on Jul 18, 2019

  1. Configuration menu
    Copy the full SHA
    bb9bf0c View commit details
    Browse the repository at this point in the history
  2. Suggest trait bound on type parameter when it is unconstrained

    Given
    
    ```
    mented on Jan 26, 2015 •
     trait Foo { fn method(&self) {} }
    
    fn call_method<T>(x: &T) {
        x.method()
    }
    ```
    
    suggest constraining `T` with `Foo`.
    estebank committed Jul 18, 2019
    Configuration menu
    Copy the full SHA
    f22bc2d View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2019

  1. rustc: Compile the fmt_macros crate as an rlib

    I think this was left out by accident from the "convert everything to
    rlibs" commit, there's no need for this to be a dylib just as everything
    else doesn't need to be a dylib!
    alexcrichton committed Jul 19, 2019
    Configuration menu
    Copy the full SHA
    c1b4d62 View commit details
    Browse the repository at this point in the history

Commits on Jul 22, 2019

  1. Configuration menu
    Copy the full SHA
    4b33968 View commit details
    Browse the repository at this point in the history

Commits on Jul 23, 2019

  1. Configuration menu
    Copy the full SHA
    f78cd4d View commit details
    Browse the repository at this point in the history
  2. Remove uses of mem::uninitialized in std::sys::cloudabi

    Usages still appear in cloudabi tests and in the reentrant mutex implementation
    nathanwhit committed Jul 23, 2019
    Configuration menu
    Copy the full SHA
    e1e0df8 View commit details
    Browse the repository at this point in the history
  3. Modify CloudABI ReentrantMutex to use MaybeUninit

    Remove uses of mem::uninitialized, which is now deprecated
    nathanwhit committed Jul 23, 2019
    Configuration menu
    Copy the full SHA
    82dd54b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6140371 View commit details
    Browse the repository at this point in the history
  5. Cleanup std::sys::cloudabi

    nathanwhit committed Jul 23, 2019
    Configuration menu
    Copy the full SHA
    0ac6afa View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b70f217 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    2083a12 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    ca8420c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    66815c6 View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#61890 - golddranks:fix_sanity_check_llvm, r…

    …=Dylan-DPC
    
    Fix some sanity checks
    
    Update: Changes that made it not to work dropped.
    
    * Fix `building_llvm` in sanity check
      * This was subtly broken: we build LLVM if any of the hosts builds LLVM, and not setting the config meant that LLVM is built for that target. Because of filtering away the targets not configured and the semantics of `Iterator::any`, it currently didn't set the `building_llvm` flag even if we indeed build it.
    * Add `swig` sanity check
      * This checks whether there is a `swig` executable needed for LLDB.
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    bf40f97 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#62261 - varkor:conservative_is_privately_un…

    …inhabited-subst, r=oli-obk
    
    Take substs into account in `conservative_is_privately_uninhabited`
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    57d2b28 View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#62528 - SimonSapin:concat, r=alexcrichton

    Add joining slices of slices with a slice separator, not just a single item
    
    rust-lang#27747 (comment)
    > It's kinda annoying to be able to join strings with a str (which can have multiple chars), but joining a slice of slices, you can only join with a single element.
    
    This turns out to be fixable, with some possible inference regressions.
    
    # TL;DR
    
    Related trait(s) are unstable and tracked at rust-lang#27747, but the `[T]::join` method that is being extended here is already stable.
    
    Example use of the new insta-stable functionality:
    
    ```rust
    let nested: Vec<Vec<Foo>> = /* … */;
    let separator: &[Foo] = /* … */;  // Previously: could only be a single &Foo
    nested.join(separator)
    ```
    
    Complete API affected by this PR, after changes:
    
    ```rust
    impl<T> [T] {
        pub fn concat<Item: ?Sized>(&self) -> <Self as Concat<Item>>::Output
            where Self: Concat<Item>
        {
            Concat::concat(self)
        }
        pub fn join<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
            where Self: Join<Separator>
        {
            Join::join(self, sep)
        }
    }
    
    // The `Item` parameter is only useful for the the slice-of-slices impl.
    pub trait Concat<Item: ?Sized> {
        type Output;
        fn concat(slice: &Self) -> Self::Output;
    }
    
    pub trait Join<Separator> {
        type Output;
        fn join(slice: &Self, sep: Separator) -> Self::Output;
    }
    
    impl<T: Clone, V: Borrow<[T]>> Concat<T> for [V] {
        type Output = Vec<T>;
    }
    
    impl<T: Clone, V: Borrow<[T]>> Join<&'_ T> for [V] {
        type Output = Vec<T>;
    }
    
    // New functionality here!
    impl<T: Clone, V: Borrow<[T]>> Join<&'_ [T]> for [V] {
        type Output = Vec<T>;
    }
    
    impl<S: Borrow<str>> Concat<str> for [S] {
        type Output = String;
    }
    
    impl<S: Borrow<str>> Join<&'_ str> for [S] {
        type Output = String;
    }
    ```
    
    # Details
    
    After rust-lang#62403 but before this PR, the API is:
    
    ```rust
    impl<T> [T] {
        pub fn concat<Separator: ?Sized>(&self) -> T::Output
            where T: SliceConcat<Separator>
        {
            SliceConcat::concat(self)
        }
    
        pub fn join<Separator: ?Sized>(&self, sep: &Separator) -> T::Output
            where T: SliceConcat<Separator>
        {
            SliceConcat::join(self, sep)
        }
    }
    
    pub trait SliceConcat<Separator: ?Sized>: Sized {
        type Output;
        fn concat(slice: &[Self]) -> Self::Output;
        fn join(slice: &[Self], sep: &Separator) -> Self::Output;
    }
    
    impl<T: Clone, V: Borrow<[T]>> SliceConcat<T> for V {
        type Output = Vec<T>;
    }
    
    impl<S: Borrow<str>> SliceConcat<str> for S {
        type Output = String;
    }
    ```
    
    By adding a trait impl we should be able to accept a slice of `T` as the separator, as an alternative to a single `T` value.
    
    In a `some_slice.join(some_separator)` call, trait resolution will pick an impl or the other based on the type of `some_separator`. In `some_slice.concat()` however there is no separator, so this call would become ambiguous. Some regression in type inference or trait resolution may be acceptable on principle, but requiring a turbofish for every single call to `concat` isn’t great.
    
    The solution to that is splitting the `SliceConcat` trait into two `Concat` and `Join` traits, one for each eponymous method. Only `Join` would gain a new impl, so that `some_slice.concat()` would not become ambiguous.
    
    Now, at the trait level the `Concat` trait does not need a `Separator` parameter anymore. However, simply removing it causes one of the impls not to be accepted anymore:
    
    ```rust
    error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
      --> src/liballoc/slice.rs:608:6
        |
    608 | impl<T: Clone, V: Borrow<[T]>> Concat for [V] {
        |      ^ unconstrained type parameter
    ```
    
    This makes sense: if `[V]::concat` is a method that is itself not generic, then its return type (which is the `Concat::Output` associated type) needs to be determined based on solely `V`. And although there is no such type in the standard library, there is nothing stopping another crate from defining a `V` type that implements both `Borrow<[Foo]>` and `Borrow<[Bar]>`. It might not be a good idea, but it’s possible. Both would apply here, and there would be no way to determine `T`.
    
    This could be a warning sign that this API is too generic. Perhaps we’d be better off having one less type variable, and only implement `Concat for [&'_ [T]]` and `Concat for [Vec<T>]` etc. However this aspect of `[V]::concat` is already stable, so we’re stuck with it.
    
    The solution is to keep a dummy type parameter on the `Concat` trait. That way, if a type has multiple `Borrow<[_]>` impls, it’ll end up with multiple corresponding `Concat<_>` impls.
    
    In `impl<S: Borrow<str>> Concat<str> for [S]`, the second occurrence of `str` is not meaningful. It could be any type. As long as there is only once such type with an applicable impl, trait resolution will be appeased without demanding turbofishes.
    
    # Joining strings with `char`
    
    For symmetry I also tried adding this impl (because why not):
    
    ```rust
    impl<S: Borrow<str>> Join<char> for [S] {
        type Output = String;
    }
    ```
    
    This immediately caused an inference regression in a dependency of rustc:
    
    ```rust
    error[E0277]: the trait bound `std::string::String: std::borrow::Borrow<[std::string::String]>` is not satisfied
       --> /home/simon/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/getopts-0.2.19/src/lib.rs:595:37
        |
    595 |             row.push_str(&desc_rows.join(&desc_sep));
        |                                     ^^^^ the trait `std::borrow::Borrow<[std::string::String]>` is not implemented for `std::string::String`
        |
        = help: the following implementations were found:
                  <std::string::String as std::borrow::Borrow<str>>
        = note: required because of the requirements on the impl of `std::slice::Join<&std::string::String>` for `[std::string::String]`
    ```
    
    In the context of this code, two facts are known:
    
    * `desc_rows` is a `Vec<String>`
    * `desc_sep` is a `String`
    
    Previously the first fact alone reduces the resolution of `join` to only one solution, where its argument it expected to be `&str`. Then, `&String` is coerced to `&str`.
    
    With the new `Join` impl, the first fact leavs two applicable impls where the separator can be either `&str` or `char`. But `&String` is neither of these things. It appears that possible coercions are not accounted for, in the search for a solution in trait resolution.
    
    I have not included this new impl in this PR. It’s still possible to add later, but the `getopts` breakage does not need to block the rest of the PR. And the functionality easy for end-user to duplicate: `slice_of_strings.join(&*char_separator.encode_utf8(&mut [0_u8, 4]))`
    
    The `&*` part of that last code snippet is another case of the same issue: `encode_utf8` returns `&mut str` which can be coerced to `&str`, but isn’t when trait resolution is ambiguous.
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    0cc5035 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#62692 - eddyb:precompute-niches, r=oli-obk

    rustc: precompute the largest Niche and store it in LayoutDetails.
    
    Since we only ever can use at most one niche, it makes sense to just store that in the layout, for the simplest caching (especially as it's almost trivial to compute).
    
    There might be a speedup from this, but even if it's marginal now, the caching would be a more significant benefit for future optimization attempts.
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    281dfd5 View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#62738 - nathanwhit:fix_mem_uninit_cloudabi,…

    … r=RalfJung
    
    Remove uses of mem::uninitialized from std::sys::cloudabi
    
    Addresses rust-lang#62397 for std::sys::cloudabi, excluding the tests within cloudabi, which will be a separate PR
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    3f786a8 View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#62772 - estebank:trait-bound, r=matthewjasper

    Suggest trait bound on type parameter when it is unconstrained
    
    Given
    
    ```
    trait Foo { fn method(&self) {} }
    
    fn call_method<T>(x: &T) {
        x.method()
    }
    ```
    
    suggest constraining `T` with `Foo`.
    
    Fix rust-lang#21673, fix rust-lang#41030.
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    4afecf7 View commit details
    Browse the repository at this point in the history
  16. Rollup merge of rust-lang#62784 - Disasm:riscv32i, r=estebank

    Add riscv32i-unknown-none-elf target
    
    This target is likely to be useful for constrained FPGA soft-cores, such as picorv32 and HeavyX.
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    298c3a2 View commit details
    Browse the repository at this point in the history
  17. Rollup merge of rust-lang#62813 - alexcrichton:less-dylib, r=Mark-Sim…

    …ulacrum
    
    rustc: Compile the `fmt_macros` crate as an rlib
    
    I think this was left out by accident from the "convert everything to
    rlibs" commit, there's no need for this to be a dylib just as everything
    else doesn't need to be a dylib!
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    c1dbc2d View commit details
    Browse the repository at this point in the history
  18. Rollup merge of rust-lang#62814 - androm3da:hexagon_19jul_2019, r=ale…

    …xcrichton
    
    add support for hexagon-unknown-linux-musl
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    690be0b View commit details
    Browse the repository at this point in the history
  19. Rollup merge of rust-lang#62890 - fakenine:normalize_use_of_backticks…

    …_compiler_messages_p15, r=Centril
    
    Normalize use of backticks in compiler messages for libsyntax/*
    
    rust-lang#60532
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    56ba4e0 View commit details
    Browse the repository at this point in the history
  20. Rollup merge of rust-lang#62901 - petrochenkov:serde, r=Centril

    cleanup: Remove `extern crate serialize as rustc_serialize`s
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    30f234e View commit details
    Browse the repository at this point in the history
  21. Rollup merge of rust-lang#62905 - fakenine:normalize_use_of_backticks…

    …_compiler_messages_p16, r=Centril
    
    Normalize use of backticks in compiler messages for doc
    
    rust-lang#60532
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    fdaf837 View commit details
    Browse the repository at this point in the history
  22. Rollup merge of rust-lang#62908 - fakenine:normalize_use_of_backticks…

    …_compiler_messages_p17, r=alexreg
    
    normalize use of backticks for compiler messages in remaining modules
    
    rust-lang#60532
    Centril authored Jul 23, 2019
    Configuration menu
    Copy the full SHA
    a18d486 View commit details
    Browse the repository at this point in the history