Commit Graph

6135 Commits

Author SHA1 Message Date
Joseph T Lyons
440cffd551 Use BTreeMap::from() instead of using BTreeMap::new() with BTreeMap::insert() 2021-12-02 12:27:23 -05:00
Joseph T Lyons
80a308df32 Use HashMap::from() instead of using HashMap::new() with HashMap::insert() 2021-12-02 12:26:47 -05:00
Martin Habovstiak
41e21aa1c2 Implement write() method for Box<MaybeUninit<T>>
This adds method similar to `MaybeUninit::write` main difference being
it returns owned `Box`. This can be used to elide copy from stack
safely, however it's not currently tested that the optimization actually
occurs.

Analogous methods are not provided for `Rc` and `Arc` as those need to
handle the possibility of sharing. Some version of them may be added in
the future.

This was discussed in #63291 which this change extends.
2021-12-02 17:18:34 +01:00
Matthias Krüger
d96ce3ea8e
Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump stage0 compiler

r? `@pietroalbini` (or anyone else)
2021-12-02 15:52:03 +01:00
Chris Denton
7a145250c6
Document Windows TLS drop behaviour 2021-12-02 14:17:58 +00:00
Ralf Jung
b11d88006c disable tests in Miri that take too long 2021-12-01 22:48:59 -05:00
Matthias Krüger
9f1f42897d
Rollup merge of #88502 - ibraheemdev:slice-take, r=dtolnay
Add slice take methods

Revival of #62282

This PR adds the following slice methods:

- `take`
- `take_mut`
- `take_first`
- `take_first_mut`
- `take_last`
- `take_last_mut`

r? `@LukasKalbertodt`
2021-12-01 20:57:42 +01:00
Matthias Krüger
ce197e2bce
Rollup merge of #91346 - ibraheemdev:result-inspect, r=dtolnay
Add `Option::inspect` and `Result::{inspect, inspect_err}`

```rust
// core::result

impl Result<T, E> {
    pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self;
    pub fn inspect_err<F: FnOnce(&E)>(self, f: F) -> Self;
}

// core::option

impl Option<T> {
    pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self;
}
```
2021-12-01 10:50:22 +01:00
Matthias Krüger
bc929f9404
Rollup merge of #91340 - cr1901:no-atomic, r=Mark-Simulacrum
Bump compiler_builtins to 0.1.55 to bring in fixes for targets lackin…

…g atomic support.

This fixes a "Cannot select" LLVM error when compiling `compiler_builtins` for targets lacking atomics, like MSP430. Se https://github.com/rust-lang/compiler-builtins/issues/441 for more info. This PR is a more general version of #91248.
2021-11-30 23:43:31 +01:00
Mark Rousskov
b221c877e8 Apply cfg-bootstrap switch 2021-11-30 10:51:42 -05:00
bors
207c80f105 Auto merge of #91352 - nnethercote:RawVec-reserve_for_push, r=dtolnay
Introduce `RawVec::reserve_for_push`.

If `Vec::push`'s capacity check fails it calls `RawVec::reserve`, which
then also does a capacity check.

This commit introduces `reserve_for_push` which skips the redundant
capacity check, for some slight compile time speed-ups.

I tried lots of minor variations on this, e.g. different inlining
attributes. This was the best one I could find.

r? `@ghost`
2021-11-30 13:52:38 +00:00
Yuki Okushi
28176a4a33
Rollup merge of #91383 - ScriptDevil:drop-while-doc-alias, r=joshtriplett
Add `drop_while` as doc alias to `Iterator::skip_while`

`skip_while` is commonly referred to as `drop_while` in other languages (clojure/c++/haskell). This recently came up in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20DropWhile/near/262203352) as well.

This pull request adds 'drop_while' as a doc-alias for 'skip_while'.

r? `@joshtriplett`
2021-11-30 17:29:13 +09:00
Yuki Okushi
a940c68035
Rollup merge of #91323 - RalfJung:assert-type, r=oli-obk
CTFE: support assert_zero_valid and assert_uninit_valid

This ensures the implementation of all three type-based assert_ intrinsics remains consistent in Miri.

`assert_inhabited` recently got stabilized in https://github.com/rust-lang/rust/pull/90896 (meaning stable `const fn` can call it), so do the same with these other intrinsics.

Cc ```@rust-lang/wg-const-eval```
2021-11-30 17:29:09 +09:00
Ashok Gautham Jadatharan
dea3494b31 Add drop_while as doc alias to Iterator::skip_while 2021-11-30 10:27:16 +05:30
Amanieu d'Antras
41e2a53c00 Android: -ldl must appear after -lgcc when linking 2021-11-30 02:42:35 +00:00
Cédric Barreteau
29f5c98a17 Remove unnecessary check in VecDeque::grow
All callers already check that the buffer is full before calling
`grow()`. This is where it makes the most sense, since `grow()` is
`inline(never)` and we don't want to pay for a function call just for
that check.
It could also be argued that it would be correct to call `grow()` even
if the buffer wasn't full yet.
This change breaks no code since `grow()` is not `pub`.
2021-11-29 21:14:20 -05:00
bors
94bec90702 Auto merge of #91244 - dtolnay:lossy, r=Mark-Simulacrum
Eliminate bunch of copies of error codepath from Utf8LossyChunksIter

Using a macro to stamp out 7 identical copies of the nontrivial slicing logic to exit this loop didn't seem like a necessary use of a macro. The early return case can be handled by `break` without practically any changes to the logic inside the loop.

