Commit graph

1009 commits

Author SHA1 Message Date
Denis Vasilik
ec7225feac
Update library/alloc/src/collections/binary_heap.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-18 16:45:23 +02:00
Denis Vasilik
2230d8d14c
Update library/alloc/src/collections/binary_heap.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-18 16:45:13 +02:00
Denis Vasilik
bdb039d10b Use intra-doc links 2020-09-18 10:50:04 +02:00
Tyler Mandry
d3c63213a0
Rollup merge of #76778 - pickfire:patch-7, r=jonas-schievink
Simplify iter fuse struct doc
2020-09-16 12:24:28 -07:00
Tyler Mandry
273267c9ee
Rollup merge of #76759 - yoshuawuyts:fix-future-pending-ready-stabilization-label, r=Dylan-DPC
Fix stabilization marker for future_readiness_fns

Updated the rustc version in which this will be stabilized from `1.47.0 -> 1.48.0`. Fixes https://github.com/rust-lang/rust/pull/74328#issuecomment-692133125. Ref #70921.

r? @Dylan-DPC
2020-09-16 12:24:21 -07:00
Tyler Mandry
ab207743af
Rollup merge of #76758 - adamlesinski:clone_clock, r=tmandry
[fuchsia] Propagate the userspace UTC clock

On Fuchsia, spawning a subprocess does not automatically
clone all of the parent process' capabilities. UTC time on
Fuchsia is managed by a top-level userspace clock capability
that is cloned and passed to subprocesses.

This change ensures that any Rust subprocess gets access to the
UTC clock, if the parent had access to it. This is critical for
tests, which on Fuchsia, use panic=abort and spawn subprocesses
per test.
2020-09-16 12:24:19 -07:00
Tyler Mandry
ab78ca92f3
Rollup merge of #76747 - GuillaumeGomez:more-missing-libcore-code-examples, r=Mark-Simulacrum
Add missing code examples in libcore
2020-09-16 12:24:16 -07:00
Tyler Mandry
153fb91d37
Rollup merge of #76721 - camelid:intra-doc-links-for-core-mem, r=jyn514
Use intra-doc links in `core::mem`

Part of #75080.

Last one for now!

---

@rustbot modify labels: A-intra-doc-links T-doc
2020-09-16 12:24:08 -07:00
Tyler Mandry
23a677787e
Rollup merge of #75026 - JulianKnodt:array_windows, r=Amanieu
Add array_windows fn

This mimicks the functionality added by array_chunks, and implements a const-generic form of
`windows`. It makes egregious use of `unsafe`, but by necessity because the array must be
re-interpreted as a slice of arrays, and unlike array_chunks this cannot be done by casting the
original array once, since each time the index is advanced it needs to move one element, not
`N`.

I'm planning on adding more tests, but this should be good enough as a premise for the functionality.
Notably: should there be more functions overwritten for the iterator implementation/in general?

~~I've marked the issue as #74985 as there is no corresponding exact issue for `array_windows`, but it's based of off `array_chunks`.~~

Edit: See Issue #75027 created by @lcnr for tracking issue

~~Do not merge until I add more tests, please.~~

r? @lcnr
2020-09-16 12:24:03 -07:00
kadmin
f240abc1dc Add array window fn
Updated issue to #75027

Update to rm oob access

And hopefully fix docs as well

Fixed naming conflict in test

Fix test which used 1-indexing

Nth starts from 0, woops

Fix a bunch of off by 1 errors

See https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=757b311987e3fae1ca47122969acda5a

Add even more off by 1 errors

And also write `next` and `next_back` in terms of `nth` and `nth_back`.

Run fmt

Fix forgetting to change fn name in test

add nth_back test & document unsafe

Remove as_ref().unwrap()
Documented occurrences of unsafe, noting what invariants are maintained
2020-09-16 14:52:20 +00:00
Dylan DPC
9524fffce3
Rollup merge of #76707 - pickfire:patch-4, r=jonas-schievink
Simplify iter flatten struct doc
2020-09-16 12:34:23 +02:00
Dylan DPC
d1b050476d
Rollup merge of #76669 - lzutao:core_asm, r=Amanieu
Prefer asm! over llvm_asm! in core

Replace llvm_asm! with asm! in core.

x86 asm compare (in somecases I replaced generic type with String).
* https://rust.godbolt.org/z/59eEMv
* https://rust.godbolt.org/z/v78s6q
* https://rust.godbolt.org/z/7qYY41
2020-09-16 12:34:11 +02:00
Lzu Tao
4dc4e9f671 Fix black_box bug detected by Amanieu
Co-authored-by: Amanieu <amanieu@gmail.com>
2020-09-16 09:25:54 +00:00
Ralf Jung
9d0a265b6c
Rollup merge of #76662 - RalfJung:lib-test-miri, r=Mark-Simulacrum
Fix liballoc test suite for Miri

