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 #76907

Closed
wants to merge 45 commits into from
Closed

Conversation

RalfJung
Copy link
Member

Successful merges:

Failed merges:

r? @ghost

hellow554 and others added 30 commits August 11, 2020 09:22
This commit moves `transparent_newtype_field` and `is_zst` to
`LateContext` where they are used, rather than being on the `VariantDef`
and `TyS` types.

Signed-off-by: David Wood <david@davidtw.co>
Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

Possible because of stabilization of rust-lang#49146 (Allow if and match in constants).
This is very similar to the existing `Box<[T; N]>: TryFrom<Box<[T]>>`, but allows avoiding the `shrink_to_fit` if you have a vector and not a boxed slice.
Thanks, Amanieu

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
m-ou-se and others added 15 commits September 19, 2020 06:54
…acrum

deny(unsafe_op_in_unsafe_fn) in libstd/path.rs

The libstd/path.rs part of rust-lang#73904 . Wraps the two calls to an unsafe fn Initializer::nop() in an unsafe block.
…ion, r=eddyb

lint/ty: move fns to avoid abstraction violation

This PR moves `transparent_newtype_field` and `is_zst` to `LateContext` where they are used, rather than being on the `VariantDef` and `TyS` types, hopefully addressing @eddyb's concern [from this comment](rust-lang#74340 (comment)).
Add test for checking duplicated branch or-patterns

This adds a regression test for checking `or-patterns` in MIR as shown in rust-lang#75439.
This doesn't introduce a fix as I'm not sure where it would go(I suspect maybe here: src/librustc_mir_build/build/matches/mod.rs), and I'm not particularly able to fix it.

cc: @lzutao
Stabilize some Option methods as const

Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

These methods are currently const under the unstable feature `const_option` (tracking issue: rust-lang#67441).
I believe these methods to be eligible for stabilization because of the stabilization of rust-lang#49146 (Allow if and match in constants) and the trivial implementations, see also:  [PR#75463](rust-lang#75463).

Related: rust-lang#76225
Add `[T; N]: TryFrom<Vec<T>>` (insta-stable)

This is very similar to the [existing](https://doc.rust-lang.org/nightly/std/convert/trait.TryFrom.html#impl-TryFrom%3CBox%3C%5BT%5D%3E%3E) `Box<[T; N]>: TryFrom<Box<[T]>>`, but allows avoiding the `shrink_to_fit` if you have a vector and not a boxed slice.

Like the slice equivalents of this, it fails if the length of the vector is not exactly `N`.
This uses `Vec<T>` as the `Error` type to return the input, like how the `Rc<[T]> -> Rc<[T; N]>` (and Arc) ones also reflect the input directly in the error type.

```rust
#[stable(feature = "array_try_from_vec", since = "1.47.0")]
impl<T, const N: usize> TryFrom<Vec<T>> for [T; N] {
    type Error = Vec<T>;
    fn try_from(mut vec: Vec<T>) -> Result<[T; N], Vec<T>>;
}
```

Inspired by this zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/APIs.20for.20getting.20stuff.20from.20a.20Vec.20by.20owned/near/209048103
Clean up vec benches bench_in_place style
do not inline black_box when building for Miri

We cannot do the assembly trick in Miri, but let's at least make sure MIR inlining does not circumvent the black_box.

Also use black_box instead of local optimization barriers in a few const tests.
…r=dtolnay

Add associated constant `BITS` to all integer types

Recently I've regularly come across this snippet (in a few different crates, including `core` and `std`):
```rust
std::mem::size_of<usize>() * 8
```

I think it's time for a `usize::BITS`.
assert ScalarMaybeUninit size

I noticed most low-level Miri types have such an assert but `ScalarMaybeUninit` does not, so let's add that. Good t see that the `Option`-like optimization kicks in and this is no bigger than `Scalar`. :)

r? @oli-obk
give *even better* suggestion when matching a const range

notice that the err already has "constant defined here"
so this is now *exceedingly clear*

extension to rust-lang#76222

r? @estebank
don't convert types to the same type with try_into (clippy::useless_conversion)
Give a better error message when x.py uses the wrong stage for CI

r? @shepmaster
…yn514

Build fixes for RISC-V 32-bit Linux support

This fixes build issues with the 32-bit RISC-V port.
@RalfJung
Copy link
Member Author

@rustbot modify labels: +rollup
@bors r+ rollup=never p=13

@bors
Copy link
Contributor

bors commented Sep 19, 2020

📌 Commit 72ff47c has been approved by RalfJung

@rustbot rustbot added the rollup A PR which is a rollup label Sep 19, 2020
@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 Sep 19, 2020
@bors
Copy link
Contributor

bors commented Sep 19, 2020

⌛ Testing commit 72ff47c with merge 5b777cd9322a036c403c9b889c702a6afd60da63...

@bors
Copy link
Contributor

bors commented Sep 19, 2020

💔 Test failed - checks-actions

@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 Sep 19, 2020
@RalfJung RalfJung closed this Sep 19, 2020
@RalfJung RalfJung deleted the rollup-lb8lulf branch September 19, 2020 09:51
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.

None yet