Commit graph

352 commits

Author SHA1 Message Date
bors
f3c923a13a Auto merge of #76645 - fusion-engineering-forks:windows-lock, r=kennytm
Small cleanups in Windows Mutex.

 - Move `held` into the boxed part, since the SRW lock implementation does not use this. This makes the Mutex 50% smaller.
 - Use `Cell` instead of `UnsafeCell` for `held`, such that `.replace()` can be used.
 - Add some comments.
 - Avoid creating multiple `&mut`s to the critical section object in `ReentrantMutex`.
2020-09-17 19:23:58 +00: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
Mara Bos
0bb96e7490 Avoid creating &muts in Windows ReentrantMutex. 2020-09-16 21:16:32 +02:00
Mara Bos
3fadc603ab Don't use mut in Windows Mutex. 2020-09-16 21:09:53 +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
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
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
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
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
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
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
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
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
Guillaume Gomez
d069c7e928 Stabilize doc_alias feature 2020-09-14 11:03:47 +02:00
Jonas Schievink
e460f8508e
Rollup merge of #76651 - nicholasbishop:bishop-remove-windows-note, r=Mark-Simulacrum
Remove Windows details from Unix and VmWorks symlink() docstrings

This note is not relevant to other operating systems.
2020-09-13 20:21:16 +02:00
Jonas Schievink
f9b9467866
Rollup merge of #76640 - fusion-engineering-forks:synconcecell-drop, r=matklad
Simplify SyncOnceCell's `take` and `drop`.

Prevents copies by using `assume_init_read` and `assume_init_drop`.
2020-09-13 20:21:13 +02:00
Nicholas Bishop
2eeb8f18eb Remove Windows details from Unix and VmWorks symlink() docstrings
This note is not relevant to other operating systems.
2020-09-12 15:50:28 -04:00
Mara Bos
1016deb592 Small cleanups in Windows Mutex.
- Move `held` into the boxed part, since the SRW lock implementation
  does not use this. This makes the Mutex 50% smaller.
- Use `Cell` instead of `UnsafeCell` for `held`, such that `.replace()`
  can be used.
- Add some comments.
2020-09-12 20:50:17 +02:00
bors
989190874f Auto merge of #76538 - fusion-engineering-forks:check-useless-unstable-trait-impl, r=lcnr
Warn for #[unstable] on trait impls when it has no effect.