Mostly, fix the regression introduced by https://github.com/rust-lang/rust/pull/75207 that caused slices (i.e., references) to be created to invalid memory or memory that has aliasing pointers that we want to keep valid. @dylni  this changes the type of `check_range` to only require the length, not the full reference to the slice, which indeed is all the information this function requires.

Also reduce the size of a test introduced in https://github.com/rust-lang/rust/pull/70793 to make it not take 3 minutes in Miri.

This makes https://github.com/RalfJung/miri-test-libstd work again.
2020-09-16 08:25:02 +02:00
Ralf Jung
17015cd5af
Rollup merge of #76534 - notriddle:doc-comments, r=jyn514
Add doc comments for From impls

https://github.com/rust-lang/rust/issues/51430
2020-09-16 08:24:56 +02:00
Ralf Jung
3a4de42a8d
Rollup merge of #76369 - ayushmishra2005:move_various_str_tests_library, r=jyn514
Move Various str tests in library

Moved various string ui  tests in library  as a part of #76268

r? @matklad
2020-09-16 08:24:54 +02:00
Ralf Jung
c1a74a3c28
Rollup merge of #76366 - ayushmishra2005:arith_tests_in_library, r=jyn514
Add Arith Tests in Library

Added Arith Tests library as a part of #76268

r? @matklad
2020-09-16 08:24:52 +02:00
Ralf Jung
22dd07d555
Rollup merge of #76335 - CDirkx:const-duration, r=ecstatic-morse
Make all methods of `Duration` unstably const

Make the following methods of `Duration` unstable const under `duration_const_2`:
 - `from_secs_f64`
 - `from_secs_f32`
 - `mul_f64`
 - `mul_f32`
 - `div_f64`
 - `div_f32`

This results in all methods of `Duration` being (unstable) const.

Moved the tests to `library` as part of #76268.

Possible because of #72449, which made the relevant `f32` and `f64` methods const.

Tracking issue: #72440

r? @ecstatic-morse
2020-09-16 08:24:50 +02:00
Ralf Jung
19a62db492
Rollup merge of #76262 - howard0su:patch-1, r=cramertj
Use inline(never) instead of cold

inline(never) is better way to avoid optimizer to inline the function instead of cold.
2020-09-16 08:24:49 +02:00
Ralf Jung
fd86705a20
Rollup merge of #76062 - pickfire:patch-13, r=jyn514
Vec slice example fix style and show type elision
2020-09-16 08:24:46 +02:00
Ralf Jung
73858d01c3
Rollup merge of #76056 - pickfire:patch-10, r=jyn514
Add more info for Vec Drain doc

See its documentation for more
2020-09-16 08:24:40 +02:00
Lzu Tao
87666e5bce Prefer asm! over llvm_asm! in core 2020-09-16 04:47:46 +00:00
Ivan Tham
1dc4f8560f
Simplify iter fuse struct doc 2020-09-16 11:45:15 +08:00
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
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
Ralf Jung
7d67546a6a hopefully fix rustdoc links 2020-09-15 23:46:26 +02:00
Ralf Jung
c528d24196 fix slice::check_range aliasing problems 2020-09-15 23:14:41 +02:00
Yoshua Wuyts
143e4e975b Fix stabilization marker for future_readiness_fns
Moved it from 1.47.0 -> 1.48.0, which is the correct release for this to stabilize in
2020-09-15 23:12:08 +02:00
Ralf Jung
d888725fba reduce size of test_from_iter_specialization_with_iterator_adapters test in Miri 2020-09-15 23:03:07 +02:00
Adam Lesinski
fafb2e9de7 [fuchsia] Propagate the userspace UTC clock
On Fuchsia, spawning a subprocess does not automatically
clone all of the parent process' capabilities. UTC time on
Fuchsia is managed by a top-level userspace clock capability
that is cloned and passed to subprocesses.

This change ensures that any Rust subprocess gets access to the
UTC clock, if the parent had access to it. This is critical for
tests, which on Fuchsia, use panic=abort and spawn subprocesses
per test.
2020-09-15 13:54:46 -07: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
Guillaume Gomez
2a5a6b42ec Add missing code examples in libcore 2020-09-15 18:18:04 +02:00
Jethro Beekman
0122e08dae Update stdarch 2020-09-15 17:26:20 +02: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
Ivan Tham
1f572b0349
Vec doc use elision as code rather than comment 2020-09-15 14:41:43 +08: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
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
Camelid
58310ce94b Use intra-doc links in core::mem 2020-09-14 15:14:21 -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
Ivan Tham
5112f879ff
Remove flatten doc intra-doc links 2020-09-15 00:35:48 +08:00
Ivan Tham
b88155160c
Simplify iter flatten struct doc 2020-09-14 21:08:08 +08:00
Lzu Tao
6655ad7ed8 Removed outdated comments 2020-09-14 09:35:54 +00:00