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 9 pull requests #62966

Closed
wants to merge 44 commits into from
Closed

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Jul 25, 2019

Successful merges:

Failed merges:

r? @ghost

varkor and others added 30 commits July 1, 2019 00:52
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
This allows the same logic used by `include_X!` macros to be used by
`#[doc(include)]`.
This makes them relative to the containing file instead of the crate
root
Co-Authored-By: gnzlbg <gnzlbg@users.noreply.github.com>
JohnTitor and others added 10 commits July 25, 2019 07:47
…r=petrochenkov

rustdoc: make #[doc(include)] relative to the containing file

This matches the behavior of other in-source paths like `#[path]` and the `include_X!` macros.

Fixes rust-lang#58373 (comment)
Also addresses rust-lang#44732 (comment)

cc rust-lang#44732

This is still missing a stdsimd change (https://github.com/jonas-schievink/stdsimd/commit/42ed30e0b5fb5e2d11765b5d1e1f36234af85984), so CI will currently fail. I'll land that change once I get initial feedback for this PR.
…=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.
…inhabited-subst, r=oli-obk

Take substs into account in `conservative_is_privately_uninhabited`
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/github.com-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.
…ndry

Add tests for overlapping explicitly dropped locals in generators

Closes rust-lang#62686

r? @tmandry
Turn `#[global_allocator]` into a regular attribute macro

It was a 99% macro with exception of some diagnostic details.

As a result of the change, `#[global_allocator]` now works in nested modules and even in nameless blocks.

Fixes rust-lang#44113
Fixes rust-lang#58072
Improve some pointer-related documentation
…isambiguation, r=estebank

Add method disambiguation help for trait implementation

Closes rust-lang#51046
Closes rust-lang#40471
…rgo, r=sfackler

Use match ergonomics in Condvar documentation

Documentation was written before match ergonomics was merged. See rust-lang#62857.

In short, replaces

```rust
let &(ref lock, ref cvar) = &*pair;
```

with

```rust
let (lock, cvar) = &*pair
```

in the docs of `std::sync::Condvar`.
@Centril
Copy link
Contributor Author

Centril commented Jul 25, 2019

@bors r+ p=9 rollup=never

@bors
Copy link
Contributor

bors commented Jul 25, 2019

📌 Commit d4c96f2 has been approved by Centril

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 25, 2019
@bors
Copy link
Contributor

bors commented Jul 25, 2019

⌛ Testing commit d4c96f2 with merge 451853242f481c6967c650b02561b7feb1a0aa49...

@bors
Copy link
Contributor

bors commented Jul 25, 2019

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 25, 2019
@Centril
Copy link
Contributor Author

Centril commented Jul 25, 2019

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2019
@bors
Copy link
Contributor

bors commented Jul 25, 2019

⌛ Testing commit d4c96f2 with merge b63669676b9b0ed4caa6becd3a35ad5212f3f267...

@rust-highfive
Copy link
Collaborator

The job LinuxTools of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-07-25T08:32:51.8609381Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-25T08:32:51.8814073Z ##[command]git config gc.auto 0
2019-07-25T08:32:51.8884580Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-25T08:32:51.8950146Z ##[command]git config --get-all http.proxy
2019-07-25T08:32:51.9100144Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/62966/merge:refs/remotes/pull/62966/merge
---
2019-07-25T08:33:29.6991403Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-25T08:33:29.6991438Z 
2019-07-25T08:33:29.6991675Z   git checkout -b <new-branch-name>
2019-07-25T08:33:29.6991706Z 
2019-07-25T08:33:29.6991773Z HEAD is now at 422a724be Merge d4c96f296cc51a1f1ab96789c29c1c896e768770 into 185b9acb66438894596f3c40d2ae4c6f7deeb8ab
2019-07-25T08:33:29.7121950Z ##[section]Finishing: Checkout
2019-07-25T08:33:29.7129915Z ##[section]Starting: Decide whether to run this job
2019-07-25T08:33:29.7133460Z Task         : Bash
2019-07-25T08:33:29.7133512Z Description  : Run a Bash script on macOS, Linux, or Windows
2019-07-25T08:33:29.7133564Z Version      : 3.151.3
2019-07-25T08:33:29.7133630Z Author       : Microsoft Corporation
2019-07-25T08:33:29.7133630Z Author       : Microsoft Corporation
2019-07-25T08:33:29.7133689Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
2019-07-25T08:33:29.7133749Z ==============================================================================
2019-07-25T08:33:29.8431906Z Generating script.
2019-07-25T08:33:29.8480812Z ========================== Starting Command Output ===========================
2019-07-25T08:33:29.8501734Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/b0dd3b19-ce4c-489c-82c3-d1d2ea8f6773.sh
2019-07-25T08:33:30.2167778Z Executing the job since submodules are updated
2019-07-25T08:33:30.2210390Z ##[section]Finishing: Decide whether to run this job
2019-07-25T08:33:30.2220641Z ==============================================================================
2019-07-25T08:33:30.2220732Z Task         : Bash
2019-07-25T08:33:30.2220811Z Description  : Run a Bash script on macOS, Linux, or Windows
2019-07-25T08:33:30.2220851Z Version      : 3.151.3
---
2019-07-25T10:42:32.6532961Z The state of "miri" has changed from "test-pass" to "build-fail"
2019-07-25T10:42:32.6533515Z The state of "rustc-guide" has changed from "test-pass" to ""
2019-07-25T10:42:32.6767505Z [master f3deed7] (linux CI update)
2019-07-25T10:42:32.6767635Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:33.3093073Z remote: Invalid username or password.
2019-07-25T10:42:33.3093937Z fatal: Authentication failed for 'https://github.com/rust-lang-nursery/rust-toolstate.git/'
2019-07-25T10:42:35.6329346Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:35.6329346Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:35.6520197Z HEAD is now at cccca90 📣 Toolstate changed by rust-lang/rust#62944!
2019-07-25T10:42:35.6650903Z The state of "rustc-guide" has changed from "test-pass" to ""
2019-07-25T10:42:35.6848051Z [master 6d475ce] (linux CI update)
2019-07-25T10:42:35.6848343Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:35.6848343Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:35.9801045Z fatal: could not read Username for 'https://github.com': No such device or address
2019-07-25T10:42:36.3147574Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:36.3147574Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:36.3317793Z HEAD is now at cccca90 📣 Toolstate changed by rust-lang/rust#62944!
2019-07-25T10:42:36.3451136Z The state of "rustc-guide" has changed from "test-pass" to ""
2019-07-25T10:42:36.3630940Z [master b07b5d2] (linux CI update)
2019-07-25T10:42:36.3631458Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:36.3631458Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:36.6689050Z fatal: could not read Username for 'https://github.com': No such device or address
2019-07-25T10:42:39.0008447Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:39.0008447Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:39.0202247Z HEAD is now at cccca90 📣 Toolstate changed by rust-lang/rust#62944!
2019-07-25T10:42:39.0328310Z The state of "rustc-guide" has changed from "test-pass" to ""
2019-07-25T10:42:39.0544246Z [master bcd8c6b] (linux CI update)
2019-07-25T10:42:39.0544816Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:39.0544816Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:39.3614557Z fatal: could not read Username for 'https://github.com': No such device or address
2019-07-25T10:42:40.6982886Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:40.6982886Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:40.7149313Z HEAD is now at cccca90 📣 Toolstate changed by rust-lang/rust#62944!
2019-07-25T10:42:40.7275741Z The state of "rustc-guide" has changed from "test-pass" to ""
2019-07-25T10:42:40.7476771Z [master f6edb82] (linux CI update)
2019-07-25T10:42:40.7477339Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:40.7477339Z  1 file changed, 1 insertion(+)
2019-07-25T10:42:41.0605477Z fatal: could not read Username for 'https://github.com': No such device or address
2019-07-25T10:42:44.4095303Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:44.4095303Z  * branch            master     -> FETCH_HEAD
2019-07-25T10:42:44.4280103Z HEAD is now at cccca90 📣 Toolstate changed by rust-lang/rust#62944!
2019-07-25T10:42:45.3693168Z ##[error]Bash exited with code '1'.
2019-07-25T10:42:45.3737449Z ##[section]Starting: Checkout
2019-07-25T10:42:45.3739729Z ==============================================================================
2019-07-25T10:42:45.3739789Z Task         : Get sources
2019-07-25T10:42:45.3739862Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Jul 25, 2019

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 25, 2019
@Centril Centril closed this Jul 25, 2019
@Centril Centril deleted the rollup-mq12abn branch July 25, 2019 18:08
@Centril Centril added the rollup A PR which is a rollup label Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.