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 18 pull requests #81578

Merged
merged 41 commits into from
Jan 31, 2021
Merged

Rollup of 18 pull requests #81578

merged 41 commits into from
Jan 31, 2021

Conversation

jonas-schievink
Copy link
Contributor

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

gilescope and others added 30 commits December 15, 2020 12:59
Tracking issue: #65798

This is unblocked now that `min_const_generics` has been stabilized
in #79135.

This PR does *not* include the corresponding `IntoIterator` impl,
which is #65819.
Instead, an iterator can be constructed through the `new` method.

`new` would become unnecessary when `IntoIterator` is implemented
and might be deprecated then, although it will stay stable.
Co-authored-by: Ashley Mannix <kodraus@hey.com>
Reverts PR #80830
Fixes taiki-e/pin-project#312

We can have an arbitrary number of `None`-delimited group frames pushed
on the stack due to proc-macro invocations, which can legally be exited.
Attempting to account for this would add a lot of complexity for a tiny
performance gain, so let's just use the original strategy.
The `Deref` cycle checks added as part of #80653 were "unbalanced" in the sense
that the main content code path checks for cycles _before_ descending, while the
sidebar checks _after_. Checking _before_ is correct, so this changes the
sidebar path to match the main content path.
Edit punctuation and wording in note on type variables
vs. type parameters.

Also add missing punctuation and two inter-doc links.
Implement io::Seek for io::Empty

Fix #78029
…t, r=m-ou-se

Stabilize Arc::{increment,decrement}_strong_count

Tracking issue: #71983

Stabilizes `Arc::{incr,decr}_strong_count`, enabling unsafely incrementing an decrementing the Arc strong count directly with fewer gotchas. This API was first introduced on nightly six months ago, and has not seen any changes since. The initial PR showed two existing pieces of code that would benefit from this API, and included a change inside the stdlib to use this.

Given the small surface area, predictable use, and no changes since introduction, I'd like to propose we stabilize this.

closes #71983
r? `@Mark-Simulacrum`

