Commit graph

496 commits

Author SHA1 Message Date
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
Federico Ponzi
ec7f9b927f
Deduplicates io::Write implementations 2020-09-11 11:39:31 +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
Tavian Barnes
a684153f29 Only call pthread_attr_destroy() after getattr_np() succeeds on all libcs
The calling convention of pthread_getattr_np() is to initialize the
pthread_attr_t, so _destroy() is only necessary on success (and _init()
isn't necessary beforehand).  On the other hand, FreeBSD wants the
attr_t to be initialized before pthread_attr_get_np(), and therefore it
should always be destroyed afterwards.
2020-09-09 11:10:43 -04:00
Tavian Barnes
a06edda3ad Fix segfault if pthread_getattr_np fails
glibc destroys[1] the passed pthread_attr_t if pthread_getattr_np()
fails.  Destroying it again leads to a segfault.  Fix it by only
destroying it on success for glibc.

[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_getattr_np.c;h=ce437205e41dc05653e435f6188768cccdd91c99;hb=HEAD#l205
2020-09-09 10:21:50 -04: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
Tobias Rapp
246d3271fe 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 code in #70577.
2020-09-07 09:26:48 +02:00
Dylan DPC
d444913840
Rollup merge of #76346 - gillespiecd:nlinks-docs, r=Dylan-DPC
Docs: nlink example typo

Small typo fix for the `nlink` function, extra whitespace before the `use` declaration
2020-09-07 01:18:13 +02:00
Dylan DPC
346d54d1f8
Rollup merge of #76344 - camelid:patch-6, r=KodrAus
Improve docs for `std::env::args()`

@rustbot modify labels: T-doc
2020-09-07 01:18:12 +02:00
Dylan DPC
e735247289
Rollup merge of #76312 - numbermaniac:patch-1, r=shepmaster
time.rs: Make spelling of "Darwin" consistent

On line 89 of this file, the OS name is written as "Darwin", but on line 162 it is written in all-caps. Darwin is usually spelt as a standard proper noun, i.e. "Darwin", rather than in all-caps.

This change makes that form consistent in both places.
2020-09-07 01:18:03 +02:00
Dylan DPC
2c62189db1
Rollup merge of #76299 - CDirkx:ip-tests, r=matklad
Make `Ipv4Addr` and `Ipv6Addr` const tests unit tests under `library`

These tests are about the standard library, not the compiler itself, thus should live in `library`, see #76268.
2020-09-07 01:17:52 +02:00
Dylan DPC
7ad2b3ab29
Rollup merge of #76287 - lzutao:rm-allowed, r=jyn514
Remove an unnecessary allowed lint

It is outdated.
2020-09-07 01:17:48 +02:00
bors
aa81d32165 Auto merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAus
Use Arc::clone and Rc::clone in documentation

This PR replaces uses of `x.clone()` by `Rc::clone(&x)` (or `Arc::clone(&x)`) to better match the documentation for those types.

@rustbot modify labels: T-doc
2020-09-06 12:34:31 +00:00
bors
23e49ddafb Auto merge of #76370 - fusion-engineering-forks:synconcecell-soundness, r=nagisa
Fix dropck issue of SyncOnceCell.

Fixes #76367.
2020-09-06 10:29:54 +00:00
bors
de921ab3c3 Auto merge of #75428 - the8472:fix-copy-eopnotsupp, r=joshtriplett
Workarounds for copy_file_range issues

fixes #75387
fixes #75446
2020-09-05 19:09:22 +00:00
Mara Bos
e56ea68db5 Add compile_fail test for SyncOnceCell's dropck issue. 2020-09-05 15:55:20 +02:00
Mara Bos
578e714393 Fix dropck issue of SyncOnceCell.
Fixes #76367.
2020-09-05 14:10:10 +02:00
Chris Gillespie
5456414d91 Fix nlink example typo 2020-09-04 14:41:27 -07:00
Camelid
85b11d50b2
Improve docs for std::env::args() 2020-09-04 14:00:09 -07:00
numbermaniac
8f11127d89
time.rs: Make spelling of "Darwin" consistent 2020-09-04 14:21:52 +10:00
Lzu Tao
a3ee65f87e Remove a useless allowed attr 2020-09-04 02:42:50 +00:00
Christiaan Dirkx
a2e077e405 Make Ipv4Addr and Ipv6Addr const tests unit tests under library
These tests are about the standard library, not the compiler itself, thus should live in `library`, see #76268.
2020-09-03 23:17:21 +02:00
bors
62dad457bc Auto merge of #73819 - euclio:rustdoc-summaries, r=jyn514,GuillaumeGomez
rustdoc: do not use plain summary for trait impls

Fixes #38386.
Fixes #48332.
Fixes #49430.
Fixes #62741.
Fixes #73474.

Unfortunately this is not quite ready to go because the newly-working links trigger a bunch of linkcheck failures. The failures are tough to fix because the links are resolved relative to the implementor, which could be anywhere in the module hierarchy.

(In the current docs, these links end up rendering as uninterpreted markdown syntax, so I don't think these failures are any worse than the status quo. It might be acceptable to just add them to the linkchecker whitelist.)

Ideally this could be fixed with intra-doc links ~~but it isn't working for me: I am currently investigating if it's possible to solve it this way.~~ Opened #73829.

EDIT: This is now ready!
2020-09-03 19:07:38 +00:00
Jethro Beekman
0b5e681f5a Improve SGX RWLock initializer test 2020-09-03 10:29:49 +02:00
Federico Ponzi
28db5214d2
More implementations of Write for immutable refs
Fixes #73836
2020-09-03 09:36:05 +02:00
bors
08deb863bd Auto merge of #76235 - jyn514:std-intra-links, r=poliorcetics
Convert many files to intra-doc links

Helps with https://github.com/rust-lang/rust/issues/75080
r? @poliorcetics
I recommend reviewing one commit at a time, but the diff is small enough you can do it all at once if you like :)
2020-09-03 05:53:48 +00:00
bors
1e33c742ca Auto merge of #75971 - Amjad50:libstd-deny-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum
Applied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasi

partial fix for #73904

There are still more that was not applied in [mod.rs]( 38fab2ea92/library/std/src/sys/wasi/mod.rs) and that is due to its using files from `../unsupported`

like:
```
#[path = "../unsupported/cmath.rs"]
pub mod cmath;
```
2020-09-03 02:15:16 +00:00
Amjad Alsharafi
559679b8c3 Applied #![deny(unsafe_op_in_unsafe_fn)] in library/std/src/wasi
All refactoring needed was only in `alloc.rs`, changed part of the code
in `alloc` method to satisfy the SAFETY statement
2020-09-03 08:27:59 +08:00
Dylan DPC
6d2b885112
Rollup merge of #76242 - RalfJung:read-fixme, r=Dylan-DPC
Read: adjust a FIXME reference

There's already another reference to https://github.com/rust-lang/rust/issues/42788 for basically the same problem, so lets reuse it here:
5e208efaa8/library/std/src/io/mod.rs (L369-L376)

r? @Dylan-DPC
2020-09-03 02:22:11 +02:00
Dylan DPC
3e156cfe90
Rollup merge of #76164 - lzutao:slice-array, r=ehuss
Link to slice pattern in array docs

Fix a todo in https://github.com/rust-lang/reference/issues/739#issuecomment-578408449
2020-09-03 02:22:04 +02:00
Dylan DPC
9605f94f69
Rollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morse
Make all methods of `std::net::Ipv4Addr` const

Make the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature:
 - `octets`
 - `is_loopback`
 - `is_private`
 - `is_link_local`
 - `is_global` (unstable)
 - `is_shared` (unstable)
 - `is_ietf_protocol_assignment` (unstable)
 - `is_benchmarking` (unstable)
 - `is_reserved` (unstable)
 - `is_multicast`
 - `is_broadcast`
 - `is_documentation`
 - `to_ipv6_compatible`
 - `to_ipv6_mapped`

This would make all methods of `Ipv6Addr` const.

Of these methods, `is_global`, `is_broadcast`, `to_ipv6_compatible`, and `to_ipv6_mapped` require a change in implementation.

Part of #76205
2020-09-03 02:22:02 +02:00
Dylan DPC
536b0c0c90
Rollup merge of #75150 - nanpuyue:deprecate_to_ipv6_compatible, r=LukasKalbertodt
Add a note for Ipv4Addr::to_ipv6_compatible

Previous discussion: #75019

> I think adding a comment saying "This isn't typically the method you want; these addresses don't typically function on modern systems. Use `to_ipv6_mapped` instead." would be a good first step, whether this method gets marked as deprecated or not.

_Originally posted by @joshtriplett in https://github.com/rust-lang/rust/pull/75150#issuecomment-680267745_
2020-09-03 02:21:58 +02:00
Howard Su
a80d39041e
Use inline(never) instead of cold
inline(never) is better way to avoid optimizer to inline the function instead of cold.
2020-09-03 06:31:21 +08:00
Joshua Nelson
bb103476a9 Fix incorrect link in prelude 2020-09-02 17:38:21 -04:00
Joshua Nelson
59a1a05bff Convert many files to intra-doc links
- Use intra-doc links for `std::io` in `std::fs`
- Use intra-doc links for File::read in unix/ext/fs.rs
- Remove explicit intra-doc links for `true` in `net/addr.rs`
- Use intra-doc links in alloc/src/sync.rs
- Use intra-doc links in src/ascii.rs
- Switch to intra-doc links in alloc/rc.rs
- Use intra-doc links in core/pin.rs
- Use intra-doc links in std/prelude
- Use shorter links in `std/fs.rs`

  `io` is already in scope.
2020-09-02 17:37:40 -04:00
bors
a167485e27 Auto merge of #75960 - camelid:patch-6, r=jyn514
Improve docs for the `const` keyword

@rustbot modify labels: T-doc
2020-09-02 17:35:46 +00:00
南浦月
3b29913295 add a note for Ipv4Addr::to_ipv6_compatible 2020-09-02 21:08:09 +08:00
Ralf Jung
0af3bd01df Read: adjust a FIXME reference 2020-09-02 12:34:15 +02:00
Federico Ponzi
321b680fe6
Update docs of OpenOptions::as_flags 2020-09-02 10:48:11 +02:00
Joshua Nelson
cafab51b29 Remove explicit links to true and false in ip.rs 2020-09-01 23:33:44 -04:00
Camelid
ce904783d0
Improve wording for const pointers 2020-09-01 19:44:20 -07:00
Tyler Mandry
11ff32f9ec
Rollup merge of #76206 - CDirkx:const-ipv6, r=ecstatic-morse
Make all methods of `std::net::Ipv6Addr` const

Make the following methods of `std::net::Ipv6Addr` unstable const under the `const_ipv6` feature:
- `segments`
- `is_unspecified`
- `is_loopback`
- `is_global` (unstable)
- `is_unique_local`
- `is_unicast_link_local_strict`
- `is_documentation`
- `multicast_scope`
- `is_multicast`
- `to_ipv4_mapped`
- `to_ipv4`

This would make all methods of `Ipv6Addr` const.

Changed the implementation of `is_unspecified` and `is_loopback` to use a `match` instead of `==`, all other methods did not require a change.

All these methods are dependent on `segments`, the current implementation of which requires unstable `const_fn_transmute` ([PR#75085](https://github.com/rust-lang/rust/pull/75085)).

Part of #76205
2020-09-01 18:24:41 -07:00
Tyler Mandry
34c8b7a92c
Rollup merge of #76099 - camelid:patch-8, r=jyn514
Add info about `!` and `impl Trait`

Fixes #76094.

@rustbot modify labels: T-doc C-enhancement
2020-09-01 18:24:29 -07:00
Camelid
54a4fd1eb9
Minor improvements
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-01 17:38:16 -07:00
Christiaan Dirkx
0c77257e56 Make all remaining methods of std::net::Ipv4Addr const
Makes the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature:
 - `is_global`
 - `is_reserved`
 - `is_broadcast`
 - `to_ipv6_compatible`
 - `to_ipv6_mapped`

This results in all methods of `Ipv4Addr` being const.

Also adds tests for these methods in a const context.
2020-09-01 23:55:17 +02:00
CDirkx
a43dd4f401 Change implementation of Ipv6Addr::is_unspecified and is_loopback from matches! to u128 comparison
Done because `matches!` doesn't optimize well with array comparisons
2020-09-01 21:05:26 +02:00
CDirkx
ee9e48bafc Make methods unstable const under const_ipv4 2020-09-01 19:50:01 +02:00
CDirkx
b31cc8f83e Make all methods of std::net::Ipv6Addr const
Make the following methods of `std::net::Ipv6Addr` unstable const under the `const_ipv6` feature:
- `segments`
- `is_unspecified`
- `is_loopback`
- `is_global` (unstable)
- `is_unique_local`
- `is_unicast_link_local_strict`
- `is_documentation`
- `multicast_scope`
- `is_multicast`
- `to_ipv4_mapped`
- `to_ipv4`

Changed the implementation of `is_unspecified` and `is_loopback` to use a `match` instead of `==`.

Part of #76205
2020-09-01 19:00:20 +02:00
bors
d9cd4a33f5 Auto merge of #76047 - Dylan-DPC:rename/maybe, r=RalfJung
rename get_{ref, mut} to assume_init_{ref,mut} in Maybeuninit

References #63568

Rework with comments addressed from #66174

Have replaced most of the occurrences I've found, hopefully didn't miss out anything

r? @RalfJung

(thanks @danielhenrymantilla for the initial work on this)
2020-09-01 05:41:22 +00:00
Camelid
55637f5669
Break line at 100 characters 2020-08-31 19:44:21 -07:00
Camelid
913354b846
Improve assert! section in bool docs 2020-08-31 19:41:27 -07:00
Camelid
c4c058c716 Improve wording
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-31 19:33:08 -07:00
Camelid
cdd6f11012 Remove empty comment 2020-08-31 19:33:08 -07:00
Camelid
e13a70122d Redefine Debug instead of importing it
This reverts commit 7e2548fe69.

Now I know why it was redefined: it seems like it's potentially because
of the orphan rule. Here are the error messages:

error[E0119]: conflicting implementations of trait `std::fmt::Debug` for type `!`:
 --> src/primitive_docs.rs:236:1
  |
6 | impl Debug for ! {
  | ^^^^^^^^^^^^^^^^
  |
  = note: conflicting implementation in crate `core`:
          - impl std::fmt::Debug for !;

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
 --> src/primitive_docs.rs:236:1
  |
6 | impl Debug for ! {
  | ^^^^^^^^^^^^^^^-
  | |              |
  | |              `!` is not defined in the current crate
  | impl doesn't use only types from inside the current crate
  |
  = note: define and implement a trait or new type instead
2020-08-31 19:33:08 -07:00
Tyler Mandry
b675824493
Rollup merge of #75945 - pickfire:patch-7, r=jyn514
Use `env::func()`, not 'the function env::func' in docs for std::env

Follow up of https://github.com/rust-lang/rust/pull/75629

r? @jyn514
2020-08-31 19:18:13 -07:00
Federico Ponzi
7c1e5c1dcd
Update OpenOptions::as_flags docs, and minor styling 2020-08-31 23:20:56 +02:00
Lzu Tao
a74d4e4889 Link to slice pattern in array docs 2020-08-31 14:53:02 +00:00
Federico Ponzi
2c9e27b759
Merge branch 'convert-openoptions-cint' of github.com:FedericoPonzi/rust into convert-openoptions-cint 2020-08-31 16:02:12 +02:00
Federico Ponzi
1bc0627607
Add as_flag function to the OpenOptionsExt struct 2020-08-31 15:48:28 +02:00
CDirkx
fbb3673331 Make more Ipv4Addr methods const
Constify the following methods of `std::net::Ipv4Addr`:
 - `octets`
 - `is_loopback`
 - `is_private`
 - `is_link_local`
 - `is_shared`
 - `is_ietf_protocol_assignment`
 - `is_benchmarking`
 - `is_multicast`
 - `is_documentation`

Also insta-stabilizes these methods as const.

Possible because of the stabilization of const integer arithmetic and control flow.
2020-08-31 05:09:20 +02:00
Lzu Tao
a4e926daee std: move "mod tests/benches" to separate files
Also doing fmt inplace as requested.
2020-08-31 02:56:59 +00:00
Alexis Bourget
81e85ce76d Move to Arc::clone(&x) over x.clone() in library/std 2020-08-30 21:59:43 +02:00
Camelid
37ea97cc10
Explain why the 0 is a u32 2020-08-30 11:43:16 -07:00
Camelid
7e2548fe69
Import Debug instead of redefining it 2020-08-30 11:39:45 -07:00
Andy Russell
98232ece14
fix broken trait method links 2020-08-30 12:04:43 -04:00
Federico Ponzi
eb3906be4a
Fix typo get openoptions function name
Co-authored-by: Ivan Tham <pickfire@riseup.net>
2020-08-30 17:01:20 +02:00
Federico Ponzi
27c90b881d
initial implementation of OpenOptions to c_int 2020-08-30 16:27:08 +02:00
Ivan Tham
1d017eb6a4
Fix env doc vars_os broken link 2020-08-30 21:19:21 +08:00
DPC
b3d7b7bdcb update fixmes 2020-08-30 14:43:52 +02:00
Camelid
bd3196282b
other branch -> else branch 2020-08-29 20:53:40 -07:00
Camelid
80dcad9e5b
Be more specific about polymorphic return types
I no longer say "polymorphic" since it's a bit ambiguous here.
2020-08-29 20:52:09 -07:00
Camelid
26eab6a0d5
Specify 0 of type u32 2020-08-29 20:48:53 -07:00
Camelid
0d9a2abe69
It's only an issue without an impl Trait for ! 2020-08-29 20:41:36 -07:00
Camelid
fd985e29dd
cannot have divergence -> cannot diverge 2020-08-29 20:35:58 -07:00
Ivan Tham
00cf550c2b Env use shorter intra-doc links in path
vars() rather than vars function

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Use [xxx()] rather than the [xxx] function

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Env text representation of function intra-doc link

Suggested by @jyn514

Link join_paths in env doc for parity

Change xxx to env::xxx for lib env doc

Add link requsted by @jyn514

Fix doc build with same link

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Fix missing intra-doc link

Fix added whitespace in doc

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Add brackets for `join_paths`

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Use unused link join_paths

Removed same link for join_paths

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Remove unsed link join_paths
2020-08-30 11:16:06 +08:00
Camelid
4aae781407 Add info about ! and impl Trait 2020-08-29 19:59:22 -07:00
Dylan DPC
96e0bc7b6b
Rollup merge of #75990 - rylev:arm-fastfail, r=alexcrichton
Add __fastfail for Windows on arm/aarch64

Fixes #73215
2020-08-30 01:43:54 +02:00
Dylan DPC
027b2f1e06
Rollup merge of #75832 - kofls:intradoc-fix, r=jyn514
Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs…

…, primitive_docs.rs & poison.rs

Partial fix for #75080

r? @jyn514
2020-08-30 01:43:37 +02:00
Ryan Levick
d931e97402 Explicitly look for 'thumb-mode' before using __fastfail on 'arm' 2020-08-29 12:30:49 +02:00
bors
360a372f2c Auto merge of #75877 - vigoux:master, r=Amanieu
Update compiler-builtins

Update the compiler-builtins dependency to include latest changes.

This allows for `aarch64-unknown-linux-musl` to pass all tests.

Fixes #57820 and fixes #46651
2020-08-29 01:48:40 +00:00
DPC
5e208efaa8 rename get_{ref, mut} to assume_init_{ref,mut} in Maybeuninit 2020-08-29 02:13:02 +02:00
bors
7b1dd61bda Auto merge of #72808 - Lucretiel:line-writer-reimpl, r=Amanieu
Substantial refactor to the design of LineWriter

# Preamble

This is the first in a series of pull requests designed to move forward with https://github.com/rust-lang/rust/issues/60673 (and the related [5 year old FIXME](ea7181b5f7/src/libstd/io/stdio.rs (L459-L461))), which calls for an update to `Stdout` such that it can be block-buffered rather than line-buffered under certain circumstances (such as a `tty`, or a user setting the mode with a function call). This pull request refactors the logic `LineWriter` into a `LineWriterShim`, which operates on a `BufWriter` by mutable reference, such that it is easy to invoke the line-writing logic on an existing `BufWriter` without having to construct a new `LineWriter`.

Additionally, fixes #72721

## A note on flushing

Because the word **flush** tends to be pretty overloaded in this discussion, I'm going to use the word **unbuffered** to refer to a `BufWriter` sending its data to the wrapped writer via `write`, without calling `flush` on it, and I'll be using **flushed** when referring to sending data via flush, which recursively writes the data all the way to the final sink.

For example, given a `T = BufWriter<BufWriter<File>>`, saying that `T` **unbuffers** its data means that it is sent to the inner `BufWriter`, but not necessarily to the `File`, whereas saying that `T` **flushes** its data means that causes it (via `Write::flush`) to be delivered all the way to `File`.

# Goals

Once it became clear (for reasons described below) that the best way to approach this would involve refactoring `LineWriter` to work more directly on `BufWriter`'s internals, I established the following design goals for the refactor:

- Do not duplicate logic with `BufWriter`. It's great at buffering and then unbuffering data, so use the existing logic as much as possible.
- Minimize superfluous copying of data into `BufWriter`'s buffer.
- Eliminate calls to `BufWriter::flush` and instead do the same thing as `BufWriter::write`, which is to only write to the wrapped writer (rather than flushing all the way down to the final data sink).
- Uphold the "at-most 1 write of new data" convention of `Write::write`
- Minimize or eliminate dropping errors (that is, eliminate the parts of the old design that threw away errors because `write` *must* report if any bytes were written)
- As much as possible, attempt to fully flush completed lines, and *not* flush partial lines. One of the advantages of this design is that, so long as we don't encounter lines larger than the `BufWriter`'s capacity, partial lines will never be unbuffered, while completed lines will *always* be unbuffered (with subsequent calls to `LineWriter::write` retrying failed writes before processing new data.

# Design

There are two major & related parts of the design.

First, a new internal stuct, `LineWriterShim`, is added. This struct implements all of the actual logic of line-writing in a `Write` implementation, but it only operates on an `&mut BufWriter`. This means that this shim can be constructed on-the-fly to apply line writing logic to an existing `BufWriter`. This is in fact how `LineWriter` has been updated to operate, and it is also how `Stdout` is being updated in my [development branch](https://github.com/Lucretiel/rust/tree/stdout-block-buffer) to switch which mode it wants to use at runtime.

[An example of how this looks in practice](f24f272df6/src/libstd/io/stdio.rs (L479-L484)
)

The second major part of the design that the line-buffering logic, implemented in `LineWriterShim`, has been updated to work slightly more directly on the internals of `BufWriter`. Mostly it makes us of the public interface—particularly `buffer()` and `get_mut()`—but it also controls the flushing of the buffer with `flush_buf` rather than `flush`, and it writes to the buffer infallibly with a new `write_to_buffer` method. This has several advantages:

- Data no longer has to round trip through the `BufWriter`'s buffer. If the user provides a complete line, that line is written directly to the inner writer (after ensuring the existing buffer is flushed).
- The conventional contract of `write`—that at-most 1 attempt to write new data is made—is much more cleanly upheld, because we don't have to perform fallible flushes and perform semi-complicated logic of trying to pretend errors at different stages didn't happen. Instead, after attempting to write lines directly to the buffer, we can infallibly add trailing data to the buffer without allowing any attempts to continue writing it to the `inner` writer.
- Perhaps most importantly, `LineWriter` *no longer performs a full flush on every line.* This makes its behavior much more consistent with `BufWriter`, which unbuffers data to its inner writer, without trying to flush it all the way to the final device. Previously, `LineWriter` had no choice but to use `flush` to ensure that the lines were unbuffered, but by writing directly to `inner` via `get_mut()` (when appropriate), we can use a more correct behavior.

## New(ish) line buffering logic

The logic for line writing has been cleaned up, as described above. It now follows this algorithm for `write`, with minor adjustments for `write_all` and `write_vectored`:

- Does our input data contain a newline?
    - If no:
        - simply use the regular `BufWriter::write` to write it; this will append it to the buffer and/or flush it as necessary based on how full the buffer is and how much input data there is.
        - additionally, if the current buffer ends with `'\n'`, attempt to immediately flush it with `flush_buf` before calling `BufWriter::write` This reproduces the old `needs_flush` behavior and ensures completed lines are flushed as soon as possible. The reason we only check if the buffer *ends* with `'\n'` is discussed later.
    - If yes:
        - First, `flush_buf`
        - Then use `bufwriter.get_mut().write()` to write the input data directly to the underlying writer, up to the last newline. Make at most one attempt at this.
        - If it errors, return the error
        - If it succeeds with a full write, add the remaining data (between the last newline and the end of the input) to the buffer. In order to uphold the "at-most 1 attempt to write new data" convention, no attempts are made to write this data to the inner writer (though obviously a subsequent write may immediately flush it, e.g., if it totally filled the buffer's capacity.
        - If it only partially succeeds, buffer the data only up to the last newline. We do this to try to avoid writing partial lines to the inner writer where possible (that is, whenever the lines are shorter than the total buffer capacity).

While it was not my intention for this behavior to diverge from this existing `LineWriter` algorithm, this updated design emerged very naturally once `LineWriter` wasn't burdened with having to only operate via `BufWriter::flush`. There essentially two main changes to observable behavior:

- `flush` is no longer used to unbuffer lines. The are only written to the writer wrapped by `LineWriter`; this inner writer might do its own buffering. This change makes `LineWriter` consistent with the behavior of `BufWriter`. This is probably the most obvious user-visible change; it's the one I most expect to provoke issue reports, if any are provoked.
- Unless a line exceeds the capacity of the buffer, partial lines are not unbuffered (without the user manually calling flush). This is a less surprising behavior, and is enabled because `LineWriter` now has more precise control of what data is buffered and when it is unbuffered. I'd be surprised if anyone is relying on `LineWriter` unbuffering or flushing *partial* lines that are shorter than the capacity, so I'm not worried about this one.

None of these changes are inconsistent with any published documentation of `LineWriter`. Nonetheless, like all changes with user-facing behavior changes, this design will obviously have to be very carefully scrutinized.

# Alternative designs and design rationalle

The initial goal of this project was to provide a way for the `LineWriter` logic to be operable directly on a `BufWriter`, so that the updated `Stdout` doesn't need to do something convoluted like `enum { BufWriter, LineWriter }` (which ends up being ~~impossible~~ difficult to transition between states after being constructed). The design went through several iterations before arriving at the current draft.

The major first version simply involved adding methods like `write_line_buffered` to `BufWriter`; these would contain the actual logic of line-buffered writing, and would additionally have the advantages (described above) of operating directly on the internals of `BufWriter`. The idea was that `LineWriter` would simply call these methods, and the updated `Stdout` would use either `BufWriter::write` or `BufWriter::write_line_buffered`, depending on what mode it was in.

The major issue with this design is that it loses the ability to take advantage of the `io::Write` trait, which provides several useful default implementations of the various io methods, such as `write_fmt` and `write_all`, just using the core methods. For this reason, the `write_line_buffered` design was retained, but moved into a separate struct called `LineWriterShim` which operates on an `&mut LineWriter`. As part of this move, the logic was lightly retooled to not touch the innards of `BufWriter` directly, but instead to make use of the unexported helper methods like `flush_buf`.

The other design evolutions were mostly related to answering questions like "how much data should be buffered", "how should partial line writes be handled", etc. As much as possible I tried to answer these by emulating the current `LineWriter` logic (which, for example, retries partial line writes on subsequent calls to `write`) while still meeting the refactor design goals.

# Next steps

~Currently, this design fails a few `LineWriter` tests, mostly because they expect `LineWriter` to *fully* flush its content. There are also some changes to the way that `LineWriter` buffers data *after* writing completed lines, aimed at ensuring that partial lines are not unbuffered prematurely. I want to make sure I fully understand the intent behind these tests before I either update the test or update this design so that they pass.~

However, in the meantime I wanted to get this published so that feedback could start to accumulate on it. There's a lot of errata around how I arrived at this design that didn't really fit in this overlong document, so please ask questions about anything that confusing or unclear and hopefully I can explain more of the rationale that led to it.

# Test updates

This design required some tests to be updated; I've research the intent behind these tests (mostly via `git blame`) and updated them appropriately. Those changes are cataloged here.

- `test_line_buffer_fail_flush`: This test was added as a regression test for #32085, and is intended to assure that an errors from `flush` aren't propagated when preceded by a successful `write`. Because type of issue is no longer possible, because `write` calls `buffer.get_mut().write()` instead of `buffer.write(); buffer.flush();`, I'm simply removing this test entirely. Other, similar error invariants related to errors during write-retrying are handled in other test cases.
- `erroneous_flush_retried`: This test was added as a regression test for #37807, and was intended to ensure that flush-retrying (via `needs_flush`) and error-ignoring were being handled correctly (ironically, this issue was caused by the flush-error-ignoring, above). Half of that issue is not possible by design with this refactor, because we no longer make fallible i/o calls that might produce errors we have to ignore after unbuffering lines. The `should_flush` behavior is captured by checking for a trailing newline in the `LineWriter` buffer; this test now checks that behavior.
- `line_vectored`: changes here were pretty minor, mostly related to when partial lines are or aren't written. The old implementation of `write_vectored` used very complicated logic to precisely determine the location of the last newline and precisely write up to that point; this required doing several consecutive fallible writes, with all the complex error handling or ignoring issues that come with it. The updated design does at-most one write of a subset of total buffers (that is, it doesn't split in the middle of a buffer), even if that means writing partial lines. One of the major advantages of the new design is that the underlying vectored write operation on the device can be taken advantage of, even with small writes, so long as they include a newline; previously these were unconditionally buffered then written.
- `line_vectored_partial_and_errors`: Pretty similiar to `line_vectored`, above; this test is for basic error recovery in `write_vectored` for vectored writes. As previously discussed, the mocked behavior being tested for (errors ignored under certain circumstances) no occurs, so I've simplified the test while doing my best to retain its spirit.
2020-08-28 23:41:57 +00:00
Ryan Levick
9e2228d2d0 Back to opcode for 32 bit ARM __fastfail 2020-08-28 17:40:56 +02:00
Ryan Levick
8bcc4d6178 Switch to asm! macro and use brk instruction on ARM 2020-08-28 11:22:21 +02:00
Pietro Albini
cbe3aef559
Rollup merge of #75946 - pickfire:patch-8, r=jyn514
Error use explicit intra-doc link and fix text

Follow up of https://github.com/rust-lang/rust/pull/75629

r? @jyn514
2020-08-28 10:24:00 +02:00
Thomas Vigouroux
392478c29e Update compiler-builtins
Fixes #57820 and #46651
2020-08-28 09:02:39 +02:00
Nathan West
c91e764d51 Once again, x.py tidy 2020-08-27 22:55:58 -04:00
Nathan West
d2d8bcb50e Typo fixes 2020-08-27 22:49:16 -04:00
Nathan West
017ed5a579 Improvements to LineWriter::write_all
`LineWriter::write_all` now only emits a single write when writing a
newline when there's already buffered data.
2020-08-27 22:32:28 -04:00
bors
41aaa90c67 Auto merge of #70212 - Amanieu:catch_foreign, r=Mark-Simulacrum
Abort when foreign exceptions are caught by catch_unwind

Prior to this PR, foreign exceptions were not caught by catch_unwind, and instead passed through invisibly. This represented a painful soundness hole in some libraries ([take_mut](https://github.com/Sgeo/take_mut/blob/master/src/lib.rs#L37)), which relied on `catch_unwind` to handle all possible exit paths from a closure.

With this PR, foreign exceptions are now caught by `catch_unwind` and will trigger an abort since catching foreign exceptions is currently UB according to the latest proposals by the FFI unwind project group.

cc @rust-lang/wg-ffi-unwind
2020-08-28 01:20:17 +00:00
Amanieu d'Antras
239f833ed1 Abort when catch_unwind catches a foreign exception 2020-08-27 21:08:30 +01:00
Ryan Levick
970e7793bf Add __fastfail for Windows on arm/aarch64 2020-08-27 19:11:48 +02:00
bors
3d0c847d33 Auto merge of #74941 - dylanmckay:replace-broken-avr-unknown-unknown-target, r=oli-obk
[AVR] Replace broken 'avr-unknown-unknown' target with 'avr-unknown-gnu-atmega328' target

The `avr-unknown-unknown` target has never worked correctly, always trying to invoke
the host linker and failing. It aimed to be a mirror of AVR-GCC's
default handling of the `avr-unknown-unknown' triple (assume bare
minimum chip features, silently skip linking runtime libraries, etc).
This behaviour is broken-by-default as it will cause a miscompiled executable
when flashed.

This patch improves the AVR builtin target specifications to instead
expose only a 'avr-unknown-gnu-atmega328' target. This target system is
`gnu`, as it uses the AVR-GCC frontend along with avr-binutils. The
target triple ABI is 'atmega328'.

In the future, it should be possible to replace the dependency on
AVR-GCC and binutils by using the in-progress AVR LLD and compiler-rt support.
Perhaps at that point it would make sense to add an
'avr-unknown-unknown-atmega328' target as a better default when
implemented.

There is no current intention to add in-tree AVR target specifications for other
AVR microcontrollers - this one can serve as a reference implementation
for other devices via `rustc --print target-spec-json
avr-unknown-gnu-atmega328p`.

There should be no users of the existing 'avr-unknown-unknown' Rust
target as a custom target specification JSON has always been
recommended, and the avr-unknown-unknown target could never pass the
linking step anyway.
2020-08-27 15:48:56 +00:00
Ivan Tham
3a814f3f57
Reduce duplicate doc link in error
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-27 23:30:15 +08:00
bors
118860a7e7 Auto merge of #75947 - pietroalbini:bootstrap-update, r=Mark-Simulacrum
Bump version to 1.48 and update cfg(bootstrap)s

r? @Mark-Simulacrum
2020-08-27 09:24:51 +00:00
Pietro Albini
1b6590c9f4
forgot to remove a cfg(not(bootstrap)) 2020-08-27 10:58:34 +02:00
Dylan DPC
a838f2fc79
Rollup merge of #75818 - ollie27:doc_systemtime_windows, r=retep998
Update docs for SystemTime Windows implementation

Windows now uses `GetSystemTimePreciseAsFileTime` (since #69858) on versions of Windows that support it.
2020-08-27 01:14:11 +02:00
Dylan DPC
730449d22a
Rollup merge of #75758 - bpangWR:master, r=Mark-Simulacrum
Fixes for VxWorks

r? @alexcrichton
2020-08-27 01:14:04 +02:00
Dylan DPC
2eec2ecbde
Rollup merge of #74730 - androm3da:fix_libstd_hexlinux_01, r=dtolnay
Hexagon libstd: update type defs
2020-08-27 01:14:02 +02:00
Camelid
294c1160bb
Improve docs for the const keyword 2020-08-26 14:51:21 -07:00
bors
48717b6f3c Auto merge of #75912 - scottmcm:manuallydrop-vs-forget, r=Mark-Simulacrum
Suggest `mem::forget` if `mem::ManuallyDrop::new` isn't used

I think this communicates the intent more idiomatically, and is shorter anyway.

Inspired because [it came up on URLO](https://users.rust-lang.org/t/validity-of-memory-area-after-std-forget/47730/7?u=scottmcm), and it turns out that std had done it too in one spot:
![image](https://user-images.githubusercontent.com/18526288/91203819-e19f2980-e6f2-11ea-9112-835f3b22ce05.png)
2020-08-26 18:40:51 +00:00
Surya Midatala
7569cf98f9 Merge conflict fix: disambiguate f32 -> prim@f32 and u32 -> prim@u32 2020-08-26 21:55:42 +05:30
Joshua Nelson
25c034c52e Use allow(unused_imports) instead of cfg(doc) for imports used only for intra-doc links 2020-08-26 21:43:46 +05:30
Joshua Nelson
9b89d8a7a2 Fix link to f32
Co-authored-by: Oliver Middleton <olliemail27@gmail.com>
2020-08-26 21:43:46 +05:30
Surya Midatala
621cbaafff Use crate::mod to disambiguate links 2020-08-26 21:43:46 +05:30
Surya Midatala
f10ab91391 Add suggestions from code review 2020-08-26 21:43:46 +05:30
Surya Midatala
b3437f36e0 Add missed links in primitive_docs.rs 2020-08-26 21:43:46 +05:30
Surya Midatala
a712fbd50b Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs, primitive_docs.rs & poison.rs 2020-08-26 21:43:46 +05:30
Ivan Tham
9ea4593572
Use [xxx()] rather than the [xxx] function
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-26 23:21:44 +08:00
Ivan Tham
16d8d4b899
Error use explicit intra-doc link and fix text 2020-08-26 22:41:56 +08:00
bors
ffd59bf9c6 Auto merge of #75687 - TimDiekmann:realloc-align, r=Amanieu
Allow reallocation to different alignment in `AllocRef`

The allocator-wg [has decided](https://github.com/rust-lang/wg-allocators/issues/5#issuecomment-672591112) to support reallocating to a different alignment in `AllocRef`. For more details please see the linked issue.

r? @Amanieu

closes https://github.com/rust-lang/wg-allocators/issues/5
2020-08-26 10:44:28 +00:00
Pang, Baoshan
079baafdf1 For VxWorks:
fix building errors
use wr-c++ as linker
2020-08-25 12:09:39 -07:00
Yoshua Wuyts
688f4471fd Stabilize future readiness fns 2020-08-25 19:08:43 +02:00
Scott McMurray
f3024073f9 Suggest mem::forget if mem::ManuallyDrop::new isn't used
I think this communicates the intent better, and is shorter anyway.
2020-08-25 09:40:53 -07:00
bors
3d6a3ed158 Auto merge of #75364 - rylev:libpanic-abort-failfast, r=alexcrichton
Call into fastfail on abort in libpanic_abort on Windows x86(_64)

This partially resolves #73215 though this is only for x86 targets. This code is directly lifted from [libstd](13290e83a6/library/std/src/sys/windows/mod.rs (L315)). `__fastfail` is the preferred way to abort a process on Windows as it will hook into debugger toolchains.

Other platforms expose a `_rust_abort` symbol which wraps `std::sys::abort_internal`. This would also work on Windows, but is a slightly largely change as we'd need to make sure that the symbol is properly exposed to the linker. I'm inlining the call to the `__fastfail`, but the indirection through `rust_abort` might be a cleaner approach.

 A different instruction must be used on ARM architectures. I'd like to verify this works first before tackling ARM.
2020-08-25 07:36:52 +00:00
bors
f44c6e4e28 Auto merge of #75110 - lzutao:ip-endianness, r=Mark-Simulacrum
Minor changes to Ipv4Addr

Minor changes to Ipv4Addr

* Impl IntoInner rather than AsInner for Ipv4Addr
* Add some comments
* Add test to show endiannes of Ipv4Addr display
2020-08-24 20:05:32 +00:00
bors
aa7010df90 Auto merge of #75815 - jyn514:ambiguous-primitives, r=guillaumegomez
Report an ambiguity if both modules and primitives are in scope for intra-doc links

Closes https://github.com/rust-lang/rust/issues/75381

- Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace
- Refactor `report_ambiguity` into a closure

Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case.

I also need to update libstd to use `prim@char` instead of `type@char`. If possible I would also like to refactor `ambiguity_error` to use `Disambiguator` instead of its own hand-rolled match - that ran into issues with `prim@` (I updated one and not the other) and it would be better for them to be in sync.
2020-08-24 10:29:29 +00:00
Dylan McKay
a0905ceff9 [AVR] Rename the last few remaining references from 'avr-unknown-unknown' to 'avr-unknown-gnu-atmega328' 2020-08-24 18:45:24 +12:00
Yuki Okushi
47a03d9815
Rollup merge of #75859 - jrheard:patch-2, r=jonas-schievink
doc: Fix typo in std::process::Child documentation

Nearly done reading stdlib docs, found another small typo, here's a PR!

r? @steveklabnik
2020-08-24 11:48:55 +09:00
Yuki Okushi
282d258cd1
Rollup merge of #75847 - camelid:patch-1, r=dtolnay
Switch to intra-doc links in `std::collections`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:50 +09:00
Yuki Okushi
25a677ccef
Rollup merge of #75831 - lzutao:https, r=Dylan-DPC
doc: Prefer https link for wikipedia URLs

A tiny changes.
2020-08-24 11:48:47 +09:00
Yuki Okushi
640b36f97a
Rollup merge of #75821 - camelid:intra-doc-links-for-std-macros, r=jyn514
Switch to intra-doc links in `std::macros`

Part of #75080.

---

* Switch to intra-doc links in `std::macros`
* Fix typo in module docs
* Link to `std::io::stderr` instead of `std::io::Stderr` to match the
  link text
* Link to `std::io::stdout`

---

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:42 +09:00
Joshua Nelson
6f4681bacc Convert str -> prim@str in std 2020-08-23 22:40:20 -04:00
JR Heard
bc47f70f88
doc: Fix typo in std::process::Child documentation 2020-08-23 16:38:23 -07:00
Camelid
e9928d8926
Switch to intra-doc links in std::collections 2020-08-23 13:51:01 -07:00
bors
d02a209eb9 Auto merge of #75028 - MrModder:master, r=steveklabnik
Document that slice refers to any pointer type to a sequence

I was recently confused about the way slices are represented in memory. The necessary information was not available in the std-docs directly, but was a mix of different material from the reference and book.

This PR should clear up the definition of slices a bit more in the documentation. Especially the fact that the term slice refers to the pointer/reference type, e.g. `&[T]`, and not `[T]`.
It also documents that slice pointers are twice the size of pointers to `Sized` types, as this concept may be unfamiliar to users coming from other languages that do not have the concept of "fat pointers" (especially C/C++).

I've documented why this was important to me and my findings in [this blog post](https://codecrash.me/understanding-rust-slices).

r? @lcnr
2020-08-23 16:59:10 +00:00
Ralf Jung
eb27828bf1 remove an unused feature flag 2020-08-23 16:12:39 +02:00
Leon Matthes
cf76256b83 Revert changed paragraph about slice definition.
This reverts part of commit e6c83dd57b.
As requested by @steveklabnik .
2020-08-23 16:02:22 +02:00
Lzu Tao
2c995d29f7 Prefer https link for wikipedia URLs 2020-08-23 10:02:42 +00:00
Camelid
637659be6a Add missing links 2020-08-22 20:23:50 -07:00
Camelid
becf5ec4ea Add missing intra-doc link 2020-08-22 17:41:40 -07:00
Camelid
5d32786b4f Switch to intra-doc links in std::macros
Also:
* Fix typo in module docs
* Link to `std::io::stderr` instead of `std::io::Stderr` to match the
  link text
* Link to `std::io::stdout`
2020-08-22 15:44:00 -07:00
Oliver Middleton
57e7e2875b Update docs for SystemTime Windows implementation
Windows now uses `GetSystemTimePreciseAsFileTime` on versions of Windows that support it.
2020-08-22 22:00:33 +01:00
bors
c5a8b7b901 Auto merge of #75790 - LeSeulArtichaut:std-intra-doc, r=jyn514
Use intra-doc-links in `std::sync::*`

Helps with #75080.
r? @jyn514
2020-08-22 08:54:29 +00:00
LeSeulArtichaut
f3a832f4b4 Use intra-doc-links in std::sync::* 2020-08-22 01:28:26 +02:00
Tomasz Miąsko
78e094632e Remove wrapper type handling absent raw standard streams
Raw standard streams are always available.  Remove unused wrapper type
that was supposed to be responsible for handling their absence.
2020-08-21 13:17:20 +02:00
Tomasz Miąsko
4a00421ba4 Make raw standard stream constructors const 2020-08-21 13:17:20 +02:00
Tomasz Miąsko
479c23bb49 Remove result type from raw standard streams constructors
Raw standard streams constructors are infallible. Remove unnecessary
result type.
2020-08-21 13:17:20 +02:00
Yuki Okushi
2a7f868d7f
Rollup merge of #75750 - poliorcetics:intra-links-std-thread, r=jyn514
Move to intra doc links for std::thread documentation

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

r? @jyn514
2020-08-21 17:55:15 +09:00
Yuki Okushi
f2d25538d4
Rollup merge of #75324 - ericseppanen:master, r=JohnTitor
clarify documentation of remove_dir errors

remove_dir will error if the path doesn't exist or isn't a directory.

It's useful to clarify that this is "remove dir or fail" not "remove dir
if it exists".

I don't think this belongs in the title. "Removes an existing, empty
directory" is strangely worded-- there's no such thing as a non-existing
directory.  Better to just say explicitly it will return an error.
2020-08-21 17:55:08 +09:00
Alexis Bourget
fb3f927131 Move to intra doc links for std::thread documentation 2020-08-20 22:03:00 +02:00
Josh Stone
7ac126ec56
Rollup merge of #75703 - tmiasko:stack-overflow-musl, r=cuviper
Enable stack-overflow detection on musl for non-main threads
2020-08-20 10:07:24 -07:00
Tyler Mandry
ad3db41182
Rollup merge of #75696 - matklad:mirit, r=RalfJung
Remove `#[cfg(miri)]` from OnceCell tests

They were carried over from once_cell crate, but they are not entirely
correct (as miri now supports more things), and we don't run miri
tests for std, so let's just remove them.

Maybe one day we'll run miri in std, but then we can just re-install
these attributes.
2020-08-19 11:12:25 -07:00
Tyler Mandry
0fdc8c06dd
Rollup merge of #75674 - poliorcetics:intra-links-std-io, r=jyn514
Move to intra doc links for std::io

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

r? @jyn514

I had no problems with those files so I added some small links here and there.
2020-08-19 11:12:23 -07:00
Tyler Mandry
4123237fa1
Rollup merge of #75648 - matklad:lazy-dropck, r=KodrAus
Make OnceCell<T> transparent to dropck

See the failed build in

https://github.com/rust-lang/rust/pull/75555#issuecomment-675016718

for an example where we need this in real life

r? @ghost
2020-08-19 11:12:20 -07:00
Alexis Bourget
dad8e11e9f Fix nits in intra-doc links for std io 2020-08-19 16:26:17 +02:00
Aleksey Kladov
34e7eac1ca Remove #[cfg(miri)] from OnceCell tests
They were carried over from once_cell crate, but they are not entirely
correct (as miri now supports more things), and we don't run miri
tests for std, so let's just remove them.

Maybe one day we'll run miri in std, but then we can just re-install
these attributes.
2020-08-19 10:28:22 +02:00
Yuki Okushi
07ea340e89
Rollup merge of #75685 - nixphix:docs/unix-ext, r=jyn514
Switch to intra-doc links in /src/sys/unix/ext/*.rs

Partial fix for #75080

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

r? @jyn514

These two links are not resolving to either `crate::fs::File...` or `fs::File...`
```
# unix/ext/fs.rs
   27:    /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read

  130:   /// [`File::write`]: ../../../../std/fs/struct.File.html#method.write
```
2020-08-19 15:54:39 +09:00
Yuki Okushi
9cf390357b
Rollup merge of #75646 - poliorcetics:intra-links-keywords, r=jyn514
Move to intra doc links for keyword documentation

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-19 15:54:32 +09:00
Tim Diekmann
438c40efa1 Allow reallocation to different alignment 2020-08-19 06:46:47 +02:00
Lzu Tao
768509ff84 Minor changes to Ipv4Addr
* Impl IntoInner rather than AsInner for Ipv4Addr
* Add some comments
* Add test to show endiannes of Ipv4Addr display
2020-08-19 03:27:24 +00:00
Prabakaran Kumaresshan
63d2e9b05f resolve comments 2020-08-19 06:19:35 +05:30
Prabakaran Kumaresshan
3e3a2c82f3 Switch to intra-doc links in /src/sys/unix/ext/*.rs 2020-08-19 05:43:55 +05:30
Tomasz Miąsko
6a80b1387f Enable stack-overflow detection on musl for non-main threads 2020-08-19 00:00:00 +00:00
Alexis Bourget
5d49c0e55a Move to intra doc links for std::io 2020-08-18 19:36:52 +02:00
Tim Diekmann
63d241a7b7 Make grow_impl unsafe 2020-08-18 15:22:10 +02:00
Tim Diekmann
66a651244e Add comment, which was removed by accident (again) 2020-08-18 10:00:31 +02:00
Tim Diekmann
a9fe0ca47a Clean up AllocRef implementation and documentation 2020-08-18 09:53:22 +02:00
bors
515c9fa505 Auto merge of #75621 - TimDiekmann:no-fast-realloc, r=Amanieu
Remove fast path in reallocation for same layout sizes

r? @Amanieu

Before merging a perf-run should be done.

Closes https://github.com/rust-lang/wg-allocators/issues/70
2020-08-18 05:42:05 +00:00
Yuki Okushi
732bebd854
Rollup merge of #75629 - EllenNyan:ellen-intra-doc-links, r=jyn514
Use intra-doc links in `std::env`, `std::alloc` and `std::error`

This is partial fixes for #75080.
2020-08-18 09:27:51 +09:00
Yuki Okushi
d18719bbaf
Rollup merge of #75464 - poliorcetics:intra-links-panic-and-ascii, r=jyn514
Move to intra doc links for ascii.rs and panic.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

I also updated the doc to fix the wording in `AsciiExt` since it is now deprecated.
The two file are small changes so I bundled them together.

Some links could not be changed to make them work, I believe those are known issues with primitive types.
2020-08-18 09:27:43 +09:00
Aleksey Kladov
695d86f584 Make OnceCell<T> transparent to dropck
See the failed build in

https://github.com/rust-lang/rust/pull/75555#issuecomment-675016718

for an example where we need this in real life
2020-08-18 00:34:54 +02:00
Alexis Bourget
431a465a8f Move to intra doc links for keyword documentation 2020-08-17 22:17:14 +02:00
Ellen
e7a7279750 Remove unnecessary links in env.rs 2020-08-17 15:16:09 +01:00
Ellen
a2dfc3ec78 Switch to intra-doc links for std/src/alloc.rs 2020-08-17 14:42:40 +01:00
Ellen
b6d2868caa Switch to intra-doc links for std/src/env.rs 2020-08-17 14:42:23 +01:00
Ellen
509cad7f2f Switch to intra-doc links for std/src/error.rs 2020-08-17 14:42:16 +01:00
Tim Diekmann
c48f784418 Fix typo in comment 2020-08-17 15:05:19 +02:00
Tim Diekmann
c619b36975 Remove fast path in reallocation for same layout sizes 2020-08-17 13:23:38 +02:00
bors
94d7660d59 Auto merge of #75468 - poliorcetics:intra-links-fs, r=jyn514
Move to intra doc links in std/src/fs.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-17 06:02:16 +00:00
Prabakaran Kumaresshan
0a96e089ba Switch to intra-doc links in /sys/windows/ext/{ffi,fs,process}.rs 2020-08-16 22:28:45 +05:30
bors
7a4fb355c6 Auto merge of #75567 - poliorcetics:intra-links-std-net, r=jyn514
Move to intra doc links in std::net

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

The links for `true` and `false` had to stay else `rustdoc` complained, it is intended ?
2020-08-16 13:15:52 +00:00