All this code is from early 2014 (#12062&mdash;nearly 8 years ago; pre-1.0) so it's possible there were compiler limitations that forced the macro way at the time.

Confirmed that `x.py bench library/alloc --stage 0 --test-args from_utf8_lossy` is unaffected on my machine.
2021-11-30 01:08:56 +00:00
Nicholas Nethercote
6a83352aa3 Introduce RawVec::reserve_for_push.
If `Vec::push`'s capacity check fails it calls `RawVec::reserve`, which
then also does a capacity check.

This commit introduces `reserve_for_push` which skips the redundant
capacity check, for some slight compile time speed-ups.

I tried lots of minor variations on this, e.g. different inlining
attributes. This was the best one I could find.
2021-11-30 08:10:47 +11:00
Ralf Jung
6c3c3e0952 CTFE: support assert_zero_valid and assert_uninit_valid 2021-11-29 11:49:31 -05:00
Alex Crichton
a0c959750a std: Stabilize the thread_local_const_init feature
This commit is intended to follow the stabilization disposition of the
FCP that has now finished in #84223. This stabilizes the ability to flag
thread local initializers as `const` expressions which enables the macro
to generate more efficient code for accessing it, notably removing
runtime checks for initialization.

More information can also be found in #84223 as well as the tests where
the feature usage was removed in this PR.

Closes #84223
2021-11-29 07:23:46 -08:00
Matthias Krüger
80277dcc4f
Rollup merge of #91049 - dimo414:patch-1, r=kennytm
Add a caveat to std::os::windows::fs::symlink_file

This is similar to the note on [Python's `os.symlink()`](https://docs.python.org/3/library/os.html#os.symlink). Some additional notes in https://github.com/dimo414/bkt/issues/3.
2021-11-29 10:41:33 +01:00
Ibraheem Ahmed
2e8358e1ab add Option::inspect and Result::{inspect, inspect_err} 2021-11-28 23:31:45 -05:00
William D. Jones
e500eb6950 Bump compiler_builtins to 0.1.55 to bring in fixes for targets lacking atomic support. 2021-11-28 23:01:03 -05:00
bors
350158dd6d Auto merge of #90681 - workingjubilee:update-libc, r=JohnTitor
Update libc to 0.2.108

Changelog:
https://github.com/rust-lang/libc/releases/tag/0.2.107
https://github.com/rust-lang/libc/releases/tag/0.2.108
Primarily intended to pull in rust-lang/libc@fd331f65f2
This should help with https://github.com/rust-lang/rust/pull/90044
2021-11-28 22:29:57 +00:00
Ralf Jung
85558ad5b3 adjust some const_eval_select safety comments 2021-11-28 14:00:58 -05:00
Ralf Jung
15a4ed6937 adjust const_eval_select documentation 2021-11-28 13:54:56 -05:00
Matthias Krüger
af0cf34787
Rollup merge of #90896 - jhpratt:stabilize_const_maybe_uninit, r=oli-obk
Stabilize some `MaybeUninit` behavior as const

This stabilizes the `MaybeUninit::as_ptr`, `MaybeUninit::assume_init`, and `MaybeUninit::assume_init_ref` as `const fn`. `MaybeUninit::as_mut_ptr` has been moved to a new flag: `const_maybe_uninit_as_mut_ptr`, which is blocked on #57349. `MaybeUninit::slice_assume_init_ref` can be `const fn` when the method is stabilized in general.

The relevant intrinsic has been stabilized as `const` as well, though this isn't user-visible. Due to the seemingly unrelated feature name I performed `rg const_assert_type` and found no other instances of it being used.

r? `@oli-obk`

`@rustbot` label: +A-const-fn +S-waiting-on-review +T-libs-api
2021-11-28 10:42:38 +01:00
Jacob Pratt
44b5b838d2
Add test for const MaybeUninit 2021-11-28 01:31:25 -05:00
Jacob Pratt
ad8e6bf5cc
Stabilize some MaybeUninit behavior as const 2021-11-28 01:01:47 -05:00
bors
27d5935df1 Auto merge of #91301 - scottmcm:stabilize-nonzero-ipot, r=nagisa
Stabilize nonzero_is_power_of_two

Closes #81106
FCP has finished in the tracking issue
2021-11-28 05:55:09 +00:00
Jubilee Young
9a04ae4997 Update libc to 0.2.108
Changelog:
https://github.com/rust-lang/libc/releases/tag/0.2.107
https://github.com/rust-lang/libc/releases/tag/0.2.108
Primarily intended to pull in fd331f65f214ea75b6210b415b5fd8650be15c73
This should help with https://github.com/rust-lang/rust/pull/90044
2021-11-27 16:13:04 -08:00
bors
4919988fe1 Auto merge of #91241 - dtolnay:firstchunk, r=oli-obk
Eliminate an unreachable codepath from String::from_utf8_lossy

`Utf8Lossy`'s `Iterator` implementation ensures that only the **final** chunk has an empty slice for `broken`:

dd549dcab4/library/core/src/str/lossy.rs (L46-L47)

Thus the only way the **first** chunk could have an empty `broken` is if it is the **final** chunk, i.e. there is only one chunk total. And the only way that there could be one chunk total with an empty `broken` is if the whole input is valid utf8 and non-empty.

That condition has already been handled by an early return, so at the point that the first `REPLACEMENT` is being pushed, it's impossible for `first_broken` to be empty.
2021-11-27 22:53:21 +00:00
Scott McMurray
23045eb622 Stabilize nonzero_is_power_of_two
Fixes 81106
FCP has finished in the tracking issue
2021-11-27 13:13:04 -08:00
bors
686e313a9a Auto merge of #91288 - matthiaskrgr:rollup-yp5h41r, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #83791 (Weaken guarantee around advancing underlying iterators in zip)
 - #90995 (Document non-guarantees for Hash)
 - #91057 (Expand `available_parallelism` docs in anticipation of cgroup quota support)
 - #91062 (rustdoc: Consolidate static-file replacement mechanism)
 - #91208 (Account for incorrect `where T::Assoc = Ty` bound)
 - #91266 (Use non-generic inner function for pointer formatting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-27 14:29:12 +00:00
bors
5fd3a5c7c1 Auto merge of #89916 - the8472:advance_by-avoid-err-0, r=dtolnay
Fix Iterator::advance_by contract inconsistency

The `advance_by(n)` docs state that in the error case `Err(k)` that k is always less than n.
It also states that `advance_by(0)` may return `Err(0)` to indicate an exhausted iterator.
These statements are inconsistent.
Since only one implementation (Skip) actually made use of that I changed it to return Ok(()) in that case too.

While adding some tests I also found a bug in `Take::advance_back_by`.
2021-11-27 11:31:26 +00:00
Matthias Krüger
073b1208f0
Rollup merge of #91266 - jam1garner:fmt-ptr-fix, r=dtolnay
Use non-generic inner function for pointer formatting

Previously, despite the implementation being type-unaware, `fmt::Pointer`'s implementation for `*const T` in monomorphized. This affects:

* `fmt::Debug` for `*const T`
* `fmt::Debug` for `*mut T`
* `fmt::Pointer` for `*const T`
* `fmt::Pointer` for `*mut T`

And since the implementation is non-trivial, this results in a large amount of LLVM bitcode being generated. For example, with a large bindgen project with Debug implementations enabled, it will generate a lot of calls to `fmt::Debug for *const T`, which in turn will perform codegen for a copy of this function for every type.

For example, in a real-world bindgen'd header I've been testing with (4,189,245 lines of bindgen Rust with layout tests disabled) the difference between a slightly old nightly (`rustc 1.58.0-nightly (e249ce6b2 2021-10-30)`) and this PR:

<details>
<summary>Nightly (Click to Expand)</summary>

```
  Lines           Copies         Function name
  -----           ------         -------------
  7256000 (100%)  216544 (100%)  (TOTAL)
  1815449 (25.0%)  24206 (11.2%) <*const T as core::fmt::Pointer>::fmt
   300248 (4.1%)   29579 (13.7%) <&T as core::fmt::Debug>::fmt
   290328 (4.0%)   24194 (11.2%) <*mut T as core::fmt::Pointer>::fmt
   217746 (3.0%)   24194 (11.2%) <*mut T as core::fmt::Debug>::fmt
   123329 (1.7%)    1486 (0.7%)  core::fmt::builders::DebugList::entries
    72790 (1.0%)    1486 (0.7%)  core::slice::iter::Iter<T>::post_inc_start
    71313 (1.0%)    1486 (0.7%)  core::slice::iter::Iter<T>::new
    68329 (0.9%)    1486 (0.7%)  <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::next
    38636 (0.5%)    1486 (0.7%)  <[T] as core::fmt::Debug>::fmt
    26874 (0.4%)    1493 (0.7%)  core::array::<impl core::fmt::Debug for [T; N]>::fmt
    22290 (0.3%)    1486 (0.7%)  core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
    19407 (0.3%)    1493 (0.7%)  core::array::<impl core::ops::index::Index<I> for [T; N]>::index
    19318 (0.3%)    1486 (0.7%)  core::slice::<impl [T]>::iter
    17832 (0.2%)    1486 (0.7%)  core::ptr::const_ptr::<impl *const T>::offset
    17832 (0.2%)    1486 (0.7%)  core::ptr::mut_ptr::<impl *mut T>::offset
    16346 (0.2%)    1486 (0.7%)  <core::ops::range::RangeFull as core::slice::index::SliceIndex<[T]>>::index
    13374 (0.2%)    1486 (0.7%)  <I as core::iter::traits::collect::IntoIterator>::into_iter
    13374 (0.2%)    1486 (0.7%)  core::ptr::const_ptr::<impl *const T>::add
    13371 (0.2%)    1486 (0.7%)  core::ptr::const_ptr::<impl *const T>::is_null
    13371 (0.2%)    1486 (0.7%)  core::ptr::mut_ptr::<impl *mut T>::is_null
    11888 (0.2%)    1486 (0.7%)  core::slice::<impl [T]>::as_ptr
    11879 (0.2%)    1486 (0.7%)  core::ptr::non_null::NonNull<T>::new_unchecked
     7421 (0.1%)    1486 (0.7%)  core::ptr::non_null::NonNull<T>::as_ptr

```

</details>

<details>
<summary>This PR (Click to Expand)</summary>

```
   Lines           Copies         Function name
  -----           ------         -------------
  5684504 (100%)  216542 (100%)  (TOTAL)
   300248 (5.3%)   29579 (13.7%) <&T as core::fmt::Debug>::fmt
   290328 (5.1%)   24194 (11.2%) <*mut T as core::fmt::Pointer>::fmt
   266265 (4.7%)   24206 (11.2%) <*const T as core::fmt::Pointer>::fmt
   217746 (3.8%)   24194 (11.2%) <*mut T as core::fmt::Debug>::fmt
   101039 (1.8%)    1486 (0.7%)  core::fmt::builders::DebugList::entries
    72790 (1.3%)    1486 (0.7%)  core::slice::iter::Iter<T>::post_inc_start
    71313 (1.3%)    1486 (0.7%)  core::slice::iter::Iter<T>::new
    68329 (1.2%)    1486 (0.7%)  <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::next
    38636 (0.7%)    1486 (0.7%)  <[T] as core::fmt::Debug>::fmt
    26874 (0.5%)    1493 (0.7%)  core::array::<impl core::fmt::Debug for [T; N]>::fmt
    22290 (0.4%)    1486 (0.7%)  core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
    19407 (0.3%)    1493 (0.7%)  core::array::<impl core::ops::index::Index<I> for [T; N]>::index
    19318 (0.3%)    1486 (0.7%)  core::slice::<impl [T]>::iter
    17832 (0.3%)    1486 (0.7%)  core::ptr::const_ptr::<impl *const T>::offset
    17832 (0.3%)    1486 (0.7%)  core::ptr::mut_ptr::<impl *mut T>::offset
    16346 (0.3%)    1486 (0.7%)  <core::ops::range::RangeFull as core::slice::index::SliceIndex<[T]>>::index
    13374 (0.2%)    1486 (0.7%)  <I as core::iter::traits::collect::IntoIterator>::into_iter
    13374 (0.2%)    1486 (0.7%)  core::ptr::const_ptr::<impl *const T>::add
    13371 (0.2%)    1486 (0.7%)  core::ptr::const_ptr::<impl *const T>::is_null
    13371 (0.2%)    1486 (0.7%)  core::ptr::mut_ptr::<impl *mut T>::is_null
    11888 (0.2%)    1486 (0.7%)  core::slice::<impl [T]>::as_ptr
    11879 (0.2%)    1486 (0.7%)  core::ptr::non_null::NonNull<T>::new_unchecked
     7421 (0.1%)    1486 (0.7%)  core::ptr::non_null::NonNull<T>::as_ptr

```

</details>

Output generated using `cargo llvm-lines` version 0.4.12.

Summary of differences:

| rustc Version | Total LLVM line count | `*const T as fmt::Pointer` LLVM lines | Compilation Time |
|-|-|-|-|
| `nightly` | 7256000 | 1815449 (25.0% of binary) | 537.014 |
| PR | 5684504 (-21.65%) | 266265 (4.7% of binary) (-85.3% from nightly) | 502.990 |

This results in a pretty noticeable as the majority of rustc's time is spent in either codegen or LLVM, in this case, and is significantly improved by disabling derives for `fmt::Debug`, as it prevents generating all this LLVM IR to be handled.

Here's a run time comparison with nightly on the same codebase (commit 454cc5fb built from source vs 37c8f25 from my PR built from source):

<details>
<summary>nightly (Click to Expand)</summary>

```
time:   2.370; rss:   56MB -> 1118MB (+1062MB)	parse_crate
time:   0.000; rss: 1118MB -> 1118MB (   +0MB)	attributes_injection
time:   0.000; rss: 1118MB -> 1118MB (   +0MB)	incr_comp_prepare_session_directory
time:   0.000; rss: 1118MB -> 1118MB (   +0MB)	incr_comp_garbage_collect_session_directories
time:   0.000; rss: 1120MB -> 1120MB (   +0MB)	plugin_loading
time:   0.000; rss: 1120MB -> 1120MB (   +0MB)	plugin_registration
time:   0.000; rss: 1120MB -> 1120MB (   +0MB)	crate_injection
time:  13.897; rss: 1120MB -> 3147MB (+2027MB)	expand_crate
time:   0.002; rss: 3147MB -> 3147MB (   +0MB)	check_unused_macros
time:  13.900; rss: 1120MB -> 3147MB (+2027MB)	macro_expand_crate
time:   0.002; rss: 3147MB -> 3147MB (   +0MB)	maybe_building_test_harness
time:   0.503; rss: 3147MB -> 3147MB (   +0MB)	AST_validation
time:   0.000; rss: 3147MB -> 3147MB (   +0MB)	maybe_create_a_macro_crate
time:   0.002; rss: 3147MB -> 3147MB (   +0MB)	finalize_imports
time:   0.502; rss: 3147MB -> 3153MB (   +6MB)	finalize_macro_resolutions
time:   4.478; rss: 3153MB -> 3574MB ( +420MB)	late_resolve_crate
time:   0.000; rss: 3574MB -> 3574MB (   +0MB)	resolve_main
time:   0.332; rss: 3574MB -> 3574MB (   +0MB)	resolve_check_unused
time:   0.000; rss: 3574MB -> 3574MB (   +0MB)	resolve_report_errors
time:   0.279; rss: 3574MB -> 3574MB (   +0MB)	resolve_postprocess
time:   5.595; rss: 3147MB -> 3574MB ( +427MB)	resolve_crate
time:   0.382; rss: 3574MB -> 3574MB (   +0MB)	complete_gated_feature_checking
time:  20.526; rss: 1120MB -> 3574MB (+2454MB)	configure_and_expand
time:   0.000; rss: 3574MB -> 3574MB (   +0MB)	prepare_outputs
time:   0.000; rss: 3574MB -> 3574MB (   +0MB)	blocked_on_dep_graph_loading
time:  65.992; rss: 3574MB -> 6317MB (+2743MB)	hir_lowering
time:   1.117; rss: 6317MB -> 6323MB (   +6MB)	early_lint_checks
time:   1.447; rss: 6323MB -> 6271MB (  -52MB)	drop_ast
time:   0.002; rss: 5838MB -> 5838MB (   +0MB)	setup_global_ctxt
time:   0.000; rss: 5843MB -> 5843MB (   +0MB)	looking_for_entry_point
time:   0.313; rss: 5843MB -> 5844MB (   +1MB)	looking_for_derive_registrar
time:   9.652; rss: 5843MB -> 6065MB ( +222MB)	misc_checking_1
time:   9.713; rss: 6065MB -> 6769MB ( +704MB)	type_collecting
time:   0.665; rss: 6769MB -> 6769MB (   +0MB)	impl_wf_inference
time:   0.064; rss: 6769MB -> 6769MB (   +0MB)	unsafety_checking
time:   3.095; rss: 6769MB -> 6792MB (  +23MB)	coherence_checking
time:  21.282; rss: 6792MB -> 7546MB ( +754MB)	wf_checking
time:   5.404; rss: 7546MB -> 7681MB ( +135MB)	item_types_checking
time:  79.665; rss: 7681MB -> 8075MB ( +394MB)	item_bodies_checking
time: 120.166; rss: 6065MB -> 8081MB (+2016MB)	type_check_crate
time:   2.038; rss: 8081MB -> 8085MB (   +4MB)	match_checking
time:   1.300; rss: 8085MB -> 8113MB (  +28MB)	liveness_and_intrinsic_checking
time:   3.338; rss: 8081MB -> 8113MB (  +32MB)	misc_checking_2
time:  68.612; rss: 8113MB -> 9285MB (+1172MB)	MIR_borrow_checking
time:   0.622; rss: 9285MB -> 9301MB (  +17MB)	MIR_effect_checking
time:   0.000; rss: 9301MB -> 9301MB (   +0MB)	layout_testing
time:   4.331; rss: 9383MB -> 9510MB ( +127MB)	death_checking
time:   0.032; rss: 9510MB -> 9510MB (   +0MB)	unused_lib_feature_checking
time:   4.444; rss: 9510MB -> 9568MB (  +58MB)	crate_lints
time:  59.563; rss: 9568MB -> 9576MB (   +8MB)	module_lints
time:  64.006; rss: 9510MB -> 9576MB (  +66MB)	lint_checking
time:   4.127; rss: 9576MB -> 9639MB (  +62MB)	privacy_checking_modules
time:  77.984; rss: 9301MB -> 9639MB ( +337MB)	misc_checking_3
time:   0.311; rss: 10357MB -> 10357MB (   +0MB)	monomorphization_collector_root_collections
time:  14.051; rss: 10357MB -> 10573MB ( +217MB)	monomorphization_collector_graph_walk
time:   1.759; rss: 10573MB -> 10652MB (  +79MB)	partition_and_assert_distinct_symbols
time:  28.518; rss: 9639MB -> 10711MB (+1072MB)	generate_crate_metadata
time:   0.000; rss: 10711MB -> 10711MB (   +0MB)	find_cgu_reuse
time:  63.408; rss: 10711MB -> 12272MB (+1560MB)	codegen_to_LLVM_IR
time:  64.916; rss: 10711MB -> 12267MB (+1556MB)	codegen_crate
time:   0.000; rss: 12261MB -> 12261MB (   +0MB)	assert_dep_graph
time:   0.000; rss: 12261MB -> 12261MB (   +0MB)	check_dirty_clean
time:   0.664; rss: 12230MB -> 12210MB (  -20MB)	encode_query_results_for(rustc_query_impl::queries::type_of)
time:   2.111; rss: 12210MB -> 12043MB ( -167MB)	encode_query_results_for(rustc_query_impl::queries::generics_of)
time:   0.108; rss: 12043MB -> 12057MB (  +14MB)	encode_query_results_for(rustc_query_impl::queries::predicates_of)
time:   0.004; rss: 12057MB -> 12059MB (   +2MB)	encode_query_results_for(rustc_query_impl::queries::mir_const_qualif)
time:   0.665; rss: 12059MB -> 12121MB (  +62MB)	encode_query_results_for(rustc_query_impl::queries::mir_for_ctfe)
time:  16.149; rss: 12121MB -> 12148MB (  +28MB)	encode_query_results_for(rustc_query_impl::queries::optimized_mir)
time:   0.000; rss: 12148MB -> 12148MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::covered_file_name)
time:   0.000; rss: 12148MB -> 12148MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::covered_code_regions)
time:   0.010; rss: 12148MB -> 12150MB (   +2MB)	encode_query_results_for(rustc_query_impl::queries::promoted_mir)
time:   0.052; rss: 12150MB -> 12155MB (   +4MB)	encode_query_results_for(rustc_query_impl::queries::unsafety_check_result)
time:   0.003; rss: 12155MB -> 12156MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::thir_check_unsafety)
time:  11.428; rss: 12156MB -> 11748MB ( -408MB)	encode_query_results_for(rustc_query_impl::queries::typeck)
time:   0.000; rss: 11748MB -> 11748MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::diagnostic_only_typeck)
time:   0.094; rss: 11748MB -> 11756MB (   +8MB)	encode_query_results_for(rustc_query_impl::queries::used_trait_imports)
time:   0.272; rss: 11756MB -> 11778MB (  +22MB)	encode_query_results_for(rustc_query_impl::queries::mir_borrowck)
time:   0.054; rss: 11778MB -> 11778MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::eval_to_allocation_raw)
time:   0.005; rss: 11778MB -> 11779MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::eval_to_const_value_raw)
time:   0.021; rss: 11779MB -> 11784MB (   +5MB)	encode_query_results_for(rustc_query_impl::queries::check_match)
time:   0.041; rss: 11784MB -> 11786MB (   +2MB)	encode_query_results_for(rustc_query_impl::queries::symbol_name)
time:   0.743; rss: 11786MB -> 11815MB (  +29MB)	encode_query_results_for(rustc_query_impl::queries::codegen_fn_attrs)
time:   0.043; rss: 11815MB -> 11816MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::codegen_fulfill_obligation)
time:   0.674; rss: 11816MB -> 11840MB (  +25MB)	encode_query_results_for(rustc_query_impl::queries::specialization_graph_of)
time:   0.000; rss: 11840MB -> 11840MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::adt_drop_tys)
time:   0.000; rss: 11840MB -> 11840MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::adt_significant_drop_tys)
time:   0.005; rss: 11840MB -> 11841MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::unused_generic_params)
time:  33.153; rss: 12232MB -> 11841MB ( -390MB)	encode_query_results
time:  88.943; rss: 11955MB -> 11783MB ( -173MB)	LLVM_passes(crate)
time:  38.854; rss: 12259MB -> 10095MB (-2164MB)	incr_comp_serialize_result_cache
time:  39.030; rss: 12261MB -> 10095MB (-2166MB)	incr_comp_persist_result_cache
time:   0.000; rss: 10095MB -> 10095MB (   +0MB)	incr_comp_persist_dep_graph
time:  39.064; rss: 12257MB -> 10095MB (-2162MB)	serialize_dep_graph
time:  19.047; rss: 10095MB -> 10307MB ( +212MB)	free_global_ctxt
time:   0.000; rss: 10307MB -> 10307MB (   +0MB)	join_worker_thread
time:   0.519; rss: 10307MB -> 10307MB (   +0MB)	copy_all_cgu_workproducts_to_incr_comp_cache_dir
time:   0.522; rss: 10307MB -> 10307MB (   +0MB)	finish_ongoing_codegen
time:   0.000; rss: 10307MB -> 10307MB (   +0MB)	llvm_dump_timing_file
time:   0.002; rss: 10307MB -> 10307MB (   +0MB)	serialize_work_products
time:   0.001; rss: 9542MB -> 9542MB (   +0MB)	incr_comp_finalize_session_directory
time:   0.000; rss: 9542MB -> 9542MB (   +0MB)	link_binary_check_files_are_writeable
time:   7.835; rss: 9542MB -> 9544MB (   +2MB)	link_rlib
time:   0.000; rss: 9544MB -> 9544MB (   +0MB)	link_binary_remove_temps
time:   7.872; rss: 9542MB -> 9544MB (   +2MB)	link_binary
time:   7.944; rss: 9542MB -> 9201MB ( -341MB)	link_crate
time:   8.495; rss: 10307MB -> 9201MB (-1106MB)	link
time: 537.014; rss:   33MB -> 3715MB (+3682MB)	total
```

</details>

<details>
<summary>This PR (Click to Expand)</summary>

```
time:   2.379; rss:   51MB -> 1116MB (+1064MB)	parse_crate
time:   0.003; rss: 1116MB -> 1116MB (   +0MB)	attributes_injection
time:   0.002; rss: 1116MB -> 1116MB (   +0MB)	incr_comp_prepare_session_directory
time:   0.000; rss: 1116MB -> 1116MB (   +0MB)	incr_comp_garbage_collect_session_directories
time:   0.000; rss: 1116MB -> 1116MB (   +0MB)	plugin_loading
time:   0.000; rss: 1116MB -> 1116MB (   +0MB)	plugin_registration
time:   0.003; rss: 1118MB -> 1118MB (   +0MB)	crate_injection
time:  13.376; rss: 1118MB -> 3143MB (+2025MB)	expand_crate
time:   0.002; rss: 3143MB -> 3143MB (   +0MB)	check_unused_macros
time:  13.379; rss: 1118MB -> 3143MB (+2025MB)	macro_expand_crate
time:   0.002; rss: 3143MB -> 3143MB (   +0MB)	maybe_building_test_harness
time:   0.479; rss: 3143MB -> 3143MB (   +0MB)	AST_validation
time:   0.002; rss: 3143MB -> 3143MB (   +0MB)	maybe_create_a_macro_crate
time:   0.005; rss: 3143MB -> 3143MB (   +0MB)	finalize_imports
time:   0.520; rss: 3143MB -> 3125MB (  -18MB)	finalize_macro_resolutions
time:   4.446; rss: 3125MB -> 3577MB ( +453MB)	late_resolve_crate
time:   0.000; rss: 3577MB -> 3577MB (   +0MB)	resolve_main
time:   0.336; rss: 3577MB -> 3577MB (   +0MB)	resolve_check_unused
time:   0.000; rss: 3577MB -> 3577MB (   +0MB)	resolve_report_errors
time:   0.295; rss: 3577MB -> 3578MB (   +0MB)	resolve_postprocess
time:   5.602; rss: 3143MB -> 3578MB ( +435MB)	resolve_crate
time:   0.388; rss: 3578MB -> 3578MB (   +0MB)	complete_gated_feature_checking
time:  20.014; rss: 1116MB -> 3578MB (+2462MB)	configure_and_expand
time:   0.000; rss: 3578MB -> 3578MB (   +0MB)	prepare_outputs
time:   0.000; rss: 3578MB -> 3578MB (   +0MB)	blocked_on_dep_graph_loading
time:  64.219; rss: 3578MB -> 6313MB (+2736MB)	hir_lowering
time:   1.102; rss: 6313MB -> 6319MB (   +6MB)	early_lint_checks
time:   1.426; rss: 6319MB -> 6268MB (  -52MB)	drop_ast
time:   0.005; rss: 5834MB -> 5836MB (   +2MB)	setup_global_ctxt
time:   0.000; rss: 5838MB -> 5838MB (   +0MB)	looking_for_entry_point
time:   0.292; rss: 5838MB -> 5840MB (   +1MB)	looking_for_derive_registrar
time:   9.553; rss: 5838MB -> 6060MB ( +222MB)	misc_checking_1
time:   9.949; rss: 6060MB -> 6764MB ( +704MB)	type_collecting
time:   0.630; rss: 6764MB -> 6764MB (   +0MB)	impl_wf_inference
time:   0.060; rss: 6764MB -> 6764MB (   +0MB)	unsafety_checking
time:   3.054; rss: 6764MB -> 6787MB (  +23MB)	coherence_checking
time:  20.702; rss: 6787MB -> 7533MB ( +746MB)	wf_checking
time:   5.194; rss: 7533MB -> 7668MB ( +135MB)	item_types_checking
time:  74.677; rss: 7668MB -> 8062MB ( +394MB)	item_bodies_checking
time: 114.497; rss: 6060MB -> 8068MB (+2008MB)	type_check_crate
time:   1.891; rss: 8068MB -> 8072MB (   +4MB)	match_checking
time:   1.292; rss: 8072MB -> 8100MB (  +28MB)	liveness_and_intrinsic_checking
time:   3.183; rss: 8068MB -> 8100MB (  +32MB)	misc_checking_2
time:  68.845; rss: 8100MB -> 9279MB (+1179MB)	MIR_borrow_checking
time:   0.587; rss: 9279MB -> 9295MB (  +17MB)	MIR_effect_checking
time:   0.000; rss: 9295MB -> 9295MB (   +0MB)	layout_testing
time:   4.443; rss: 9377MB -> 9504MB ( +127MB)	death_checking
time:   0.034; rss: 9504MB -> 9504MB (   +0MB)	unused_lib_feature_checking
time:   4.409; rss: 9504MB -> 9562MB (  +58MB)	crate_lints
time:  56.490; rss: 9562MB -> 9571MB (   +8MB)	module_lints
time:  60.900; rss: 9504MB -> 9571MB (  +66MB)	lint_checking
time:   4.147; rss: 9571MB -> 9633MB (  +62MB)	privacy_checking_modules
time:  75.094; rss: 9295MB -> 9633MB ( +337MB)	misc_checking_3
time:   0.315; rss: 10357MB -> 10357MB (   +0MB)	monomorphization_collector_root_collections
time:  14.501; rss: 10357MB -> 10571MB ( +215MB)	monomorphization_collector_graph_walk
time:   1.763; rss: 10571MB -> 10661MB (  +89MB)	partition_and_assert_distinct_symbols
time:  29.035; rss: 9633MB -> 10706MB (+1073MB)	generate_crate_metadata
time:   0.000; rss: 10706MB -> 10706MB (   +0MB)	find_cgu_reuse
time:  30.913; rss: 10706MB -> 12150MB (+1444MB)	codegen_to_LLVM_IR
time:  31.108; rss: 10706MB -> 12150MB (+1444MB)	codegen_crate
time:   0.000; rss: 12150MB -> 12150MB (   +0MB)	assert_dep_graph
time:   0.000; rss: 12150MB -> 12150MB (   +0MB)	check_dirty_clean
time:   0.416; rss: 12152MB -> 12199MB (  +46MB)	encode_query_results_for(rustc_query_impl::queries::type_of)
time:   1.259; rss: 12199MB -> 12211MB (  +12MB)	encode_query_results_for(rustc_query_impl::queries::generics_of)
time:   0.095; rss: 12211MB -> 12193MB (  -18MB)	encode_query_results_for(rustc_query_impl::queries::predicates_of)
time:   0.005; rss: 12193MB -> 12195MB (   +2MB)	encode_query_results_for(rustc_query_impl::queries::mir_const_qualif)
time:   0.828; rss: 12195MB -> 12208MB (  +14MB)	encode_query_results_for(rustc_query_impl::queries::mir_for_ctfe)
time:  17.880; rss: 12208MB -> 11987MB ( -222MB)	encode_query_results_for(rustc_query_impl::queries::optimized_mir)
time:   0.000; rss: 11987MB -> 11987MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::covered_file_name)
time:   0.000; rss: 11987MB -> 11987MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::covered_code_regions)
time:   0.007; rss: 11987MB -> 11988MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::promoted_mir)
time:   0.049; rss: 11988MB -> 11992MB (   +4MB)	encode_query_results_for(rustc_query_impl::queries::unsafety_check_result)
time:   0.002; rss: 11992MB -> 11994MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::thir_check_unsafety)
time:  38.049; rss: 11994MB -> 12093MB (  +99MB)	encode_query_results_for(rustc_query_impl::queries::typeck)
time:   0.000; rss: 12093MB -> 12093MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::diagnostic_only_typeck)
time:   0.024; rss: 12093MB -> 12095MB (   +2MB)	encode_query_results_for(rustc_query_impl::queries::used_trait_imports)
time:   0.372; rss: 12095MB -> 12053MB (  -42MB)	encode_query_results_for(rustc_query_impl::queries::mir_borrowck)
time:   0.015; rss: 12053MB -> 12053MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::eval_to_allocation_raw)
time:   0.005; rss: 12053MB -> 12054MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::eval_to_const_value_raw)
time:   0.003; rss: 12054MB -> 12056MB (   +2MB)	encode_query_results_for(rustc_query_impl::queries::check_match)
time:   0.037; rss: 12056MB -> 11899MB ( -157MB)	encode_query_results_for(rustc_query_impl::queries::symbol_name)
time:   0.667; rss: 11899MB -> 11708MB ( -191MB)	encode_query_results_for(rustc_query_impl::queries::codegen_fn_attrs)
time:   0.045; rss: 11708MB -> 11709MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::codegen_fulfill_obligation)
time:   0.295; rss: 11709MB -> 11734MB (  +25MB)	encode_query_results_for(rustc_query_impl::queries::specialization_graph_of)
time:   0.000; rss: 11734MB -> 11734MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::adt_drop_tys)
time:   0.000; rss: 11734MB -> 11734MB (   +0MB)	encode_query_results_for(rustc_query_impl::queries::adt_significant_drop_tys)
time:   0.005; rss: 11734MB -> 11734MB (   +1MB)	encode_query_results_for(rustc_query_impl::queries::unused_generic_params)
time:  60.063; rss: 12152MB -> 11734MB ( -418MB)	encode_query_results
time:  76.745; rss: 12007MB -> 11699MB ( -308MB)	LLVM_passes(crate)
time:  61.634; rss: 12150MB -> 10557MB (-1593MB)	incr_comp_serialize_result_cache
time:  61.637; rss: 12150MB -> 10557MB (-1593MB)	incr_comp_persist_result_cache
time:   0.001; rss: 10557MB -> 10557MB (   +0MB)	incr_comp_persist_dep_graph
time:  61.641; rss: 12150MB -> 10557MB (-1593MB)	serialize_dep_graph
time:  15.601; rss: 10557MB -> 10242MB ( -315MB)	free_global_ctxt
time:   0.000; rss: 10242MB -> 10242MB (   +0MB)	join_worker_thread
time:   0.368; rss: 10242MB -> 10242MB (   +0MB)	copy_all_cgu_workproducts_to_incr_comp_cache_dir
time:   0.375; rss: 10242MB -> 10242MB (   +0MB)	finish_ongoing_codegen
time:   0.000; rss: 10242MB -> 10242MB (   +0MB)	llvm_dump_timing_file
time:   0.002; rss: 10242MB -> 10242MB (   +0MB)	serialize_work_products
time:   0.001; rss: 9668MB -> 9668MB (   +0MB)	incr_comp_finalize_session_directory
time:   0.000; rss: 9668MB -> 9668MB (   +0MB)	link_binary_check_files_are_writeable
time:   1.469; rss: 9668MB -> 9671MB (   +3MB)	link_rlib
time:   0.000; rss: 9671MB -> 9671MB (   +0MB)	link_binary_remove_temps
time:   1.506; rss: 9668MB -> 9671MB (   +3MB)	link_binary
time:   1.622; rss: 9668MB -> 9329MB ( -339MB)	link_crate
time:   2.037; rss: 10242MB -> 9329MB ( -913MB)	link
time: 502.990; rss:   32MB -> 5888MB (+5855MB)	total
```

</details>

(6.34% decrease in runtime, results are consistent across multiple runs)
2021-11-27 11:46:45 +01:00
Matthias Krüger
8fb58e5ece
Rollup merge of #91057 - the8472:clarify-parallelism-steady-state, r=dtolnay
Expand `available_parallelism` docs in anticipation of cgroup quota support

The "fixed" in "fixed steady state limits" means to exclude load-dependent resource prioritization
that would calculate to 100% of capacity on an idle system and less capacity on a loaded system.

Additionally I also exclude "system load" since it would be silly to try to identify
other, perhaps higher priority, processes hogging some CPU cores that aren't explicitly excluded
by masks/quotas/whatever.
2021-11-27 11:46:42 +01:00
Matthias Krüger
43279b2749
Rollup merge of #90995 - the8472:hash-portability, r=dtolnay
Document non-guarantees for Hash

Dependence on endianness and type sizes was reported for enum discriminants in #74215 but it is a more general
issue since for example the default implementation of `Hasher::write_usize` uses native endianness.
Additionally the implementations of library types are occasionally changed as their internal fields
change or hashing gets optimized.

## Question

Should this go on the module level documentation instead since it also concerns `Hasher` to some extent and not just `Hash`?

resolves #74215
2021-11-27 11:46:42 +01:00
Matthias Krüger
14ef447d12
Rollup merge of #83791 - the8472:relax-zip-side-effect-guarantee, r=dtolnay
Weaken guarantee around advancing underlying iterators in zip

The current guarantee (introduced in #52279) is too strong as it prevents adapters from exploiting knowledge about the iterator length and using counted loops for example because they would stop calling `next()` before it ever returned `None`. Additionally several nested zip iterators already fail to uphold this.

This does not yet remove any of the specialization code that tries (and sometimes fails) to uphold the guarantee for `next()`
because removing it would also affect `next_back()` in more surprising ways.

The intent is to be able to remove for example this branch

36bcf40697/library/core/src/iter/adapters/zip.rs (L234-L243)

or this test

36bcf40697/library/core/tests/iter/adapters/zip.rs (L177-L188)

Solves #82303 by declaring it a non-issue.
2021-11-27 11:46:40 +01:00
bors
0881b3abe4 Auto merge of #90846 - cuviper:weak, r=dtolnay
Refactor weak symbols in std::sys::unix

This makes a few changes to the weak symbol macros in `sys::unix`:

- `dlsym!` is added to keep the functionality for runtime `dlsym`
  lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't
  want to show up in ELF symbol tables.
- `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime
  behavior is just a simple null check. This is also used by `syscall!`.
  - On non-ELF targets (macos/ios) where that linkage is not known to
    behave, `weak!` is just an alias to `dlsym!` for the old behavior.
- `raw_syscall!` is added to always call `libc::syscall` on linux and
  android, for cases like `clone3` that have no known libc wrapper.

The new `weak!` linkage does mean that you'll get versioned symbols if
you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`.
This might seem problematic, but old non-weak symbols can tie the build
to new versions too, like `dlsym@GLIBC_2.34` from their recent library
unification. If you build with an old glibc like `dist-x86_64-linux`
does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may
be resolved based on the runtime glibc.

I also found a few functions that don't need to be weak anymore:

- Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as
  these were added in API 12, and our baseline is API 14.
- Linux can directly use `splice`, added way back in glibc 2.5 and
  similarly old musl. Android only added it in API 21 though.
2021-11-27 07:58:00 +00:00
Tobias Kortkamp
47474f1055
Add riscv64gc-unknown-freebsd 2021-11-27 07:24:18 +01:00
bors
bbad745a68 Auto merge of #91269 - matthiaskrgr:rollup-jh8i8eh, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90611 (Fix another ICE in rustdoc scrape_examples)
 - #91197 (rustdoc: Rename `Type::ResolvedPath` to `Type::Path` and don't re-export it)
 - #91223 (Fix headings indent)
 - #91240 (Saner formatting for UTF8_CHAR_WIDTH table)
 - #91248 (Bump compiler-builtins to 0.1.53)
 - #91252 (Fix bug where submodules wouldn't be updated when running x.py from a subdirectory)
 - #91259 (Remove `--display-doctest-warnings`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-27 00:42:30 +00:00
Matthias Krüger
a92f867bf1
Rollup merge of #91248 - alessandrod:compiler-builtins-bump-bpf, r=Mark-Simulacrum
Bump compiler-builtins to 0.1.53

Fixes a LLVM crash with the bpf targets, see https://github.com/rust-lang/compiler-builtins/pull/440
2021-11-26 22:41:42 +01:00
Matthias Krüger
3bdf5fbbd8
Rollup merge of #91240 - dtolnay:utf8width, r=Mark-Simulacrum
Saner formatting for UTF8_CHAR_WIDTH table

The way these lines were currently wrapped definitely does not look like someone's intentional formatting. It's likely they got disfigured by rustfmt at some point.

This commit rearranges it to a rustfmt-compatible formatting that I find easier to read.
2021-11-26 22:41:41 +01:00
bors
ccce98535b Auto merge of #91246 - nnethercote:faster-layout-array, r=dtolnay
Faster `Layout::array`

`Layout::array` is called (indirectly) by `Vec::push()`, which is typically instantiated many times, and so making it smaller can help with compile times because less LLVM IR is generated.

r? `@ghost`
2021-11-26 21:35:53 +00:00
David Tolnay
c6810a569f
Clarify safety comment on using i to index into self.source 2021-11-26 12:57:36 -08:00
jam1garner
37c8f254ed Use non-generic inner function for pointer formatting 2021-11-26 13:59:57 -05:00
Matthias Krüger
fdc305d58d
Rollup merge of #91176 - hermitcore:spin, r=kennytm
If the thread does not get the lock in the short term, yield the CPU

Reduces on [RustyHermit](https://github.com/hermitcore/rusty-hermit) the amount of wasted processor cycles
2021-11-26 16:02:24 +01:00
Alessandro Decina
1cf37189bc Bump compiler-builtins to 0.1.53
Fixes a LLVM crash with the bpf targets
2021-11-26 10:33:32 +00:00
Nicholas Nethercote
dbfb91385f Add a unit test for zero-sized types in RawVec.
Because there's some subtle behaviour specific to zero-sized types and
it's currently not well tested.
2021-11-26 19:30:45 +11:00
Nicholas Nethercote
f3bda74d36 Optimize Layout::array.
The current implementation is much more conservative than it needs to
be, because it's dealing with the size and alignment of a given `T`,
which are more restricted than an arbitrary `Layout`.

For example, imagine a struct with a `u32` and a `u4`. You can safely
create a `Layout { size_: 5, align_: 4 }` by hand, but
`Layout:🆕:<T>` will give `Layout { size_: 8, align_: 4}`, where the
size already has padding that accounts for the alignment. (And the
existing `debug_assert_eq!` in `Layout::array` already demonstrates that
no additional padding is required.)
2021-11-26 19:30:35 +11:00
Nicholas Nethercote
026edbb4ef Use unchecked construction in Layout::pad_to_align.
Other, similar methods for `Layout` do likewise, and there's already an
`unwrap()` around the result demonstrating the safety.
2021-11-26 19:30:35 +11:00
David Tolnay
2be9a8349f
Eliminate bunch of copies of error codepath from Utf8LossyChunksIter
Using a macro to stamp out 7 identical copies of the nontrivial slicing
logic to exit this loop didn't seem like a necessary use of a macro. The
early return case can be handled by `break` without practically any
changes to the logic inside the loop.

All this code is from early 2014 (7.5 years old, pre-1.0) so it's
possible there were compiler limitations that forced the macro way at
the time.

Confirmed that `x.py bench library/alloc --stage 0 --test-args from_utf8_lossy`
is unaffected on my machine.
2021-11-25 19:52:45 -08:00
David Tolnay
9125dd74bd
Eliminate an unreachable codepath from String::from_utf8_lossy
Utf8Lossy's Iterator implementation ensures that only the final chunk
has an empty slice for broken. Thus the only way the first chunk could
have an empty broken is if it is the final chunk, i.e. there is only one
chunk total. And the only way that there could be one chunk total is if
the whole input is valid utf8 and non-empty. That condition has already
been handled by an early return, so at the point that the first
REPLACEMENT is being pushed, it's impossible for first_broken to be
empty.
2021-11-25 18:27:40 -08:00
David Tolnay
553a84c445
Saner formatting for UTF8_CHAR_WIDTH table 2021-11-25 18:18:36 -08:00
Matthias Krüger
6970cf5a23
Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebank
Print associated types on opaque `impl Trait` types

This PR generalizes #91021, printing associated types for all opaque `impl Trait` types instead of just special-casing for future.

before:
```
error[E0271]: type mismatch resolving `<impl Iterator as Iterator>::Item == u32`
```

after:
```
error[E0271]: type mismatch resolving `<impl Iterator<Item = usize> as Iterator>::Item == u32`
```

---

Questions:
1. I'm kinda lost in binders hell with this one. Is all of the `rebind`ing necessary?
2. Is there a map collection type that will give me a stable iteration order? Doesn't seem like TraitRef is Ord, so I can't just sort later..
3. I removed the logic that suppresses printing generator projection types. It creates outputs like this [gist](https://gist.github.com/compiler-errors/d6f12fb30079feb1ad1d5f1ab39a3a8d). Should I put that back?
4. I also added spaces between traits, `impl A+B` -> `impl A + B`. I quite like this change, but is there a good reason to keep it like that?

r? ````@estebank````
2021-11-25 15:05:37 +01:00
Guillaume Gomez
0466a1256f Implement VecDeque::retain_mut 2021-11-25 13:28:31 +01:00
Guillaume Gomez
a81f3610ea
Rollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se
Fix test in std::process on android

closes #10380
2021-11-24 22:56:38 +01:00
Guillaume Gomez
a6a1d7ca29
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
Create rustdoc_internals feature gate

As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag.

This is pretty much what it would look like (needs to update the tests too).

The tracking issue is https://github.com/rust-lang/rust/issues/90418.

What do you think ``@rust-lang/rustdoc`` ?
2021-11-24 22:56:37 +01:00
Guillaume Gomez
658c148b87
Rollup merge of #89542 - jhpratt:stabilize-duration-const-fns, r=oli-obk
Partially stabilize `duration_consts_2`

Methods that were only blocked on `const_panic` have been stabilized.
The remaining methods of `duration_consts_2` are all related to floats,
and as such have been placed behind the `duration_consts_float` feature
gate.
2021-11-24 22:56:35 +01:00
Guillaume Gomez
1e6ced3532 Create rustdoc_internals feature gate 2021-11-24 21:57:18 +01:00
Stefan Lankes
6911af9d06
Improving the readability
Co-authored-by: kennytm <kennytm@gmail.com>
2021-11-24 21:12:56 +01:00
Stefan Lankes
644b445428 If the thread does not get the lock in the short term, yield the CPU
Reduces the amount of wasted processor cycles
2021-11-24 15:59:28 +01:00
the8472
53fc69f87c
Apply suggestions from code review
Co-authored-by: pierwill <19642016+pierwill@users.noreply.github.com>
2021-11-23 23:55:05 +01:00
Michael Goulet
b84a52c95a Add generator lang-item 2021-11-23 10:34:16 -08:00
Matthias Krüger
3dc00111f2
Rollup merge of #91153 - birkenfeld:kernel_copy_fallback, r=the8472
kernel_copy: avoid panic on unexpected OS error

According to documentation, the listed errnos should only occur
if the `copy_file_range` call cannot be made at all, so the
assert be correct.  However, since in practice file system
drivers (incl. FUSE etc.) can return any errno they want, we
should not panic here.

Fixes #91152
2021-11-23 19:28:12 +01:00
Georg Brandl
b490ccc227 kernel_copy: avoid panic on unexpected OS error
According to documentation, the listed errnos should only occur
if the `copy_file_range` call cannot be made at all, so the
assert be correct.  However, since in practice file system
drivers (incl. FUSE etc.) can return any errno they want, we
should not panic here.

Fixes #91152
2021-11-23 11:10:49 +01:00
name1e5s
08a500ffc9 fix test in std::process on android 2021-11-23 13:57:22 +08:00
Jacob Pratt
7b103e7dd2
Use derive_default_enum in the compiler 2021-11-22 20:17:53 -05:00
Eric Holk
dfa0db5961 Reintroduce into_future in .await desugaring
This is a reintroduction of the remaining parts from
https://github.com/rust-lang/rust/pull/65244 that have not been relanded
yet.

Issues GH-67644, GH-67982
2021-11-22 14:57:27 -08:00
Jacob Pratt
88b0d7cfc5
Partially stabilize duration_consts_2
Methods that were only blocked on `const_panic` have been stabilized.
The remaining methods of `duration_consts_2` are all related to floats,
and as such have been placed behind the `duration_consts_float` feature
gate.
2021-11-22 13:09:08 -05:00
bors
883a241c08 Auto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum
Mention std::io::Error::from(ErrorKind) in Error::new() docs

This conversion is not very discoverable for the cases
where an error is required without extra payload.
2021-11-22 13:56:51 +00:00
Scott McMurray
348a25044b Intra-doc links apparently don't like pointers? 2021-11-22 02:40:56 -08:00
Scott McMurray
875e01e616 Add <*{const|mut} T>::{to|from}_bits
Named based on the floating-point methods of the same name, as those are also about returning the *representation* of the value.
2021-11-22 02:08:59 -08:00
bors
cebd2dda1d Auto merge of #90352 - camsteffen:for-loop-desugar, r=oli-obk
Simplify `for` loop desugar

Basically two intermediate bindings are inlined. I could have left one intermediate binding in place as this would simplify some diagnostic logic, but I think the difference in that regard would be negligible, so it is better to have a minimal HIR.

For checking that the pattern is irrefutable, I added a special case when the `match` is found to be non-exhaustive.

The reordering of the arms is purely stylistic. I don't *think* there are any perf implications.

```diff
  match IntoIterator::into_iter($head) {
      mut iter => {
          $label: loop {
-             let mut __next;
              match Iterator::next(&mut iter) {
-                 Some(val) => __next = val,
                  None => break,
+                 Some($pat) => $block,
              }
-             let $pat = __next;
-             $block
          }
      }
  }
```
2021-11-21 21:20:20 +00:00
Eduardo Sánchez Muñoz
23637e20cd libcore: assume the input of next_code_point and next_code_point_reverse is UTF-8-like
The functions are now `unsafe` and they use `Option::unwrap_unchecked` instead of `unwrap_or_0`

`unwrap_or_0` was added in 42357d772b. I guess `unwrap_unchecked` was not available back then.

Given this example:

```rust
pub fn first_char(s: &str) -> Option<char> {
    s.chars().next()
}
```

Previously, the following assembly was produced:

```asm
_ZN7example10first_char17ha056ddea6bafad1cE:
	.cfi_startproc
	test	rsi, rsi
	je	.LBB0_1
	movzx	edx, byte ptr [rdi]
	test	dl, dl
	js	.LBB0_3
	mov	eax, edx
	ret
.LBB0_1:
	mov	eax, 1114112
	ret
.LBB0_3:
	lea	r8, [rdi + rsi]
	xor	eax, eax
	mov	r9, r8
	cmp	rsi, 1
	je	.LBB0_5
	movzx	eax, byte ptr [rdi + 1]
	add	rdi, 2
	and	eax, 63
	mov	r9, rdi
.LBB0_5:
	mov	ecx, edx
	and	ecx, 31
	cmp	dl, -33
	jbe	.LBB0_6
	cmp	r9, r8
	je	.LBB0_9
	movzx	esi, byte ptr [r9]
	add	r9, 1
	and	esi, 63
	shl	eax, 6
	or	eax, esi
	cmp	dl, -16
	jb	.LBB0_12
.LBB0_13:
	cmp	r9, r8
	je	.LBB0_14
	movzx	edx, byte ptr [r9]
	and	edx, 63
	jmp	.LBB0_16
.LBB0_6:
	shl	ecx, 6
	or	eax, ecx
	ret
.LBB0_9:
	xor	esi, esi
	mov	r9, r8
	shl	eax, 6
	or	eax, esi
	cmp	dl, -16
	jae	.LBB0_13
.LBB0_12:
	shl	ecx, 12
	or	eax, ecx
	ret
.LBB0_14:
	xor	edx, edx
.LBB0_16:
	and	ecx, 7
	shl	ecx, 18
	shl	eax, 6
	or	eax, ecx
	or	eax, edx
	ret
```

After this change, the assembly is reduced to:

```asm
_ZN7example10first_char17h4318683472f884ccE:
	.cfi_startproc
	test	rsi, rsi
	je	.LBB0_1
	movzx	ecx, byte ptr [rdi]
	test	cl, cl
	js	.LBB0_3
	mov	eax, ecx
	ret
.LBB0_1:
	mov	eax, 1114112
	ret
.LBB0_3:
	mov	eax, ecx
	and	eax, 31
	movzx	esi, byte ptr [rdi + 1]
	and	esi, 63
	cmp	cl, -33
	jbe	.LBB0_4
	movzx	edx, byte ptr [rdi + 2]
	shl	esi, 6
	and	edx, 63
	or	edx, esi
	cmp	cl, -16
	jb	.LBB0_7
	movzx	ecx, byte ptr [rdi + 3]
	and	eax, 7
	shl	eax, 18
	shl	edx, 6
	and	ecx, 63
	or	ecx, edx
	or	eax, ecx
	ret
.LBB0_4:
	shl	eax, 6
	or	eax, esi
	ret
.LBB0_7:
	shl	eax, 12
	or	eax, edx
	ret
```
2021-11-21 17:05:55 +01:00
Cameron Steffen
9c83f8c4d1 Simplify for loop desugar 2021-11-21 08:15:21 -06:00
Jonas Platte
64cca297cb
Fix method name reference in stream documentation 2021-11-21 11:57:38 +01:00
Matthias Krüger
789d168e13
Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm
Adds IEEE 754-2019 minimun and maximum functions for f32/f64

IEEE 754-2019 removed the `minNum` (`min` in Rust) and `maxNum` (`max` in Rust) operations in favor of the newly created `minimum` and `maximum` operations due to their [non-associativity](https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/minNum_maxNum_Removal_Demotion_v3.pdf) that cannot be fix in a backwards compatible manner. This PR adds `fN::{minimun,maximum}` functions following the new rules.

### IEEE 754-2019 Rules

> **minimum(x, y)** is x if x < y, y if y < x, and a quiet NaN if either operand is a NaN, according to 6.2.
For this operation, −0 compares less than +0. Otherwise (i.e., when x = y and signs are the same)
it is either x or y.

> **maximum(x, y)** is x if x > y, y if y > x, and a quiet NaN if either operand is a NaN, according to 6.2.
For this operation, +0 compares greater than −0. Otherwise (i.e., when x = y and signs are the
same) it is either x or y.

"IEEE Standard for Floating-Point Arithmetic," in IEEE Std 754-2019 (Revision of IEEE 754-2008) , vol., no., pp.1-84, 22 July 2019, doi: 10.1109/IEEESTD.2019.8766229.

### Implementation

This implementation is inspired by the one in [`glibc` ](90f0ac10a7/math/s_fminimum_template.c) (it self derived from the C2X draft) expect that:
 - it doesn't use `copysign` because it's not available in `core` and also because `copysign` is unnecessary (we only want to check the sign, no need to create a new float)
 - it also prefer `other > self` instead of `self < other` like IEEE 754-2019 does

I originally tried to implement them [using intrinsics](1d8aa13bc3) but LLVM [error out](https://godbolt.org/z/7sMrxW49a) when trying to lower them to machine intructions, GCC doesn't yet have built-ins for them, only cranelift support them nativelly (as it doesn't support the nativelly the old sementics).

Helps with https://github.com/rust-lang/rust/issues/83984
2021-11-21 09:55:13 +01:00
Georg Brandl
289eb786d4 Mention std::io::Error::from(ErrorKind) in Error::new() docs
This conversion is not very discoverable for the cases
where an error is required without extra payload.
2021-11-21 09:00:13 +01:00
Ibraheem Ahmed
25271a5a98 fix doc links for downcast_unchecked 2021-11-20 18:22:05 -05:00
Urgau
e2ec3b1dd7
Apply documentation suggestions from @est31
Co-authored-by: est31 <est31@users.noreply.github.com>
2021-11-20 23:05:30 +01:00
bors
5bc98076f3 Auto merge of #91093 - matthiaskrgr:rollup-kovzwx0, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89741 (Mark `Arc::from_inner` / `Rc::from_inner` as unsafe)
 - #90927 (Fix float ICE)
 - #90994 (Fix ICE `#90993`: add missing call to cancel)
 - #91018 (Adopt let_else in more places in rustc_mir_build)
 - #91022 (Suggest `await` in more situations where infer types are involved)
 - #91088 (Revert "require full validity when determining the discriminant of a value")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-20 21:40:43 +00:00
Matthias Krüger
09d9c098e0
Rollup merge of #89741 - sdroege:arc-rc-from-inner-unsafe, r=Mark-Simulacrum
Mark `Arc::from_inner` / `Rc::from_inner` as unsafe

While it's an internal function, it is easy to create invalid Arc/Rcs to
a dangling pointer with it.

Fixes https://github.com/rust-lang/rust/issues/89740
2021-11-20 22:33:48 +01:00
Michael Diamond
9c3b0d81ef Add a caveat to std::os::windows::fs::symlink_file
This is similar to the note on [Python's `os.symlink()`](https://docs.python.org/3/library/os.html#os.symlink). Some additional notes in https://github.com/dimo414/bkt/issues/3.
2021-11-20 12:28:43 -08:00
bors
2885c47482 Auto merge of #87704 - ChrisDenton:win-resolve-exe, r=yaahc
Windows: Resolve `process::Command` program without using the current directory

Currently `std::process::Command` searches many directories for the executable to run, including the current directory. This has lead to a [CVE for `ripgrep`](https://cve.circl.lu/cve/CVE-2021-3013) but presumably other command line utilities could be similarly vulnerable if they run commands. This was [discussed on the internals forum](https://internals.rust-lang.org/t/std-command-resolve-to-avoid-security-issues-on-windows/14800). Also discussed was [which directories should be searched](https://internals.rust-lang.org/t/windows-where-should-command-new-look-for-executables/15015).

EDIT: This PR originally removed all implicit paths. They've now been added back as laid out in the rest of this comment.

## Old Search Strategy

The old search strategy is [documented here][1]. Additionally Rust adds searching the child's paths (see also #37519). So the full list of paths that were searched was:

1. The directories that are listed in the child's `PATH` environment variable.
2. The directory from which the application loaded.
3. The current directory for the parent process.
4. The 32-bit Windows system directory.
5. The 16-bit Windows system directory.
6. The Windows directory.
7. The directories that are listed in the PATH environment variable.

## New Search Strategy

The new strategy removes the current directory from the searched paths.

1. The directories that are listed in the child's PATH environment variable.
2. The directory from which the application loaded.
3. The 32-bit Windows system directory.
4. The Windows directory.
5. The directories that are listed in the parent's PATH environment variable.

Note that it also removes the 16-bit system directory, mostly because there isn't a function to get it. I do not anticipate this being an issue in modern Windows.

## Impact

Removing the current directory should fix CVE's like the one linked above. However, it's possible some Windows users of affected Rust CLI applications have come to expect the old behaviour.

This change could also affect small Windows-only script-like programs that assumed the current directory would be used. The user would need to use `.\file.exe` instead of the bare application name.

This PR could break tests, especially those that test the exact output of error messages (e.g. Cargo) as this does change the error messages is some cases.

[1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa#parameters
2021-11-20 18:23:11 +00:00
Loïc BRANSTETT
2bad893900 Add similar note as LLVM does for minNum and maxNum functions 2021-11-20 10:14:03 +01:00
Loïc BRANSTETT
a8ee0e9c2c Implement IEEE 754-2019 minimun and maximum functions for f32/f64 2021-11-20 10:14:03 +01:00
bors
6d48ee90f5 Auto merge of #91052 - ehuss:update-stdarch, r=Amanieu
Update stdarch

5 commits in 815d55c610dab39e92e7c83bf5fd4b7a020b4d46..cfba59fccd90b3b52a614120834320f764ab08d1
2021-11-08 00:58:47 +0000 to 2021-11-19 01:29:04 +0000
- Work-around buggy Intel chips erroneously reporting BMI1/BMI2 support (rust-lang/stdarch#1249)
- complete armv8 instructions (rust-lang/stdarch#1256)
- Fix i8mm feature with bootstrap compiler. (rust-lang/stdarch#1252)
- Fix unused link_name attribute. (rust-lang/stdarch#1251)
- Add remaining insturctions (rust-lang/stdarch#1250)
2021-11-20 07:20:43 +00:00
The8472
6851b8d931 document why we're not directly passing drop_ptr to drop_in_place 2021-11-20 01:29:04 +01:00
The8472
ce994027fe replace vec::Drain drop loops with drop_in_place 2021-11-20 01:12:07 +01:00
Matthias Krüger
62b259cd88
Rollup merge of #91044 - r00ster91:x1b, r=joshtriplett
Turn all 0x1b_u8 into '\x1b' or b'\x1b'

Supersedes #91040
2021-11-20 01:09:44 +01:00
Matthias Krüger
97bd45b373
Rollup merge of #88361 - WaffleLapkin:patch-2, r=jyn514
Makes docs for references a little less confusing

- Make clear that the `Pointer` trait is related to formatting
- Make clear that the `Pointer` trait is implemented for references (previously it was confusing to first see that it's implemented and then see it in "expect")
- Make clear that `&T` (shared reference) implements `Send` (if `T: Send + Sync`)
2021-11-20 01:09:37 +01:00
The8472
39b98e8c1a Expand available_parallelism docs in anticipation of cgroup quotas
The "fixed" in "fixed steady state limits" means to exclude load-dependent resource prioritization
that would calculate to 100% of capacity on an idle system and less capacity on a loaded system.

Additionally I also exclude "system load" since it would be silly to try to identify
other, perhaps higher priority, processes hogging some CPU cores that aren't explicitly excluded
by masks/quotas/whatever.
2021-11-19 22:52:09 +01:00
Eric Huss
458ed5a0c4 Update stdarch 2021-11-19 11:20:42 -08:00
r00ster91
a2d78573d3 Turn all 0x1b_u8 into '\x1b' or b'\x1b' 2021-11-19 18:14:18 +01:00
Maybe Waffle
cdb0c29a9c Remove unnecessary doc links 2021-11-19 19:13:53 +03:00
The8472
3f9b26dc64 Fix Iterator::advance_by contract inconsistency
The `advance_by(n)` docs state that in the error case `Err(k)` that k is always less than n.
It also states that `advance_by(0)` may return `Err(0)` to indicate an exhausted iterator.
These statements are inconsistent.
Since only one implementation (Skip) actually made use of that I changed it to return Ok(()) in that case too.

While adding some tests I also found a bug in `Take::advance_back_by`.
2021-11-19 13:00:23 +01:00
Yuki Okushi
f62984fca9
Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se
windows: Return the "Not Found" error when a path is empty

Fixes #90940
2021-11-19 13:06:35 +09:00
Yuki Okushi
7432588e5d
Rollup merge of #89258 - est31:const_char_convert, r=oli-obk
Make char conversion functions unstably const

The char conversion functions like `char::from_u32` do trivial computations and can easily be converted into const fns. Only smaller tricks are needed to avoid non-const standard library functions like `Result::ok` or `bool::then_some`.

Tracking issue: https://github.com/rust-lang/rust/issues/89259
2021-11-19 13:06:31 +09:00
bors
548c1088ef Auto merge of #90774 - alexcrichton:tweak-const, r=m-ou-se
std: Tweak expansion of thread-local const

This commit tweaks the expansion of `thread_local!` when combined with a
`const { ... }` value to help ensure that the rules which apply to
`const { ... }` blocks will be the same as when they're stabilized.
Previously with this invocation:

    thread_local!(static NAME: Type = const { init_expr });

this would generate (on supporting platforms):

    #[thread_local]
    static NAME: Type = init_expr;

instead the macro now expands to:

    const INIT_EXPR: Type = init_expr;
    #[thread_local]
    static NAME: Type = INIT_EXPR;

with the hope that because `init_expr` is defined as a `const` item then
it's not accidentally allowing more behavior than if it were put into a
`static`. For example on the stabilization issue [this example][ex] now
gives the same error both ways.

[ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-18 23:54:14 +00:00
bors
cc946fcd32 Auto merge of #91019 - JohnTitor:rollup-q95ra7r, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #90386 (Add `-Zassert-incr-state` to assert state of incremental cache)
 - #90438 (Clean up mess for --show-coverage documentation)
 - #90480 (Mention `Vec::remove` in `Vec::swap_remove`'s docs)
 - #90607 (Make slice->str conversion and related functions `const`)
 - #90750 (rustdoc: Replace where-bounded Clean impl with simple function)
 - #90895 (require full validity when determining the discriminant of a value)
 - #90989 (Avoid suggesting literal formatting that turns into member access)
 - #91002 (rustc: Remove `#[rustc_synthetic]`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-18 20:23:26 +00:00
Yuki Okushi
77c985f765
Rollup merge of #90607 - WaffleLapkin:const_str_from_utf8, r=oli-obk
Make slice->str conversion and related functions `const`

This PR marks the following APIs as `const`:
```rust
// core::str
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error>;
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error>;
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str;

impl Utf8Error {
    pub const fn valid_up_to(&self) -> usize;
    pub const fn error_len(&self) -> Option<usize>;
}
```

Everything but `from_utf8_unchecked_mut` uses `const_str_from_utf8` feature gate, `from_utf8_unchecked_mut` uses `const_str_from_utf8_unchecked_mut` feature gate.

---

I'm not sure why `from_utf8_unchecked_mut` was left out being  non-`const`, considering that `from_utf8_unchecked` is not only `const`, but **`const` stable**.

---

r? ```@oli-obk``` (performance-only `const_eval_select` use)
2021-11-19 02:22:57 +09:00
Yuki Okushi
3e97d9bd97
Rollup merge of #90480 - r00ster91:remove, r=kennytm
Mention `Vec::remove` in `Vec::swap_remove`'s docs

Thought this was a nice addition.
2021-11-19 02:22:56 +09:00
bors
b6f580acc0 Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett
std: Get the standard library compiling for wasm64

This commit goes through and updates various `#[cfg]` as appropriate to
get the wasm64-unknown-unknown target behaving similarly to the
wasm32-unknown-unknown target. Most of this is just updating various
conditions for `target_arch = "wasm32"` to also account for `target_arch
= "wasm64"` where appropriate. This commit also lists `wasm64` as an
allow-listed architecture to not have the `restricted_std` feature
enabled, enabling experimentation with `-Z build-std` externally.

The main goal of this commit is to enable playing around with
`wasm64-unknown-unknown` externally via `-Z build-std` in a way that's
similar to the `wasm32-unknown-unknown` target. These targets are
effectively the same and only differ in their pointer size, but wasm64
is much newer and has much less ecosystem/library support so it'll still
take time to get wasm64 fully-fledged.
2021-11-18 17:19:27 +00:00
Maybe Waffle
573a00e3f9 Fill in tracking issues for const_str_from_utf8 and const_str_from_utf8_unchecked_mut features 2021-11-18 14:04:01 +03:00
The8472
fd1494e9c3 Document non-guarantees for Hash
Dependence on endianness and type sizes was reported for enum discriminants in #74215 but it is a more general
issue since for example the default implementation of `Hasher::write_usize` uses native endianness.
Additionally the implementations of library types are occasionally changed as their internal fields
change or hashing gets optimized.
2021-11-18 02:00:53 +01:00
Maybe Waffle
cf6f64a963 Make slice->str conversion and related functions const
This commit makes the following functions from `core::str` `const fn`:
- `from_utf8[_mut]` (`feature(const_str_from_utf8)`)
- `from_utf8_unchecked_mut` (`feature(const_str_from_utf8_unchecked_mut)`)
- `Utf8Error::{valid_up_to,error_len}` (`feature(const_str_from_utf8)`)
2021-11-18 00:50:42 +03:00
Matthias Krüger
904dba5066
Rollup merge of #90772 - GuillaumeGomez:vec-retain-mut, r=joshtriplett
Add Vec::retain_mut

This is to continue the discussion started in #83218.

Original comment was:

> Take 2 of #34265, since I needed this today.

The reason I think why we should add `retain_mut` is for coherency and for discoverability. For example we have `chunks` and `chunks_mut` or `get` and `get_mut` or `iter` and `iter_mut`, etc. When looking for mutable `retain`, I would expect `retain_mut` to exist. It took me a while to find out about `drain_filter`. So even if it provides an API close to `drain_filter`, just for the discoverability, I think it's worth it.

cc ``````@m-ou-se`````` ``````@jonas-schievink`````` ``````@Mark-Simulacrum``````
2021-11-17 15:58:01 +01:00
Matthias Krüger
ec84633b54
Rollup merge of #90687 - jhpratt:const_panic, r=oli-obk
Permit const panics in stable const contexts in stdlib

Without this change, it is not possible to use `panic!` and similar (including `assert!`) in stable const contexts inside of stdlib. See #89542 for a real-world case that currently fails for this reason. This does _not_ affect any user code.

For example, this snippet currently fails to compile:

```rust
#[stable(feature = "foo", since = "1.0.0")]
#[rustc_const_stable(feature = "foo", since = "1.0.0")]
const fn foo() {
    assert!(false);
    assert!(false, "foo");
}
```

With the addition of `#[rustc_const_unstable]` to `core::panicking::panic`, the error no longer occurs. This snippet has been added verbatim in this PR as a UI test.

To avoid needing to add `#![feature(core_panic)]` to libcore, the two instances of direct calls to `core::panicking::panic` have been switched to use the `panic!` macro.

I am requesting prioritization because this is holding up other stabilizations such as #89542 (which is otherwise ready to merge and succeeds with this change)
2021-11-17 15:58:00 +01:00
Maybe Waffle
f926c0e0d9 Fill in tracking issue for feature const_align_offset 2021-11-16 23:58:40 +03:00
Maybe Waffle
8f5f094432 Mark <*const _>::align_offset and <*mut _>::align_offset as const fn 2021-11-16 23:03:28 +03:00
Yuki Okushi
ddc1d58ca8
windows: Return the "Not Found" error when a path is empty 2021-11-17 03:11:14 +09:00
Yuki Okushi
35dd1f65e9
Rollup merge of #90909 - RalfJung:miri-no-portable-simd, r=workingjubilee
disable portable SIMD tests in Miri

Until https://github.com/rust-lang/miri/issues/1912 is resolved, we'll have to skip these tests in Miri.
2021-11-16 09:14:23 +09:00
Yuki Okushi
fb96ecc37a
Rollup merge of #90848 - scottmcm:remove-signed-bigint-helpers, r=joshtriplett
Remove bigint_helper_methods for *signed* types

This PR inspired by `@cuviper's` comment @ https://github.com/rust-lang/rust/issues/90541#issuecomment-967309808

These are working well for *unsigned* types, so keep those, but for the the *signed* ones there are a bunch of questions about what the semantics and API should be.  For the main "helpers for big integer implementations" use, there's no need for the signed versions anyway.  There are plenty of other methods which exist for unsigned types but not signed ones, like `next_power_of_two`, so this isn't unusual.

Fixes #90541
Tracking issue #85532
2021-11-16 09:14:21 +09:00
Yuki Okushi
96cfc9e73a
Rollup merge of #90835 - sunfishcode:sunfishcode/wasi-char-device, r=alexcrichton
Rename WASI's `is_character_device` to `is_char_device`.

Rename WASI's `FileTypeExt::is_character_device` to
`FileTypeExt::is_char_device`, for consistency with the Unix
`FileTypeExt::is_char_device`.

Also, add a `FileTypeExt::is_socket` function, for consistency with the
Unix `FileTypeExt::is_socket` function.

r? `@alexcrichton`
2021-11-16 09:14:19 +09:00
Yuki Okushi
aaac528b80
Rollup merge of #90790 - tamaroning:fix-lib-std-test, r=Mark-Simulacrum
Fix standard library test with read_link

closes #90669
resolve this issue by comparing between Paths instead of strs
2021-11-16 09:14:17 +09:00
Yuki Okushi
c44455af1d
Rollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahc
Implement `Termination` for `Result<Infallible, E>`

As noted in #43301, `Result<!, E>` is not usable on stable.
2021-11-16 09:14:15 +09:00
Yuki Okushi
73ec27d359
Rollup merge of #85766 - workingjubilee:file-options, r=yaahc
Stabilize File::options()

Renames File::with_options to File::options, per consensus in
rust-lang/rust#65439, and stabilizes it.
2021-11-16 09:14:14 +09:00
bors
891ca5f63c Auto merge of #90821 - scottmcm:new-slice-reverse, r=Mark-Simulacrum
MIRI says `reverse` is UB, so replace it with something LLVM can vectorize

For small types with padding, the current implementation is UB because it does integer operations on uninit values.
```
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
   --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:836:5
    |
836 | /     uint_impl! { u32, u32, i32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
837 | |     "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" }
    | |________________________________________________________________________________________________^ using uninitialized data, but this operation requires initialized memory
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

    = note: inside `core::num::<impl u32>::rotate_left` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs:211:13
    = note: inside `core::slice::<impl [Foo]>::reverse` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs:701:58
```
<https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=340739f22ca5b457e1da6f361768edc6>

But LLVM has gotten smarter since I wrote the previous implementation in 2017, so this PR removes all the manual magic and just writes it in such a way that LLVM will vectorize.  This code is much simpler and has very little `unsafe`, and is actually faster to boot!

If you're curious to see the codegen: <https://rust.godbolt.org/z/Pcn13Y9E3>

Before:
```
running 7 tests
test slice::reverse_simd_f64x4                           ... bench:      17,940 ns/iter (+/- 481) = 58448 MB/s
test slice::reverse_u128                                 ... bench:      17,758 ns/iter (+/- 205) = 59048 MB/s
test slice::reverse_u16                                  ... bench:     158,234 ns/iter (+/- 6,876) = 6626 MB/s
test slice::reverse_u32                                  ... bench:      62,047 ns/iter (+/- 1,117) = 16899 MB/s
test slice::reverse_u64                                  ... bench:      31,582 ns/iter (+/- 552) = 33201 MB/s
test slice::reverse_u8                                   ... bench:      81,253 ns/iter (+/- 1,510) = 12905 MB/s
test slice::reverse_u8x3                                 ... bench:     270,615 ns/iter (+/- 11,463) = 3874 MB/s
```

After:
```
running 7 tests
test slice::reverse_simd_f64x4                           ... bench:      17,731 ns/iter (+/- 306) = 59137 MB/s
test slice::reverse_u128                                 ... bench:      17,919 ns/iter (+/- 239) = 58517 MB/s
test slice::reverse_u16                                  ... bench:      43,160 ns/iter (+/- 607) = 24295 MB/s
test slice::reverse_u32                                  ... bench:      21,065 ns/iter (+/- 371) = 49778 MB/s
test slice::reverse_u64                                  ... bench:      21,118 ns/iter (+/- 482) = 49653 MB/s
test slice::reverse_u8                                   ... bench:      76,878 ns/iter (+/- 1,688) = 13639 MB/s
test slice::reverse_u8x3                                 ... bench:     264,723 ns/iter (+/- 5,544) = 3961 MB/s
```

Those are the existing benches, <14a2fd640e/library/alloc/benches/slice.rs (L322-L346)>
2021-11-15 20:19:23 +00:00
Josh Triplett
8c9bfaa5f3 Stabilize format_args_capture
Works as expected, and there are widespread reports of success with it,
as well as interest in it.
2021-11-15 10:14:29 +01:00
Josh Triplett
89c3d84b75 Give examples of format args capture in the fmt module documentation 2021-11-15 10:13:44 +01:00
bors
ad44239975 Auto merge of #88282 - Neutron3529:patch-4, r=Mark-Simulacrum
Optimize BinaryHeap::extend from Vec

This improves the performance of extending `BinaryHeap`s from vectors directly. Future work may involve extending this optimization to other, similar, cases where the length of the added elements is well-known, but this is not yet done in this PR.
2021-11-14 18:47:42 +00:00
Ralf Jung
60595f7bde disable portable SIMD tests in Miri 2021-11-14 12:26:35 -05:00
bors
c8e94975a6 Auto merge of #90596 - the8472:path-hash-opt, r=Mark-Simulacrum
Optimize Eq and Hash for Path/PathBuf

```
# new

test path::tests::bench_hash_path_long                            ... bench:          86 ns/iter (+/- 1)
test path::tests::bench_hash_path_short                           ... bench:          13 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:         197 ns/iter (+/- 6)
test path::tests::bench_path_hashset_miss                         ... bench:          94 ns/iter (+/- 4)

# old

test path::tests::bench_hash_path_long                            ... bench:         192 ns/iter (+/- 2)
test path::tests::bench_hash_path_short                           ... bench:          33 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:       1,121 ns/iter (+/- 24)
test path::tests::bench_path_hashset_miss                         ... bench:         273 ns/iter (+/- 6)
```
2021-11-14 15:18:26 +00:00
Jacob Pratt
5907a8ca10
Fix incorrect feature flags 2021-11-14 00:53:09 -05:00
bors
d212d902ae Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk
Stabilize `const_raw_ptr_deref` for `*const T`

This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is behind the
same feature gate as mutable references.

closes https://github.com/rust-lang/rust/issues/51911
2021-11-13 17:10:15 +00:00
bors
1b12d01903 Auto merge of #90542 - the8472:privatize-the-means-of-rawvec-production, r=joshtriplett
Make RawVec private to alloc

RawVec was previously exposed for compiler-internal use (libarena specifically) in 1acbb0a935

Since it is unstable, doc-hidden and has no associated tracking issue it was never meant for public use. And since
it is no longer used outside alloc itself it can be made private again.

Also remove some functions that are dead due to lack of internal users.
2021-11-13 13:57:00 +00:00
bors
3e018ce194 Auto merge of #87264 - mystor:expand_literal, r=petrochenkov
proc_macro: Add an expand_expr method to TokenStream

This feature is aimed at giving proc macros access to powers similar to those used by builtin macros such as `format_args!` or `concat!`. These macros are able to accept macros in place of string literal parameters, such as the format string, as they perform recursive macro expansion while being expanded.

This can be especially useful in many cases thanks to helper macros like `concat!`, `stringify!` and `include_str!` which are often used to construct string literals at compile-time in user code.

For now, this method only allows expanding macros which produce literals, although more expressions will be supported before the method is stabilized.

In earlier versions of this PR, this method exclusively returned `Literal`, and spans on returned literals were stripped of expansion context before being returned to be as conservative as possible about permission leakage. The method's naming has been generalized to eventually support arbitrary expressions, and the context stripping has been removed (https://github.com/rust-lang/rust/pull/87264#discussion_r674863279), which should allow for more general APIs like "format_args_implicits" (https://github.com/rust-lang/rust/issues/67984) to be supported as well.

## API Surface

```rust
impl TokenStream {
    pub fn expand_expr(&self) -> Result<TokenStream, ExpandError>;
}

#[non_exhaustive]
pub struct ExpandError;

impl Debug for ExpandError { ... }
impl Display for ExpandError { ... }
impl Error for ExpandError {}
impl !Send for ExpandError {}
impl !Sync for ExpandError {}
```
2021-11-13 08:22:52 +00:00
bors
7594067b69 Auto merge of #90041 - jfrimmel:rt_copy_checks, r=Mark-Simulacrum
Re-enable `copy[_nonoverlapping]()` debug-checks

This commit re-enables the debug checks for valid usages of the two functions `copy()` and `copy_nonoverlapping()`. Those checks were commented out in #79684 in order to make the functions const. All that's been left was a FIXME, that could not be resolved until there is was way to only do the checks at runtime.
Since #89247 there is such a way: `const_eval_select()`. This commit uses that new intrinsic in order to either do nothing (at compile time) or to do the old checks (at runtime).

The change itself is rather small: in order to make the checks usable with `const_eval_select`, they are moved into a local function (one for `copy` and one for `copy_nonoverlapping` to keep symmetry).

The change does not break referential transparency, as there is nothing you can do at compile time, which you cannot do on runtime without getting undefined behavior. The CTFE-engine won't allow missuses. The other way round is also fine.

I've refactored the code to use `#[cfg(debug_assertions)]` on the new items. If that is not desired, the second commit can be dropped.
I haven't added any checks, as I currently don't know, how to test this properly.

Closes #90012.

cc `@rust-lang/lang,` `@rust-lang/libs` and `@rust-lang/wg-const-eval` (as those teams are linked in the issue above).
2021-11-13 05:19:39 +00:00
Ibraheem Ahmed
8db85a3c78 add slice take methods 2021-11-12 23:08:27 -05:00
Ibraheem Ahmed
6f982930ba add tracking issue for downcast_unchecked 2021-11-12 22:55:11 -05:00
Ibraheem Ahmed
29403eeef0 add unchecked downcast methods 2021-11-12 22:53:26 -05:00
bors
032dfe4360 Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrum
pub use core::simd;

A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust, `std::arch` offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completely `unsafe` to use.  `core::simd` offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available.

`core::simd` is enabled by the `#![portable_simd]` nightly feature tracked in https://github.com/rust-lang/rust/issues/86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests **are** introduced via the documentation, but these use deterministic asserts.

There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out.

The major types are
- `core::simd::Simd<T, N>`
- `core::simd::Mask<T, N>`

There is also the `LaneCount` struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.
2021-11-13 02:17:20 +00:00
Scott McMurray
6323f928bf Remove bigint_helper_methods for *signed* types
These are working well for *unsigned* types, for the the signed ones there are a bunch of questions about what the semantics and API should be.  And for the main "helpers for big integer implementations" use, there's no need for the signed versions anyway.

And there are plenty of other methods which exist for unsigned types but not signed ones, like `next_power_of_two`, so this isn't unusual.

Fixes 90541
2021-11-12 17:00:47 -08:00
Jubilee Young
7c3d72d069 Test core::simd works
These tests just verify some basic APIs of core::simd function, and
guarantees that attempting to access the wrong things doesn't work.
The majority of tests are stochastic, and so remain upstream, but
a few deterministic tests arrive in the subtree as doc tests.
2021-11-12 16:58:47 -08:00
Jubilee Young
39cb863253 Expose portable-simd as core::simd
This enables programmers to use a safe alternative to the current
`extern "platform-intrinsics"` API for writing portable SIMD code.
This is `#![feature(portable_simd)]` as tracked in #86656
2021-11-12 16:58:39 -08:00
Jubilee Young
fdee059c90 Add 'library/portable-simd/' from commit '1ce1c645cf27c4acdefe6ec8a11d1f0491954a99'
git-subtree-dir: library/portable-simd
git-subtree-mainline: efd0483949
git-subtree-split: 1ce1c645cf
2021-11-12 16:58:25 -08:00
Josh Stone
5ff6ac4287 Refactor weak symbols in std::sys::unix
This makes a few changes to the weak symbol macros in `sys::unix`:

- `dlsym!` is added to keep the functionality for runtime `dlsym`
  lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't
  want to show up in ELF symbol tables.
- `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime
  behavior is just a simple null check. This is also used by `syscall!`.
  - On non-ELF targets (macos/ios) where that linkage is not known to
    behave, `weak!` is just an alias to `dlsym!` for the old behavior.
- `raw_syscall!` is added to always call `libc::syscall` on linux and
  android, for cases like `clone3` that have no known libc wrapper.

The new `weak!` linkage does mean that you'll get versioned symbols if
you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`.
This might seem problematic, but old non-weak symbols can tie the build
to new versions too, like `dlsym@GLIBC_2.34` from their recent library
unification. If you build with an old glibc like `dist-x86_64-linux`
does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may
be resolved based on the runtime glibc.

I also found a few functions that don't need to be weak anymore:

- Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as
  these were added in API 12, and our baseline is API 14.
- Linux can directly use `splice`, added way back in glibc 2.5 and
  similarly old musl. Android only added it in API 21 though.
2021-11-12 15:25:16 -08:00
Nika Layzell
3e4d3d2a29 proc_macro: Add an expand_expr method to TokenStream
This feature is aimed at giving proc macros access to powers similar to
those used by builtin macros such as `format_args!` or `concat!`. These
macros are able to accept macros in place of string literal parameters,
such as the format string, as they perform recursive macro expansion
while being expanded.

This can be especially useful in many cases thanks to helper macros like
`concat!`, `stringify!` and `include_str!` which are often used to
construct string literals at compile-time in user code.

For now, this method only allows expanding macros which produce
literals, although more expresisons will be supported before the method
is stabilized.
2021-11-12 15:41:40 -05:00
Matthias Krüger
5b3cb68d97
Rollup merge of #90798 - edmorley:doc-unreachable-custom-message, r=dtolnay
Document `unreachable!` custom panic message

The `unreachable!` docs previously did not mention that there was a second form, `unreachable!("message")` that could be used to specify a custom panic message,

The docs now mention this feature in the same wording as currently used for `unimplemented!`:
https://doc.rust-lang.org/core/macro.unimplemented.html#panics
2021-11-12 19:17:33 +01:00
Matthias Krüger
160602b485
Rollup merge of #90704 - ijackson:exitstatus-comments, r=joshtriplett
Unix ExitStatus comments and a tiny docs fix

Some nits left over from #88300
2021-11-12 19:17:31 +01:00
Matthias Krüger
70532c4503
Rollup merge of #90644 - est31:const_swap, r=Mark-Simulacrum
Extend the const swap feature

Adds the `const_swap` feature gate to three more swap functions. cc tracking issue #83163

```Rust
impl<T> [T] {
    pub const fn swap(&mut self, a: usize, b: usize);
    pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize);
}
impl<T: ?Sized> *mut T {
    pub const unsafe fn swap(self, with: *mut T);
}
2021-11-12 19:17:30 +01:00
Dan Gohman
2d46d1bec9 Rename WASI's is_character_device to is_char_device.
Rename WASI's `FileTypeExt::is_character_device` to
`FileTypeExt::is_char_device`, for consistency with the Unix
`FileTypeExt::is_char_device`.

Also, add a `FileTypeExt::is_socket` function, for consistency with the
Unix `FileTypeExt::is_socket` function.
2021-11-12 09:25:32 -08:00
Guillaume Gomez
c15b55ace6 Add Vec::retain_mut 2021-11-12 15:22:48 +01:00
Neutron3529
2feee3659e provide a SpecExtend trait for Vec<T>
The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3)
2021-11-12 15:45:25 +08:00
Scott McMurray
71f5cfb21f MIRI says reverse is UB, so replace it with an implementation that LLVM can vectorize
For small types with padding, the current implementation is UB because it does integer operations on uninit values.  But LLVM has gotten smarter since I wrote the previous implementation in 2017, so remove all the manual magic and just write it in such a way that LLVM will vectorize.  This code is much simpler (albeit nuanced) and has very little `unsafe`, and is actually faster to boot!
2021-11-11 20:32:18 -08:00
The8472
c1ea7bdc87 Prefix can be case-insensitive, delegate to its Hash impl instead of trying to hash the raw bytes
This should have 0 performance overhead on unix since Prefix is always None.
2021-11-11 21:44:12 +01:00
Ian Jackson
fe39fb3149 process::ExitStatus: Discuss exit vs _exit in a comment.
As discussed here
 https://github.com/rust-lang/rust/pull/88300#issuecomment-936097710

I felt this was the best place to put this (rather than next to
ExitStatusExt).  After all, it's a property of the ExitStatus type on
Unix.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11 17:48:51 +00:00
Ian Jackson
d1df4715ec unix::ExitStatus: Add comment saying that it's a wait status
With cross-reference.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11 17:48:51 +00:00