Earlier today I sent a PR with an `#[unstable]` attribute on a trait `impl`, but was informed that this attribute has no effect there. (comment: https://github.com/rust-lang/rust/pull/76525#issuecomment-689678895, issue: https://github.com/rust-lang/rust/issues/55436)

This PR adds a warning for this situation. Trait `impl` blocks with `#[unstable]` where both the type and the trait are stable will result in a warning:

```
warning: An `#[unstable]` annotation here has no effect. See issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information.
   --> library/std/src/panic.rs:235:1
    |
235 | #[unstable(feature = "integer_atomics", issue = "32976")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

---

It detects three problems in the existing code:

1. A few `RefUnwindSafe` implementations for the atomic integer types in `library/std/src/panic.rs`. Example:
d92155bf6a/library/std/src/panic.rs (L235-L236)
2. An implementation of `Error` for `LayoutErr` in `library/std/srd/error.rs`:
d92155bf6a/library/std/src/error.rs (L392-L397)
3. `From` implementations for `Waker` and `RawWaker` in `library/alloc/src/task.rs`. Example:
d92155bf6a/library/alloc/src/task.rs (L36-L37)

Case 3 interesting: It has a bound with an `#[unstable]` trait (`W: Wake`), so appears to have much effect on stable code. It does however break similar blanket implementations. It would also have immediate effect if `Wake` was implemented for any stable type. (Which is not the case right now, but there are no warnings in place to prevent it.) Whether this case is a problem or not is not clear to me. If it isn't, adding a simple `c.visit_generics(..);` to this PR will stop the warning for this case.
2020-09-12 18:01:33 +00:00
Mara Bos
aa68aaa8e1 Mark Once::new as #[inline].
Without this, it was not inlined in SyncOnceCell::into_inner(), causing
unecessary checks and dead code.
2020-09-12 17:11:47 +02:00
bors
85109afee9 Auto merge of #76561 - Thomasdezeeuw:iov-constant-limits, r=Amanieu
Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/O

Also updates the libc dependency to 0.2.77 (from 0.2.74) as the
constants were only recently added.

Related #68042, #75005

r? `@Amanieu` (also reviewed #75005)
2020-09-12 12:06:12 +00:00
Mara Bos
8a261a2b34 Simplify SyncOnceCell's take and drop. 2020-09-12 14:00:38 +02:00
Ralf Jung
2477f070fc
Rollup merge of #76583 - CDirkx:os-doc, r=jonas-schievink
Update `std::os` module documentation.

Adds missing descriptions for the modules `std::os::linux::fs` and `std::os::windows::io`.
Also adds punctuation for consistency with other descriptions.
2020-09-12 10:43:20 +02:00
bors
94a7ea271f Auto merge of #74328 - yoshuawuyts:stabilize-future-readiness-fns, r=sfackler
Stabilize core::future::{pending,ready}

This PR stabilizes `core::future::{pending,ready}`, tracking issue https://github.com/rust-lang/rust/issues/70921.

## Motivation

These functions have been on nightly for three months now, and have lived as part of the futures ecosystem for several years. In that time these functions have undergone several iterations, with [the `async-std` impls](https://docs.rs/async-std/1.6.2/async_std/future/index.html) probably diverging the most (using `async fn`, which in hindsight was a mistake).

It seems the space around these functions has been _thoroughly_ explored over the last couple of years, and the ecosystem has settled on the current shape of the functions. It seems highly unlikely we'd want to make any further changes to these functions, so I propose we stabilize.

## Implementation notes

This stabilization PR was fairly straightforward; this feature has already thoroughly been reviewed by the libs team already in https://github.com/rust-lang/rust/pull/70834. So all this PR does is remove the feature gate.
2020-09-12 02:13:28 +00:00
Thomas de Zeeuw
c394624471 Ignore unnecessary unsafe warnings
This is a work-around for a libc issue:
https://github.com/rust-lang/libc/issues/1888.
2020-09-11 19:12:06 +02:00
rijenkii
64b8fd7920 Add peek and peek_from to UnixStream and UnixDatagram 2020-09-11 20:07:08 +07:00
Mara Bos
cf8e5d1bc9 Mark Error impl for LayoutErr as stable.
This impl was effectively stable. #[unstable] had no effect here,
since both Error and LayoutErr were already stable.

This effectively became stable as soon as LayoutErr became stable, which
was in 1.28.0.
2020-09-11 13:36:15 +02:00
Mara Bos
f6fbf669ab Mark RefUnwindSafe impls for stable atomic types as stable.
These impls were effectively stable. #[unstable] had no effect here,
since both RefUnwindSafe and these types were already stable.

These effectively became stable as soon as the types became stable,
which was in 1.34.0.
2020-09-11 13:36:15 +02:00
Christiaan Dirkx
954361a3d4 Update std::os module documentation.
Adds missing descriptions for the modules std::os::linux::fs and std::os::windows::io.
Also adds punctuation for consistency with other descriptions.
2020-09-11 04:05:19 +02:00
Thomas de Zeeuw
f7b6ace029 Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/O
Also updates the libc dependency to 0.2.77 (from 0.2.74) as the
constants were only recently added.
2020-09-10 16:27:28 +02:00
Tyler Mandry
fa56cf537f
Rollup merge of #76458 - mbrubeck:hash_drain_filter, r=Amanieu
Add drain_filter method to HashMap and HashSet

Add `HashMap::drain_filter` and `HashSet::drain_filter`, implementing part of rust-lang/rfcs#2140.  These new methods are unstable.  The tracking issue is #59618.

The added iterators behave the same as `BTreeMap::drain_filter` and `BTreeSet::drain_filter`, except their iteration order is arbitrary.  The unit tests are adapted from `alloc::collections::btree`.

This branch rewrites `HashSet` to be a wrapper around `hashbrown::HashSet` rather than `std::collections::HashMap`.
 (Both are themselves wrappers around `hashbrown::HashMap`, so the in-memory representation is the same either way.)  This lets `std` re-use more iterator code from `hashbrown`.  Without this change, we would need to duplicate much more code to implement `HashSet::drain_filter`.

This branch also updates the `hashbrown` crate to version 0.9.0.  Aside from changes related to the `DrainFilter` iterators, this version only changes features that are not used in libstd or rustc.  And it updates `indexmap` to version 1.6.0, whose only change is compatibility with `hashbrown` 0.9.0.
2020-09-09 21:02:27 -07:00
Flying-Toast
c66789d572 Capitalize safety comments 2020-09-08 22:26:44 -04:00
Matt Brubeck
fb1fab5a67 Tests for HashMap/HashSet::drain_filter 2020-09-08 17:24:28 -07:00
Matt Brubeck
49aef963d3 Add HashMap::drain_filter and HashSet::drain_filter
Implements #59618.
2020-09-08 17:24:28 -07:00
Matt Brubeck
ebd15e790a Implement HashSet in terms of hashbrown::HashSet 2020-09-08 17:24:23 -07:00
Matt Brubeck
15ccdeb224 Update to hashbrown 0.9 2020-09-08 17:23:26 -07:00
Dylan DPC
87302a297c
Rollup merge of #76162 - abrausch:documentation-fix-duration_since, r=jyn514
Make duration_since documentation more clear
2020-09-09 01:35:10 +02:00
Alexander Brausch
98231bfb95 Make duration_since documentation more clear 2020-09-08 23:27:24 +02:00
bors
9fe551ae49 Auto merge of #74366 - t-rapp:tr-bufreader-pos, r=LukasKalbertodt
Implement Seek::stream_position() for BufReader

Optimization over `BufReader::seek()` for getting the current position without flushing the internal buffer.

Related to #31100. Based on the code in #70577.
2020-09-07 11:09:41 +00:00