Commit graph

127275 commits

Author SHA1 Message Date
Dylan DPC
69ac07608e
Rollup merge of #76198 - CDirkx:const-ordering, r=dtolnay
Make some Ordering methods const

Resubmission of [PR#75463](https://github.com/rust-lang/rust/pull/75463) as per [PR#76172](https://github.com/rust-lang/rust/pull/76172).

Constify the following methods of `core::cmp::Ordering`:
 - `reverse`
 - `then`

Insta-stabilizes these methods as const under the `const_ordering` feature, as their implementation is a trivial match and the recent stabilization of #49146 (Allow `if` and `match` in constants).
Note: the `const_ordering` feature has never actually been used as these methods have not been `#[rustc_const_unstable]`.

Tracking issue:  #76113
2020-09-16 01:30:42 +02:00
Dylan DPC
db228987ac
Rollup merge of #76048 - alistair23:alistair/rv32-linux, r=Amanieu
Initial support for riscv32gc_unknown_linux_gnu

Now that RISC-V 32-bit (RV32) support is in upstream glibc let's add support for userspace Rust.
2020-09-16 01:30:40 +02:00
Dylan DPC
056c7b09ff
Rollup merge of #75886 - erikdesjardins:index, r=nikic
Test that bounds checks are elided for [..index] after .position()

Closes #73396.

This was fixed by the LLVM 11 update in #73526.
2020-09-16 01:30:38 +02:00
Dylan DPC
c9105185de
Rollup merge of #75882 - pickfire:patch-6, r=jyn514
Use translated variable for test string

Test should be educative, added english translation and pronounciation.
2020-09-16 01:30:36 +02:00
Dylan DPC
034af08e14
Rollup merge of #75749 - ehuss:consolidate-sys, r=alexcrichton
Consolidate some duplicate code in the sys modules.

This consolidates some modules which were duplicated throughout the sys module. The intent is to make it easier to update and maintain this code. This mainly affects the wasi, sgx, and "unsupported" targets.

I explicitly skipped hermit, cloudabi, and vxworks. These tier-3 targets have copied large sections of the sys tree. I don't think they should have, but I don't want to put effort into changing them. It also doesn't help that there aren't any scripts or instructions for building them.

There are still sections of duplicate code here and there, but this PR covers the easy parts where entire modules are the same.
2020-09-16 01:30:34 +02:00
Dylan DPC
fa4cfeb597
Rollup merge of #75304 - Aaron1011:feature/diag-deref-move-out, r=estebank
Note when a a move/borrow error is caused by a deref coercion

Fixes #73268

When a deref coercion occurs, we may end up with a move error if the
base value has been partially moved out of. However, we do not indicate
anywhere that a deref coercion is occuring, resulting in an error
message with a confusing span.

This PR adds an explicit note to move errors when a deref coercion is
involved. We mention the name of the type that the deref-coercion
resolved to, as well as the `Deref::Target` associated type being used.
2020-09-16 01:30:32 +02:00
Dylan DPC
fb9bb2b5ca
Rollup merge of #75146 - tmiasko:range-overflow, r=Mark-Simulacrum
Detect overflow in proc_macro_server subspan

* Detect overflow in proc_macro_server subspan
* Add tests for overflow in Vec::drain
* Add tests for overflow in String / VecDeque operations using ranges
2020-09-16 01:30:30 +02:00
Dylan DPC
4f0c245429
Rollup merge of #73955 - hellow554:unsafe_process, r=Mark-Simulacrum
deny(unsafe_op_in_unsafe_fn) in libstd/process.rs

The libstd/process.rs part of #73904 . Wraps the two calls to an unsafe fn Initializer::nop() in an unsafe block.

Will have to wait for #73909 to be merged, because of the feature in the libstd/lib.rs
2020-09-16 01:30:28 +02:00
bors
6af1bdda54 Auto merge of #73595 - SNCPlay42:lifetime-after-mut, r=Mark-Simulacrum
improve diagnostics for lifetime after `&mut`

If, when parsing a borrow pointee type, we see a lifetime after `mut`, suggest placing the lifetime before `mut` and eat the lifetime to avoid a large number of unhelpful diagnostics.

There are some subtleties to avoid false positives in cases like `&mut 'a + Trait`, where `&mut ('a + Trait)` is a better suggestion.

fixes #73568
2020-09-15 21:01:30 +00:00
bors
07ece44a42 Auto merge of #73166 - jethrogb:stdarch, r=Amanieu
Update stdarch

This PR **changes the public signature** of the following functions in `core::arch::{x86, x86_64}`:
```patch
-pub unsafe fn _mm256_extract_epi8(a: __m256i, imm8: i32) -> i8
+pub unsafe fn _mm256_extract_epi8(a: __m256i, imm8: i32) -> i32
-pub unsafe fn _mm256_extract_epi16(a: __m256i, imm8: i32) -> i16
+pub unsafe fn _mm256_extract_epi16(a: __m256i, imm8: i32) -> i32
```

This change is desired so that these signatures
* are similar to those of the 128-bit versions `_mm_extract_epi8` and `_mm_extract_epi16`
* match the Intel definitions for the intrinsics
  * [RFC 2325](https://github.com/rust-lang/rfcs/blob/master/text/2325-stable-simd.md) specifies that the exact vendor function signatures should be used

A [crater run](https://github.com/rust-lang/rust/pull/73166#issuecomment-667230319) revealed only a single breakage. The [vektor crate](https://github.com/AdamNiederer/vektor/blob/master/src/x86/avx2.rs#L2436-L2472) copied the incorrect signatures in `core` exactly to their own crate. The functions don't seem to be used by anyone anywhere.

Actual breakage is not expected, since due to the nature of the functions, users would generally write `_mm256_extract_epi8(...) as u8` or `_mm256_extract_epi16(...) as u16`.

See https://github.com/rust-lang/stdarch/pull/868/. Note that the changes from that stdarch PR have already partially landed in core after https://github.com/rust-lang/stdarch/pull/878/. This PR is now only about the remaining changes.
2020-09-15 19:04:40 +00:00
bors
a874956d94 Auto merge of #75148 - joechrisellis:master, r=Amanieu
Implementation of peer credentials for Unix sockets

The code in `ucred.rs` is based on the work done in [PR 13](https://github.com/tokio-rs/tokio-uds/pull/13) in the tokio-uds repository on GitHub.

This commit is effectively a port to the stdlib, so credit to Martin Habovštiak (`@Kixunil)` and contributors for the meat of this work. 🥇

Happy to make changes as needed. 🙂
2020-09-15 17:05:57 +00:00
Jethro Beekman
0122e08dae Update stdarch 2020-09-15 17:26:20 +02:00
Alistair Francis
e968f86f71 doc: platform-support.md: Move to tier 3
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-15 08:13:01 -07:00
bors
27a45d0aab Auto merge of #76708 - Mark-Simulacrum:lld-macos, r=alexcrichton
Always try to promote shared LLVM to the sysroot

Even when LLVM is not generally participating in a shared link with rustc, we
will likely still link to the shared dylib from rust-lld, so we still need to
promote it.

This reverts part of #76349; my expectation that the link-shared rule was sufficient was likely wrong.

Hopefully fixes #76698.

r? `@alexcrichton`
2020-09-15 15:06:59 +00:00
Alistair Francis
cbda1546b1 doc: platform-support.md: Document port
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-15 07:58:33 -07:00
SNCPlay42
4de9a53d98 improve diagnostics for lifetime after &mut 2020-09-15 10:36:06 -04:00
Mark Rousskov
f001a0c8dd Enable shared linking to LLVM on non-Windows
Windows doesn't quite support dynamic linking to LLVM yet, but on other
platforms we do. In #76708, it was discovered that we dynamically link to LLVM
from the LLVM tools (e.g., rust-lld), so we need the shared LLVM library to link
against. That means that if we do not have a shared link to LLVM, and want LLVM
tools to work, we'd be shipping two copies of LLVM on all of these platforms:
one in librustc_driver and one in libLLVM.

Also introduce an error into rustbuild if we do end up configured for shared
linking on Windows.
2020-09-15 10:22:02 -04:00
Eric Huss
25cca07ea0 Consolidate wasi::process and unsupported::process 2020-09-15 07:01:13 -07:00
Eric Huss
cfb955da6f Consolidate wasi alloc with unix alloc. 2020-09-15 07:01:13 -07:00
Eric Huss
5a4098ed0f Consolidate byte-identical modules. 2020-09-15 07:01:07 -07:00
bors
4c1966f97e Auto merge of #76311 - lzutao:split_core-slice, r=lcnr
Split `core::slice` to smaller mods

Unfortunately the `#[lang = "slice"]` is too big (3003 lines), I cannot split it further.

Note for reviewer:
* I split to multiple commits for easier reviewing, but I could git squash them all to one if requested.
* Recommend pulling this change locally and using advanced git diff viewer or this command:
  ```
  git show --reverse --color-moved=dimmed-zebra master..
  ```

---

I split core/slice/mod.rs to these modules:

* `ascii`: For operations on `[u8]`.
* `cmp`: For comparison operations on `[T]`, like PartialEq and SliceContains impl.
* `index`: For indexing operations like Index/IndexMut and SliceIndex.
* `iter`: For Iterator definitions and implementation on `[T]`.
  - `macros`: For iterator! and forward_iterator! macros.
* `raw`: For free function to create `&[T]` or `&mut [T]` from pointer + length or a reference.

The heapsort wrapper in mod.rs is removed in favor of reexport from `sort::heapsort`.
2020-09-15 12:15:59 +00:00
Lzu Tao
c65050d537 Fix clippy hard-code slice::Iter path 2020-09-15 10:21:40 +00:00
bors
90b1f5ae59 Auto merge of #76171 - estebank:turbofish-the-revenge, r=davidtwco
Detect turbofish with multiple type params missing leading `::`

Fix #76072.
2020-09-15 10:14:52 +00:00
bors
c1589cc819 Auto merge of #76684 - jyn514:refactor-intra-links, r=manishearth
Refactor intra doc link code

I got tired of `fold_item` being 500 lines long.
This is best reviewed one commit at a time with whitespace changes hidden.
There are no logic changes other than the last commit making a parameter checked by the caller instead of the callee.

r? `@Manishearth`
2020-09-15 07:42:13 +00:00
bors
6cae28165f Auto merge of #76682 - richkadel:vec-take, r=Mark-Simulacrum
Optimize behavior of vec.split_off(0) (take all)

Optimization improvement to `split_off()` so the performance meets the
intuitively expected behavior when `at == 0`, avoiding the current behavior
of copying the entire vector.

The change honors documented behavior that the original vector's
"previous capacity unchanged".

This improvement better supports the pattern for building and flushing a
buffer of elements, such as the following:

```rust
    let mut vec = Vec::new();
    loop {
        vec.push(something);
        if condition_is_met {
            process(vec.split_off(0));
        }
    }
```

`Option` wrapping is the first alternative I thought of, but is much
less obvious and more verbose:

```rust
    let mut capacity = 1;
    let mut vec: Option<Vec<Stuff>> = None;
    loop {
        vec.get_or_insert_with(|| Vec::with_capacity(capacity)).push(something);
        if condition_is_met {
            capacity = vec.capacity();
            process(vec.take().unwrap());
        }
    }
```

Directly using `mem::replace()` (instead of  calling`split_off()`) could work,
but `mem::replace()` is a more advanced tool for Rust developers, and in
this case, I believe developers would assume the standard library should
be sufficient for the purpose described here.

The benefit of the approach to this change is it does not change the
existing API contract, but improves the peformance of `split_off(0)` for
`Vec`, `String` (which delegates `split_off()` to `Vec`), and any other
existing use cases.

This change adds tests to validate the behavior of `split_off()` with
regard to capacity, as originally documented, and confirm that behavior
still holds, when `at == 0`.

The change is an implementation detail, and does not require a
documentation change, but documenting the new behavior as part of its
API contract may benefit future users.

(Let me know if I should make that documentation update.)

Note, for future consideration:

I think it would be helpful to introduce an additional method to `Vec`
(if not also to `String`):

```
    pub fn take_all(&mut self) -> Self {
        self.split_off(0)
    }
```

This would make it more clear how `Vec` supports the pattern, and make
it easier to find, since the behavior is similar to other `take()`
methods in the Rust standard library.

r? `@wesleywiser`
FYI: `@tmandry`
2020-09-15 05:01:17 +00:00
Erik Desjardins
0f1d25e556 Test that bounds checks are elided for indexing after .[r]position() 2020-09-14 22:19:48 -04:00
bors
715e9340a1 Auto merge of #74532 - fusion-engineering-forks:atomic-from-mut, r=KodrAus
Add Atomic*::from_mut.

The atomic equivalent of [`Cell::from_mut`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.from_mut).
2020-09-15 02:09:34 +00:00
Alistair Francis
82bd5a3e1d librustc_target: Address comments
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-14 17:43:06 -07:00
Alistair Francis
a4183f0e61 librustc_target: Initial support for riscv32gc_unknown_linux_gnu
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-14 17:40:29 -07:00
bors
255ceeb5ff Auto merge of #76612 - estebank:pat-missing-fields-suggestion, r=davidtwco
Provide suggestion for missing fields in patterns
2020-09-15 00:17:13 +00:00
bors
9b4154193e Auto merge of #76541 - matthiaskrgr:unstable_sort, r=davidtwco
use sort_unstable to sort primitive types

It's not important to retain original order if we have &[1, 1, 2, 3] for example.

clippy::stable_sort_primitive
2020-09-14 21:43:17 +00:00
bors
41dc3942eb Auto merge of #75608 - estebank:suggest-boxed-match-exprs, r=lcnr,varkor
More structured suggestions for boxed trait objects instead of impl Trait on non-coerceable tail expressions

When encountering a `match` or `if` as a tail expression where the
different arms do not have the same type *and* the return type of that
`fn` is an `impl Trait`, check whether those arms can implement `Trait`
and if so, suggest using boxed trait objects.

Use structured suggestion for `impl T` to `Box<dyn T>`.

Fix https://github.com/rust-lang/rust/issues/69107
2020-09-14 19:57:57 +00:00
Esteban Küber
c6f2ddf1cb Fix rebase and add comments 2020-09-14 12:51:25 -07:00
Esteban Küber
62effcbd5b Detect turbofish with multiple type params missing leading ::
Fix #76072.
2020-09-14 12:06:51 -07:00
bors
bb0067c75e Auto merge of #76278 - jethrogb:jb/sgx-rwlock-init-test, r=Mark-Simulacrum
Improve SGX RWLock initializer test

r? `@eddyb`

This addresses https://github.com/pnkfelix/rust/pull/1#discussion_r374239895

Fixes https://github.com/fortanix/rust-sgx/issues/213
2020-09-14 18:04:18 +00:00
bors
57c5f40cf4 Auto merge of #75740 - GuillaumeGomez:stabilize-doc-alias-feature, r=ollie27
Stabilize doc_alias feature

Fixes #50146.

This PR intend to stabilize the `doc_alias` feature. The last remaining bits were missing checks on the attribute usage and on its arguments. Both have been added so I think we can now move to the next step.

r? `@ollie27`

cc `@rust-lang/rustdoc`
2020-09-14 10:56:30 +00:00
Lzu Tao
6655ad7ed8 Removed outdated comments 2020-09-14 09:35:54 +00:00
Lzu Tao
f2976ab2d6 Move ascii to new module 2020-09-14 09:35:54 +00:00
Lzu Tao
fbad684e2f move indexing impl to new mod 2020-09-14 09:35:54 +00:00
Lzu Tao
bcd18f977b Move free functions to a new module 2020-09-14 09:35:54 +00:00
Lzu Tao
f376443b8f Move iterator impls to a new module 2020-09-14 09:35:54 +00:00
Joe Ellis
68ff495afa Fix peer credentials for Android 2020-09-14 10:31:56 +01:00
Joe Ellis
72eef6168f Conditionally compile peer credentials feature for supported platforms 2020-09-14 10:31:56 +01:00
Joe Ellis
fa697dfa81 Add documentation to public fields of UCred struct 2020-09-14 10:31:56 +01:00
Joe Ellis
7c20be387b Move Unix peer credentials tests to their own file 2020-09-14 10:31:56 +01:00
Joe Ellis
40a830321d Add pid as an option to UCred struct
Currently, PID will be populated for Linux, and set to None for BSDs.
2020-09-14 10:31:56 +01:00
Joe Ellis
cbcf3877b5 Use u32::MAX instead of u32::max_value
Co-authored-by: lzutao <taolzu@gmail.com>
2020-09-14 10:31:56 +01:00
Joe Ellis
be2637aba7 Add basic test for Unix peer credentials 2020-09-14 10:31:56 +01:00
Joe Ellis
a9ec61db17 Remove use of MaybeUninit in ucred.rs
We can simply init the struct directly. There is no real need to use
uninit memory here.
2020-09-14 10:31:56 +01:00
Joe Ellis
ed20eff92b Implementation of peer credentials for Unix sockets
The code in `ucred.rs` is based on the work done in PR 13 in the
tokio-uds repository on GitHub. Link below for reference:

    https://github.com/tokio-rs/tokio-uds/pull/13

Credit to Martin Habovštiak (GitHub username Kixunil) and contributors
for this work!
2020-09-14 10:31:44 +01:00