## Links
 * [Initial implementation](#70733)
 * [Motivation from #68700](#68700 (comment))
 * [Real world example in an executor](https://docs.rs/extreme/666.666.666666/src/extreme/lib.rs.html#13)
stabilise `cargo test -- --include-ignored`

stabilise `cargo test -- --include-ignored`

On stable there's no way to run ignored tests as well as the normal tests.

An example use case where stabilising this would help:
Exercism has some initial tests and then some additional ignored tests that people run currently with --ignore but currently they can't run all the tests in one go without being on nightly. It would be a little more ergonomic if this flag was stablilised.

( Fixes  #65770 )

I built with ./x.py build -i library/test - but as libtest is a dylib is there an easy way to invoke it manually to check it's working as expected? (I've updated the automated tests.)
Implement missing `AsMut<str>` for `str`

Allows `&mut str` to be taken by a Generic which requires `T` such that `T: AsMut<str>`. Motivating example:

```rust
impl<'i, T> From<T> for StructImmut<'i> where
    T: AsRef<str> + 'i,
{
    fn from(asref: T) -> Self {
        let string: &str = asref.as_ref();
        //  ...
    }
}

impl<'i, T> From<T> for StructMut<'i> where
    T: AsMut<str> + 'i,
{
    fn from(mut asmut: T) -> Self {
        let string: &mut str = asmut.as_mut();
        //  ...
    }
}
```

The Immutable form of this structure can be constructed by `StructImmut::from(s)` where `s` may be a `&String` or a `&str`, because `AsRef<str>` is implemented for `str`. However, the mutable form of the structure can be constructed in the same way **only** with a `&mut String`, and **not** with a `&mut str`.

This change does have some precedent, because as can be seen in [the Implementors](https://doc.rust-lang.org/std/convert/trait.AsMut.html#implementors), `AsMut<[T]>` is implemented for `[T]` as well as for `Vec<T>`, but `AsMut<str>` is implemented only for `String`. This would complete the symmetry.

As a trait implementation, this should be immediately stable.
Stabilize by-value `[T; N]` iterator `core::array::IntoIter`

Tracking issue: #65798

This is unblocked now that `min_const_generics` has been stabilized in #79135.

This PR does *not* include the corresponding `IntoIterator` impl, which is #65819. Instead, an iterator can be constructed through the `new` method.

`new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
Add Box::downcast() for dyn Any + Send + Sync

Looks like a plain omission, but unfortunately I just needed that in my code :)
…r=m-ou-se

Stabilize `core::slice::fill_with`

_Tracking issue: https://github.com/rust-lang/rust/issues/79221_

This stabilizes the `slice_fill_with` feature for Rust 1.51, following the stabilization of `slice_fill` in 1.50. This was requested by libs team members in #79213.

This PR also adds the "memset" alias for `slice::fill_with`, mirroring the alias set on the `slice::fill` sibling API. This will ensure someone looking for "memset" will find both variants.

r? `@Amanieu`
Remove requirement that forces symmetric and transitive PartialEq impls to exist

### Counterexample of symmetry:

If you [have](https://docs.rs/proc-macro2/1.0.24/proc_macro2/struct.Ident.html#impl-PartialEq%3CT%3E) an impl like:

```rust
impl<T> PartialEq<T> for Ident
where
    T: ?Sized + AsRef<str>
```

then Rust will not even allow the symmetric impl to exist.

```console
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Ident`)
 --> src/main.rs:9:6
  |
9 | impl<T> PartialEq<Ident> for T where T: ?Sized + AsRef<str> {
  |      ^ type parameter `T` must be covered by another type when it appears before the first local type (`Ident`)
  |
  = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
  = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
```

<br>

### Counterexample of transitivity:

Consider these two existing impls from `regex` and `clap`:

```rust
// regex

/// An inline representation of `Option<char>`.
pub struct Char(u32);

impl PartialEq<char> for Char {
    fn eq(&self, other: &char) -> bool {
        self.0 == *other as u32
    }
}
```

```rust
// clap

pub(crate) enum KeyType {
    Short(char),
    Long(OsString),
    Position(u64),
}

impl PartialEq<char> for KeyType {
    fn eq(&self, rhs: &char) -> bool {
        match self {
            KeyType::Short(c) => c == rhs,
            _ => false,
        }
    }
}
```

It's nice to be able to add `PartialEq<proc_macro::Punct> for char` in libproc_macro (#80595), but it makes no sense to force an `impl PartialEq<Punct> for Char` and `impl PartialEq<Punct> for KeyType` in `regex` and `clap` in code that otherwise has nothing to do with proc macros.

<br>

`@rust-lang/libs`
Account for existing `_` field pattern when suggesting `..`

Follow up to #80017.
…enkov

Clone entire `TokenCursor` when collecting tokens

Reverts PR #80830
Fixes taiki-e/pin-project#312

We can have an arbitrary number of `None`-delimited group frames pushed
on the stack due to proc-macro invocations, which can legally be exited.
Attempting to account for this would add a lot of complexity for a tiny
performance gain, so let's just use the original strategy.
Optimize decimal formatting of 128-bit integers

## Description

This PR optimizes the `udivmod_1e19` function, which is used for formatting 128-bit integers, based on the algorithm provided in \[1\]. This optimization improves performance of formatting 128-bit integers, especially on 64-bit architectures. It also slightly reduces the output binary size.

## Assembler comparison

https://godbolt.org/z/YrG5zY

## Performance

#### previous results

```
test fmt::write_u128_max                                        ... bench:         552 ns/iter (+/- 4)
test fmt::write_u128_min                                        ... bench:         125 ns/iter (+/- 2)
```

#### new results

```
test fmt::write_u128_max                                        ... bench:         205 ns/iter (+/- 13)
test fmt::write_u128_min                                        ... bench:         129 ns/iter (+/- 5)
```

## Reference

\[1\] T. Granlund and P. Montgomery, “Division by Invariant Integers Using Multiplication” in Proc. of the SIGPLAN94 Conference on Programming Language Design and Implementation, 1994, pp. 61–72
…omez

Balance sidebar `Deref` cycle check with main content

The `Deref` cycle checks added as part of #80653 were "unbalanced" in the sense
that the main content code path checks for cycles _before_ descending, while the
sidebar checks _after_. Checking _before_ is correct, so this changes the
sidebar path to match the main content path.

Fixes #81395

r? ```@GuillaumeGomez```
…=estebank

Add a regression test for ICE of bad_placeholder_type

Add a regression test for #72685. Check the error message is output instead of ICE.
Edit rustc_typeck top-level docs

Edit punctuation and wording in note on type variables vs. type parameters.

Also add missing punctuation and two inter-doc links.
…-schievink

Replace predecessor with range in collections documentation

Fixes #81548.
…kler

Clarify that InPlaceIterable guarantees extend to all advancing iterator methods.

A documentation update that should answer a question that came up in [this zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Safety.20guarantees.20of.20InPlaceIterable/near/223743336)

CC `@SkiFire13`
@rustbot rustbot added the rollup A PR which is a rollup label Jan 31, 2021
@jonas-schievink
Copy link
Contributor Author

@bors r+ rollup=never p=18

@bors
Copy link
Contributor

bors commented Jan 31, 2021

📌 Commit 8b281d9 has been approved by jonas-schievink

@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 Jan 31, 2021
@bors
Copy link
Contributor

bors commented Jan 31, 2021

⌛ Testing commit 8b281d9 with merge 7850c28...

@bors
Copy link
Contributor

bors commented Jan 31, 2021

☀️ Test successful - checks-actions
Approved by: jonas-schievink
Pushing 7850c28 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 31, 2021
@bors bors merged commit 7850c28 into rust-lang:master Jan 31, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 31, 2021
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #81578!

Tested on commit 7850c28.
Direct link to PR: #81578

💔 rls on windows: test-pass → build-fail (cc @Xanewok).
💔 rls on linux: test-pass → build-fail (cc @Xanewok).
💔 rustfmt on windows: test-pass → build-fail (cc @topecongiro @calebcartwright).
💔 rustfmt on linux: test-pass → build-fail (cc @topecongiro @calebcartwright).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Jan 31, 2021
Tested on commit rust-lang/rust@7850c28.
Direct link to PR: <rust-lang/rust#81578>

💔 rls on windows: test-pass → build-fail (cc @Xanewok).
💔 rls on linux: test-pass → build-fail (cc @Xanewok).
💔 rustfmt on windows: test-pass → build-fail (cc @topecongiro @calebcartwright).
💔 rustfmt on linux: test-pass → build-fail (cc @topecongiro @calebcartwright).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.