Commit graph

4112 commits

Author SHA1 Message Date
Christiaan Dirkx
a808fd44a3 Move std::sys::unix::ext to std::os::unix 2021-05-03 16:56:21 +02:00
Christiaan Dirkx
ffc20e48de Move std::sys::windows::ext to std::os::windows 2021-05-03 16:56:20 +02:00
Christiaan Dirkx
7024bfffbd Move std::sys::hermit::ext to std::os::hermit 2021-05-03 16:56:20 +02:00
Christiaan Dirkx
0e2cd33db8 Cleanup std::os 2021-05-03 16:56:20 +02:00
Guillaume Gomez
55e21e8cca
Rollup merge of #84858 - LingMan:patch-1, r=JohnTitor
Fix stability attributes of byte-to-string specialization
2021-05-03 15:08:11 +02:00
Guillaume Gomez
2604440d8a
Rollup merge of #84856 - kornelski:enomem, r=JohnTitor
Correct stability of ErrorKind::OutOfMemory

Fix for #84744
2021-05-03 15:08:10 +02:00
Guillaume Gomez
dd5fc8edb8
Rollup merge of #84835 - wcampbell0x2a:add-issue-34202-link, r=m-ou-se
Add link to Issue #34202 in udp docs
2021-05-03 15:08:02 +02:00
wcampbell
2e559c8e10
use else if in std library
Clippy: Decreases indentation and improves readability

Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2021-05-03 07:05:08 -04:00
LingMan
eb9f168e1e
Fix stability attributes of byte-to-string specialization 2021-05-03 13:00:34 +02:00
Kornel
2247d46b11 Correct stability of ErrorKind::OutOfMemory 2021-05-03 10:28:19 +01:00
bors
e327a823d8 Auto merge of #84845 - wcampbell0x2a:clippy-redundant-field-names, r=joshtriplett
[clippy] remove redundant field names
2021-05-03 08:05:12 +00:00
bors
2428cc4816 Auto merge of #84842 - blkerby:null_lowercase, r=joshtriplett
Replace 'NULL' with 'null'

This replaces occurrences of "NULL" with "null" in docs, comments, and compiler error/lint messages. This is for the sake of consistency, as the lowercase "null" is already the dominant form in Rust. The all-caps NULL looks like the C macro (or SQL keyword), which seems out of place in a Rust context, given that NULL does not exist in the Rust language or standard library (instead having [`ptr::null()`](https://doc.rust-lang.org/stable/std/ptr/fn.null.html)).
2021-05-03 05:41:23 +00:00
wcampbell
962c3416ca
[clippy] remove redundant field names
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2021-05-02 20:24:17 -04:00
bors
59f551a2dc Auto merge of #84840 - Dylan-DPC:rollup-uzk7w0h, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #84072 (Allow setting `target_family` to multiple values, and implement `target_family="wasm"`)
 - #84744 (Add ErrorKind::OutOfMemory)
 - #84784 (Add help message to suggest const for unused type param)
 - #84811 (RustDoc: Fix bounds linking trait.Foo instead of traitalias.Foo)
 - #84818 (suggestion for unit enum variant when matched with a patern)
 - #84832 (Do not print visibility in external traits)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-03 00:17:16 +00:00
Brent Kerby
6679f5ceb1 Change 'NULL' to 'null' 2021-05-02 17:46:00 -06:00
wcampbell
e4250a014e
Add link to Issue #34202 in udp docs
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2021-05-02 19:13:41 -04:00
bors
8a8ed07883 Auto merge of #82576 - gilescope:to_string, r=Amanieu
i8 and u8::to_string() specialisation (far less asm).

Take 2. Around 1/6th of the assembly to without specialisation.

https://godbolt.org/z/bzz8Mq

(partially fixes #73533 )
2021-05-02 22:01:57 +00:00
Kornel
19568f9a83 Use ErrorKind::OutOfMemory in unix, windows, and wasi 2021-05-02 11:40:32 +01:00
Kornel
541c8d898e Add ErrorKind::OutOfMemory 2021-05-02 11:40:31 +01:00
bors
e244e840f2 Auto merge of #84725 - sebpop:arm64-isb, r=joshtriplett
[Arm64] use isb instruction instead of yield in spin loops

On arm64 we have seen on several databases that ISB (instruction synchronization
barrier) is better to use than yield in a spin loop.  The yield instruction is a
nop.  The isb instruction puts the processor to sleep for some short time.  isb
is a good equivalent to the pause instruction on x86.

Below is an experiment that shows the effects of yield and isb on Arm64 and the
time of a pause instruction on x86 Intel processors.  The micro-benchmarks use
https://github.com/google/benchmark.git

```
$ cat a.cc
static void BM_scalar_increment(benchmark::State& state) {
  int i = 0;
  for (auto _ : state)
    benchmark::DoNotOptimize(i++);
}
BENCHMARK(BM_scalar_increment);
static void BM_yield(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("yield"::);
}
BENCHMARK(BM_yield);
static void BM_isb(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("isb"::);
}
BENCHMARK(BM_isb);
BENCHMARK_MAIN();

$ g++ -o run a.cc -O2 -lbenchmark -lpthread
$ ./run

--------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
--------------------------------------------------------------

AWS Graviton2 (Neoverse-N1) processor:
BM_scalar_increment      0.485 ns        0.485 ns   1000000000
BM_yield                 0.400 ns        0.400 ns   1000000000
BM_isb                    13.2 ns         13.2 ns     52993304

AWS Graviton (A-72) processor:
BM_scalar_increment      0.897 ns        0.874 ns    801558633
BM_yield                 0.877 ns        0.875 ns    800002377
BM_isb                    13.0 ns         12.7 ns     55169412

Apple Arm64 M1 processor:
BM_scalar_increment      0.315 ns        0.315 ns   1000000000
BM_yield                 0.313 ns        0.313 ns   1000000000
BM_isb                    9.06 ns         9.06 ns     77259282
```

```
static void BM_pause(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("pause"::);
}
BENCHMARK(BM_pause);

Intel Skylake processor:
BM_scalar_increment      0.295 ns        0.295 ns   1000000000
BM_pause                  41.7 ns         41.7 ns     16780553
```

Tested on Graviton2 aarch64-linux with `./x.py test`.
2021-05-02 04:54:31 +00:00
bors
603a42ec54 Auto merge of #84658 - Amanieu:reserved_regs, r=petrochenkov
Be stricter about rejecting LLVM reserved registers in asm!

LLVM will silently produce incorrect code if these registers are used as operands.

cc `@rust-lang/wg-inline-asm`
2021-05-01 13:01:24 +00:00
Amanieu d'Antras
ea310d9253 Reserve x18 on AArch64 and un-reserve x16 2021-05-01 13:25:56 +01:00
Soveu
7bd9d9f1e9 str::is_char_boundary - few comments 2021-04-30 20:51:30 +02:00
Amanieu d'Antras
09cfb248e7 Avoid using rbx in SGX inline assembly since it is reserved 2021-04-30 18:27:12 +01:00
Joshua Nelson
4a63e1e991 Allow using core:: in intra-doc links within core itself
I came up with this idea ages ago, but rustdoc used to ICE on it. Now it
doesn't.
2021-04-30 14:57:07 +00:00
Soveu
2ea0410f09 str::is_char_boundary - slight optimization 2021-04-30 16:13:00 +02:00
bors
7506228e2e Auto merge of #84716 - joshtriplett:chroot, r=dtolnay
Add std::os::unix::fs::chroot to change the root directory of the current process

This is a straightforward wrapper that uses the existing helpers for C
string handling and errno handling.

Having this available is convenient for UNIX utility programs written in
Rust, and avoids having to call the unsafe `libc::chroot` directly and
handle errors manually, in a program that may otherwise be entirely safe
code.
2021-04-30 12:19:37 +00:00
bors
49920bc581 Auto merge of #84522 - CDirkx:cmath, r=yaahc
Reuse `sys::unix::cmath` on other platforms

Reuse `sys::unix::cmath` on all non-`windows` platforms.

`unix` is chosen as the canonical location instead of `unsupported` or `common` because `unsupported` doesn't make sense semantically and `common` is reserved for code that is supported on all platforms. Also `unix` is already the home of some non-`windows` code that is technically not exclusive to `unix` like `unix::path`.
2021-04-30 09:52:32 +00:00
Josh Triplett
ffb874ac90 Add std::os::unix::fs::chroot to change the root directory of the current process
This is a straightforward wrapper that uses the existing helpers for C
string handling and errno handling.

Having this available is convenient for UNIX utility programs written in
Rust, and avoids having to call the unsafe `libc::chroot` directly and
handle errors manually, in a program that may otherwise be entirely safe
code.
2021-04-30 00:11:03 -07:00
Jack Huey
32c5f39faf
Rollup merge of #84706 - joshtriplett:reduce-aliases, r=m-ou-se
Drop alias `reduce` for `fold` - we have a `reduce` function

Searching for "reduce" currently puts the `reduce` alias for `fold`
above the actual `reduce` function. The `reduce` function already has a
cross-reference for `fold`, and vice versa.
2021-04-29 19:27:27 -04:00
Jack Huey
6e50ac8a34
Rollup merge of #84692 - r00ster91:var-var_os-vars, r=joshtriplett
Link between std::env::{var, var_os} and std::env::{vars, vars_os}

In #84551 I linked between `std::env::{args, args_os}` and this PR does the same but for `std::env::{var, var_os}` and `std::env::{vars, vars_os}`. Now all of `std::env::{var, var_os, vars, vars_os, args, args_os}` should each mention their `_os` or non-`_os` equivalent in the docs so that you can easily navigate between them.
2021-04-29 19:27:25 -04:00
Jack Huey
15582fcd14
Rollup merge of #84683 - Ben-Lichtman:grammar, r=jonas-schievink
Minor grammar tweaks for readability to btree internals

I was reading through the btree implementation and I noticed some grammar that could be improved in Node.rs so here is what I think would be a minor improvement.
2021-04-29 19:27:23 -04:00
Jack Huey
e720df672d
Rollup merge of #84590 - est31:array_into_iter, r=nikomatsakis
Point out that behavior might be switched on 2015 and 2018 too one day

Reword documentation to make it clear that behaviour can be switched on older editions too, one day in the future. It doesn't *have* to be switched, but I think it's good to have it as an option and re-evaluate it a few months/years down the line when e.g. the crates that showed up in crater were broken by different changes in the language already.

cc #25725, #65819, #66145, #84147 , and https://github.com/rust-lang/rust/issues/84133#issuecomment-818005314
2021-04-29 19:27:21 -04:00
Sebastian Pop
c064b6560b [Arm64] use isb instruction instead of yield in spin loops
On arm64 we have seen on several databases that ISB (instruction synchronization
barrier) is better to use than yield in a spin loop.  The yield instruction is a
nop.  The isb instruction puts the processor to sleep for some short time.  isb
is a good equivalent to the pause instruction on x86.

Below is an experiment that shows the effects of yield and isb on Arm64 and the
time of a pause instruction on x86 Intel processors.  The micro-benchmarks use
https://github.com/google/benchmark.git

$ cat a.cc
static void BM_scalar_increment(benchmark::State& state) {
  int i = 0;
  for (auto _ : state)
    benchmark::DoNotOptimize(i++);
}
BENCHMARK(BM_scalar_increment);
static void BM_yield(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("yield"::);
}
BENCHMARK(BM_yield);
static void BM_isb(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("isb"::);
}
BENCHMARK(BM_isb);
BENCHMARK_MAIN();

$ g++ -o run a.cc -O2 -lbenchmark -lpthread
$ ./run

--------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
--------------------------------------------------------------

AWS Graviton2 (Neoverse-N1) processor:
BM_scalar_increment      0.485 ns        0.485 ns   1000000000
BM_yield                 0.400 ns        0.400 ns   1000000000
BM_isb                    13.2 ns         13.2 ns     52993304

AWS Graviton (A-72) processor:
BM_scalar_increment      0.897 ns        0.874 ns    801558633
BM_yield                 0.877 ns        0.875 ns    800002377
BM_isb                    13.0 ns         12.7 ns     55169412

Apple Arm64 M1 processor:
BM_scalar_increment      0.315 ns        0.315 ns   1000000000
BM_yield                 0.313 ns        0.313 ns   1000000000
BM_isb                    9.06 ns         9.06 ns     77259282

static void BM_pause(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("pause"::);
}
BENCHMARK(BM_pause);

Intel Skylake processor:
BM_scalar_increment      0.295 ns        0.295 ns   1000000000
BM_pause                  41.7 ns         41.7 ns     16780553

Tested on Graviton2 aarch64-linux with `./x.py test`.
2021-04-29 23:05:40 +00:00
Josh Triplett
8a2e67e0d0 Simplify chdir implementation and minimize unsafe block 2021-04-29 13:11:20 -07:00
Josh Triplett
c185f08e46 Add doc alias for chdir to std::env::set_current_dir
Searching for `chdir` in the Rust documentation produces no useful
results.
2021-04-29 12:41:23 -07:00
Josh Triplett
20b569f579 Drop alias reduce for fold - we have a reduce function
Searching for "reduce" currently puts the `reduce` alias for `fold`
above the actual `reduce` function. The `reduce` function already has a
cross-reference for `fold`, and vice versa.
2021-04-29 12:05:08 -07:00
bors
18587b14d1 Auto merge of #84556 - RalfJung:const-fn-trait-bound, r=oli-obk
use correct feature flag for impl-block-level trait bounds on const fn

I am not sure what that special hack was needed for, but it doesn't seem needed any more...

This removes the last use of the `const_fn` feature flag -- Cc https://github.com/rust-lang/rust/issues/84510
r? `@oli-obk`
2021-04-29 17:38:37 +00:00
Mohsen Zohrevandi
8a0a4b1493 Use atomics in join_orders_after_tls_destructors test
std::sync::mpsc uses thread locals and depending on the order TLS dtors
are run `rx.recv()` can panic when used in a TLS dtor.
2021-04-29 08:51:18 -07:00
r00ster91
d0c0b8a4a3 Link between std::env::{var, var_os} and std::env::{vars, vars_os} 2021-04-29 13:15:49 +02:00
est31
a3523363db Ignore doctests in bootstrap
On bootstrap the IntoIterator trait is not implemented
yet for arrays.
2021-04-29 12:39:23 +02:00
Ralf Jung
9a852776f4 don't let const_fn feature flag affect impl-block-level trait bounds 2021-04-29 09:27:45 +02:00
Jack Huey
ccd04a5281
Rollup merge of #84663 - CDirkx:dropguard, r=Mark-Simulacrum
Remove `DropGuard` in `sys::windows::process` and use `StaticMutex` instead

`StaticMutex` is a mutex that when locked provides a guard that unlocks the mutex again when dropped, thus provides the exact same functionality as `DropGuard`. `StaticMutex` is used in more places, and is thus preferred over an ad-hoc construct like `DropGuard`.

````@rustbot```` label: +T-libs-impl
2021-04-28 22:59:31 -04:00
Ben-Lichtman
3e016a7682 Minor grammar tweaks for readability 2021-04-28 19:43:33 -07:00
bors
50ca3ac24f Auto merge of #84615 - a1phyr:clone_from_pathbuf_osstring, r=Mark-Simulacrum
Override `clone_from` method for PathBuf and OsString

This was not the case before because `#[derive(Clone)]` do not do it.
2021-04-28 23:25:23 +00:00
bors
da43ee8d82 Auto merge of #84650 - a1phyr:simplify_mutex_into_inner, r=m-ou-se
Simplify `Mutex::into_inner`

Thanks to #77147, `Mutex` do not implement `Drop` directly, so the old unsafe implementation of `into_inner` is not relevant anymore.
2021-04-28 18:08:01 +00:00
Christiaan Dirkx
1ac632627b Remove DropGuard in sys::windows::process and use StaticMutex instead 2021-04-28 19:11:57 +02:00
Christiaan Dirkx
cf79c06575 Fix missing import in unsupported::args 2021-04-28 16:16:01 +02:00
Christiaan Dirkx
45bc1930ca Reuse unsupported::args on wasm 2021-04-28 16:14:03 +02:00
Christiaan Dirkx
fab8410801 Move wasm atomics code to wasm/atomics 2021-04-28 16:14:01 +02:00
Christiaan Dirkx
52fa9daa64 Rework wasm::thread to thread_atomics 2021-04-28 15:51:14 +02:00
bors
20040fa332 Auto merge of #84562 - richkadel:issue-83601, r=tmandry
Adds feature-gated `#[no_coverage]` function attribute, to fix derived Eq `0` coverage issue #83601

Derived Eq no longer shows uncovered

The Eq trait has a special hidden function. MIR `InstrumentCoverage`
would add this function to the coverage map, but it is never called, so
the `Eq` trait would always appear uncovered.

Fixes: #83601

The fix required creating a new function attribute `no_coverage` to mark
functions that should be ignored by `InstrumentCoverage` and the
coverage `mapgen` (during codegen).

Adding a `no_coverage` feature gate with tracking issue #84605.

r? `@tmandry`
cc: `@wesleywiser`
2021-04-28 13:05:16 +00:00
Christiaan Dirkx
26fb1e373b Reuse unix::cmath 2021-04-28 14:25:04 +02:00
Benoît du Garreau
0b7b121c29 Simplify Mutex::into_inner 2021-04-28 13:56:23 +02:00
Yuki Okushi
7ebe5b9e4d
Rollup merge of #84642 - Amanieu:vec_extend_from_within, r=dtolnay
Stabilize vec_extend_from_within

Closes #81656
2021-04-28 16:59:11 +09:00
Yuki Okushi
0e72e0fb7f
Rollup merge of #84624 - r00ster91:patch-5, r=JohnTitor
Make sentence in env::args_os' docs plain and simple

Follow-up to #84551. See https://github.com/rust-lang/rust/pull/84551#discussion_r620728070 on why this makes more sense.
2021-04-28 16:59:09 +09:00
Amanieu d'Antras
22951b7f56 Stabilize vec_extend_from_within 2021-04-28 07:27:06 +01:00
Rich Kadel
3a5df48021 adds feature gating of no_coverage at either crate- or function-level 2021-04-27 17:12:51 -07:00
est31
12642d99a6 Add a paragraph with possible alternatives on older editions 2021-04-28 01:42:14 +02:00
r00ster
1778f30cd8
Make sentence in env::args_os' docs plain and simple 2021-04-27 21:31:04 +02:00
Rich Kadel
888d0b4c96 Derived Eq no longer shows uncovered
The Eq trait has a special hidden function. MIR `InstrumentCoverage`
would add this function to the coverage map, but it is never called, so
the `Eq` trait would always appear uncovered.

Fixes: #83601

The fix required creating a new function attribute `no_coverage` to mark
functions that should be ignored by `InstrumentCoverage` and the
coverage `mapgen` (during codegen).

While testing, I also noticed two other issues:

* spanview debug file output ICEd on a function with no body. The
workaround for this is included in this PR.
* `assert_*!()` macro coverage can appear covered if followed by another
`assert_*!()` macro. Normally they appear uncovered. I submitted a new
Issue #84561, and added a coverage test to demonstrate this issue.
2021-04-27 11:11:56 -07:00
Dylan DPC
7969de2d9c
Rollup merge of #84563 - jclulow:backtrace-upgrade, r=Mark-Simulacrum
Update backtrace to 0.3.57

Adds support for symbol resolution on illumos systems.
2021-04-27 19:08:48 +02:00
Dylan DPC
e7be5ddc4a
Rollup merge of #84521 - CDirkx:hermit-dedup, r=Mark-Simulacrum
Reuse modules on `hermit`

Reuse the following modules on `hermit`:
- `unix::path` (contents identical)
- `unsupported::io` (contents identical)
- `unsupported::thread_local_key` (contents functionally identical, only changes are the panic error messages)

`@rustbot` label: +T-libs-impl
2021-04-27 19:08:46 +02:00
Benoît du Garreau
4a8671a2fa Override clone_from method for PathBuf and OsString 2021-04-27 15:20:59 +02:00
Dan Zwell
6c22b39187 Reorder the parameter descriptions of map_or and map_or_else
They were described backwards. #84608
2021-04-27 18:00:30 +08:00
bors
61e171566a Auto merge of #84092 - scottmcm:try_trait_initial, r=yaahc,m-ou-se
Add the `try_trait_v2` library basics

No compiler changes as part of this -- just new unstable traits and impls thereof.

The goal here is to add the things that aren't going to break anything, to keep the feature implementation simpler in the next PR.

(Draft since the FCP won't end until Saturday, but I was feeling optimistic today -- and had forgotten that FCP was 10 days, not 7 days.)
2021-04-26 23:17:31 +00:00
bors
9684258936 Auto merge of #84600 - m-ou-se:rollup-mf5m2z8, r=m-ou-se
Rollup of 4 pull requests

Successful merges:

 - #84120 (Stabilize Duration::MAX)
 - #84523 (Stabilize ordering_helpers.)
 - #84551 (Unify the docs of std::env::{args_os, args} more)
 - #84574 (rustdoc: Fix typos in maybe_inline_local fn)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-04-26 19:58:11 +00:00
Mara Bos
6d277c7694
Rollup merge of #84551 - r00ster91:patch-4, r=yaahc
Unify the docs of std::env::{args_os, args} more

I noticed that `args_os` was missing some information and I thought it should mention `args` for when you want more safety just like how `args` mentions `args_os` if you don't want it to panic on invalid Unicode.
2021-04-26 21:06:48 +02:00
Mara Bos
9758d532f0
Rollup merge of #84523 - m-ou-se:stabilize-ordering-helpers, r=m-ou-se
Stabilize ordering_helpers.

Tracking issue: https://github.com/rust-lang/rust/issues/79885

Closes https://github.com/rust-lang/rust/issues/79885
2021-04-26 21:06:47 +02:00
Mara Bos
fb1502d570
Rollup merge of #84120 - workingjubilee:stabilize-duration-max, r=m-ou-se
Stabilize Duration::MAX

Following the suggested direction from https://github.com/rust-lang/rust/issues/76416#issuecomment-817278338, this PR proposes that `Duration::MAX` should have been part of the `duration_saturating_ops` feature flag all along, having been

0. heavily referenced by that feature flag
1. an odd duck next to most of `duration_constants`, as I expressed in https://github.com/rust-lang/rust/issues/57391#issuecomment-717681193
2. introduced in #76114 which added `duration_saturating_ops`

and accordingly should be folded into `duration_saturating_ops` and therefore stabilized.

r? `@m-ou-se`
2021-04-26 21:06:46 +02:00
est31
5bd31879d7 Point out that behavior might be switched on 2015 and 2018 editions too one day 2021-04-26 21:02:08 +02:00
bors
ae54ee6507 Auto merge of #84174 - camsteffen:slice-diag, r=Mark-Simulacrum
Remove slice diagnostic item

...because it is unusally placed on an impl and is redundant with a lang item.

Depends on rust-lang/rust-clippy#7074 (next clippy sync). ~I expect clippy tests to fail in the meantime.~ Nope tests passed...

CC `@flip1995`
2021-04-26 17:16:03 +00:00
bors
7bd62a8f5a Auto merge of #83390 - clarfonthey:hasher_docs, r=Amanieu
Document Hasher spec decision from #42951

Since that ticket was closed without the decision actually being documented.

Fixes #42951.
2021-04-26 08:21:55 +00:00
bors
4f0b24fd73 Auto merge of #84543 - paolobarbolini:reverse_bits-const-since, r=m-ou-se
Fix 'const-stable since' of reverse_bits

This fixes the const_stable `since` of `reverse_bits` for the signed and unsigned integer types. The previous value was incorrect, as it pointed to an older version where `reverse_bits` hadn't been stabilized yet.

`reverse_bits` was const-stable from the start, as can be seen from:

https://doc.rust-lang.org/1.37.0/std/primitive.u32.html#method.reverse_bits
https://doc.rust-lang.org/1.37.0/std/primitive.i32.html#method.reverse_bits
2021-04-26 05:41:04 +00:00
ltdk
920de7dd94 Document Hasher spec decision from #42951 2021-04-26 01:11:46 -04:00
Dylan DPC
000a630110
Rollup merge of #84547 - RalfJung:max_const_fn, r=oli-obk
Get rid of is_min_const_fn

This removes the last trace of the min_const_fn mechanism by making the unsafety checker agnostic about whether something is a min or "non-min" const fn. It seems this distinction was used to disallow some features inside `const fn`, but that is the responsibility of the const checker, not of the unsafety checker. No test seems to even notice this change in the unsafety checker so I guess we are good...

r? `@oli-obk`
Cc https://github.com/rust-lang/rust/issues/84510
2021-04-25 23:15:18 +02:00
Dylan DPC
25508ebe68
Rollup merge of #84541 - KaiJewson:inline-raw, r=m-ou-se
Inline most raw socket, fd and handle conversions

Now that file descriptor types on Unix have niches, it is advantageous for user libraries which provide file descriptor wrappers (e.g. `Socket` from socket2) to store a `File` internally instead of a `RawFd`, so that the niche can be taken advantage of. However, doing so will currently result in worse performance as `IntoRawFd`, `FromRawFd` and `AsRawFd` are not inlined. This change adds `#[inline]` to those methods on std types that wrap file descriptors, handles or sockets.
2021-04-25 23:15:17 +02:00
Joshua M. Clulow
d21fb2bc36 Update backtrace to 0.3.57
Adds support for symbol resolution on illumos systems.
2021-04-25 13:48:03 -07:00
Jubilee Young
8278380047 Update to reflect feedback on the constraints 2021-04-25 10:28:23 -07:00
Scott McMurray
5671647902 Documentation improvements (hopefully) 2021-04-25 10:04:23 -07:00
r00ster
82b6983aca
Change wording 2021-04-25 15:48:24 +02:00
r00ster
22ec96135d
Unify the docs of std::env::{args_os, args} more 2021-04-25 14:45:48 +02:00
Ralf Jung
43126f3573 get rid of min_const_fn references in library/ and rustdoc 2021-04-25 14:14:19 +02:00
bors
06f0adb345 Auto merge of #84216 - RalfJung:black-box, r=Mark-Simulacrum
move core::hint::black_box under its own feature gate

The `black_box` function had its own RFC and is tracked separately from the `test` feature at https://github.com/rust-lang/rust/issues/64102. Let's reflect this in the feature gate.

To avoid breaking all the benchmarks, libtest's `test::black_box` is a wrapping definition, not a reexport -- this means it is still under the `test` feature gate.
2021-04-25 10:35:24 +00:00
Paolo Barbolini
34e51279ab Fix 'const-stable since' of reverse_bits 2021-04-25 11:58:59 +02:00
Ralf Jung
23d54ad96f move core::hint::black_box under its own feature gate 2021-04-25 11:08:12 +02:00
bors
13a2615883 Auto merge of #84147 - cuviper:array-method-dispatch, r=nikomatsakis,m-ou-se
Cautiously add IntoIterator for arrays by value

Add the attribute described in #84133, `#[rustc_skip_array_during_method_dispatch]`, which effectively hides a trait from method dispatch when the receiver type is an array.

Then cherry-pick `IntoIterator for [T; N]` from #65819 and gate it with that attribute. Arrays can now be used as `IntoIterator` normally, but `array.into_iter()` has edition-dependent behavior, returning `slice::Iter` for 2015 and 2018 editions, or `array::IntoIter` for 2021 and later.

r? `@nikomatsakis`
cc `@LukasKalbertodt` `@rust-lang/libs`
2021-04-25 07:26:49 +00:00
KaiJewson
fbc2aadbfc Inline most raw socket, fd and handle conversions 2021-04-25 07:39:09 +01:00
Josh Stone
f6a90ca168 Ignore array IntoIterator tests in bootstrap 2021-04-24 22:33:51 -07:00
bors
5da10c0121 Auto merge of #84115 - CDirkx:rt, r=m-ou-se
Rework `init` and `cleanup`

This PR reworks the code in `std` that runs before and after `main` and centralizes this code respectively in the functions `init` and `cleanup` in both `sys_common` and `sys`. This makes is easy to see what code is executed during initialization and cleanup on each platform just by looking at e.g. `sys::windows::init`.

Full list of changes:
- new module `rt` in `sys_common` to contain `init` and `cleanup` and the runtime macros.
- `at_exit` and the mechanism to register exit handlers has been completely removed. In practice this was only used for closing sockets on windows and flushing stdout, which have been moved to `cleanup`.
- <s>On windows `alloc` and `net` initialization is now done in `init`, this saves a runtime check in every allocation and network use.</s>
2021-04-25 04:45:39 +00:00
Jubilee Young
a80dbea918 Clarify Duration::MAX depends on Instant
Duration is used in std to represent a difference between two Instants.
As such, it has to at least contain that span of time in it. However,
Instant can vary by platform. Thus, we should explain the impl of
Duration::MAX is sensitive to these vagaries of the platform.
2021-04-24 16:57:58 -07:00
bors
b56b175c6c Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obk
further split up const_fn feature flag

This continues the work on splitting up `const_fn` into separate feature flags:
* `const_fn_trait_bound` for `const fn` with trait bounds
* `const_fn_unsize` for unsizing coercions in `const fn` (looks like only `dyn` unsizing is still guarded here)

I don't know if there are even any things left that `const_fn` guards... at least libcore and liballoc do not need it any more.

`@oli-obk` are you currently able to do reviews?
2021-04-24 23:16:03 +00:00
Yuki Okushi
78306f03ef
Rollup merge of #84179 - CDirkx:dont_send_sync, r=m-ou-se
Explicitly implement `!Send` and `!Sync` for `sys::{Args, Env}`

Remove the field `_dont_send_or_sync_me: PhantomData<*mut ()>` in favor of an explicit implementation of `!Send` and `!Sync`.
2021-04-25 01:53:11 +09:00
Yuki Okushi
46b67ab0f9
Rollup merge of #84105 - WaffleLapkin:stabilize_array_from_ref, r=m-ou-se
stabilize `core::array::{from_ref,from_mut}` in `1.53.0`

I didn't get any response in https://github.com/rust-lang/rust/issues/77101#issuecomment-761831104, so I figured out I can try opening stabilization pr.

---

This PR stabilizes following functions:
```rust
// core::array
pub fn from_ref<T>(s: &T) -> &[T; 1];
pub fn from_mut<T>(s: &mut T) -> &mut [T; 1];
```

Functions are similar to already stabilized `core::slice::{`[`from_ref`](https://doc.rust-lang.org/std/slice/fn.from_ref.html),[`from_mut`](https://doc.rust-lang.org/std/slice/fn.from_mut.html)`}` and were unstable without any problems/questions for a while now.

---

resolves #77101

``@rustbot`` modify labels: +T-libs
2021-04-25 01:53:10 +09:00
Mara Bos
d86835281b Stabilize ordering_helpers. 2021-04-24 18:45:20 +02:00
Christiaan Dirkx
36e9382449 Reuse unix::path and unsupported::{io, thread_local_key} on hermit 2021-04-24 17:32:25 +02:00
Yuki Okushi
ed991a36b0
Rollup merge of #84489 - amorison:issue-83969-fix, r=yaahc
Mention FusedIterator case in Iterator::fuse doc

Using `fuse` on an iterator that incorrectly implements
`FusedIterator` does not fuse the iterator. This commit adds a
note about this in the documentation of this method to increase
awareness about this potential issue (esp. when relying on fuse
in unsafe code).

Closes #83969
2021-04-24 12:17:09 +09:00
Yuki Okushi
ed5646bfee
Rollup merge of #84453 - notriddle:waker-from-docs, r=cramertj
Document From implementations for Waker and RawWaker

CC #51430
2021-04-24 12:17:06 +09:00
Yuki Okushi
c00439f682
Rollup merge of #83990 - the8472:take-trusted-len, r=dtolnay
implement `TrustedRandomAccess` for `Take` iterator adapter

`TrustedRandomAccess` requires the iterator length to fit within `usize`. `take(n)` only constrains the upper bound of an iterator. So if the inner is `TrustedRandomAccess` (which already implies a finite length) then so can be `Take`.

```````@rustbot``````` label T-libs-impl
2021-04-24 12:17:01 +09:00
Yuki Okushi
9ada731c65
Rollup merge of #84444 - notriddle:num-docs-from-undocumented-items-toggle, r=yaahc
doc: Get rid of "[+] show undocumented items" toggle on numeric From impls

On most From implementations, the docstring is attached to the function. This is also how people have been [recommended] to do it.

Screenshots:

* [before](https://user-images.githubusercontent.com/1593513/115767662-323c5480-a35e-11eb-9918-98aba83e9183.png)
* [after](https://user-images.githubusercontent.com/1593513/115767675-35374500-a35e-11eb-964f-c28eeb6c807a.png)

[recommended]: https://github.com/rust-lang/rust/issues/51430#issuecomment-398322434
2021-04-24 03:44:12 +09:00
Yuki Okushi
ace3bd4f8b
Rollup merge of #84387 - CDirkx:poison, r=m-ou-se
Move `sys_common::poison` to `sync::poison`

`sys_common` should not contain publicly exported types, only platform-independent abstractions on top of `sys`, which `sys_common::poison` is not. There is thus no reason for the module to not live under `sync`.

Part of #84187.
2021-04-24 03:44:09 +09:00
Yuki Okushi
5b7c98676f
Rollup merge of #84248 - calebsander:refactor/vec-functions, r=Amanieu
Remove duplicated fn(Box<[T]>) -> Vec<T>

`<[T]>::into_vec()` does the same thing as `Vec::from::<Box<[T]>>()`, so they can be implemented in terms of each other. This was the previous implementation of `Vec::from()`, but was changed in #78461. I'm not sure what the rationale was for that change, but it seems preferable to maintain a single implementation.
2021-04-24 03:44:04 +09:00
Yuki Okushi
dcb4083ed9
Rollup merge of #80805 - camelid:iter-by_ref-example, r=steveklabnik
Improve `Iterator::by_ref` example

I split the example into two: one that fails to compile, and one that
works. I also made them identical except for the addition of `by_ref`
so we don't confuse readers with random differences.

cc `@steveklabnik,` who is the one that added the previous version of this example
2021-04-24 03:44:02 +09:00
Adrien Morison
21b3b27fe4 Mention FusedIterator case in Iterator::fuse doc
Using `fuse` on an iterator that incorrectly implements
`FusedIterator` does not fuse the iterator. This commit adds a
note about this in the documentation of this method to increase
awareness about this potential issue (esp. when relying on fuse
in unsafe code).
2021-04-23 19:13:27 +01:00
bors
cb81dc535c Auto merge of #82585 - TrolledWoods:master, r=dtolnay
Added CharIndices::offset function

The CharIndices iterator has a field internally called front_offset, that I think would be very useful to have access to.

You can already do something like ``char_indices.next().map(|(offset, _)| offset)``, but that is wordy, in addition to not handling the case where the iterator has ended, where you'd want the offset to be equal to the length.

I'm very new to the open source world and the rust repository, so I'm sorry if I missed a step or did something weird.
2021-04-23 02:48:13 +00:00
bors
f4a8cf0a00 Auto merge of #78681 - m-ou-se:binary-heap-retain, r=Amanieu
Improve rebuilding behaviour of BinaryHeap::retain.

This changes `BinaryHeap::retain` such that it doesn't always fully rebuild the heap, but only rebuilds the parts for which that's necessary.

This makes use of the fact that retain gives out `&T`s and not `&mut T`s.

Retaining every element or removing only elements at the end results in no rebuilding at all. Retaining most elements results in only reordering the elements that got moved (those after the first removed element), using the same logic as was already used for `append`.

cc `@KodrAus` `@sfackler` - We briefly discussed this possibility in the meeting last week while we talked about stabilization of this function (#71503).
2021-04-23 00:07:19 +00:00
Christiaan Dirkx
dc110af7fc Explicitly implement !Send and !Sync for sys::{Args, Env} 2021-04-23 00:15:35 +02:00
Michael Howell
60ff298070 Document From implementations for Waker and RawWaker 2021-04-22 14:16:33 -07:00
Michael Howell
c247055032 Get rid of "[+] show undocumented items" toggle on numeric From impls
On most From implementations, the docstring is attached to the
function. This is also how people have been [recommended] to do it.

Screenshots:

* [before](https://user-images.githubusercontent.com/1593513/115767662-323c5480-a35e-11eb-9918-98aba83e9183.png)
* [after](https://user-images.githubusercontent.com/1593513/115767675-35374500-a35e-11eb-964f-c28eeb6c807a.png)

[recommended]: https://github.com/rust-lang/rust/issues/51430#issuecomment-398322434
2021-04-22 11:51:05 -07:00
bors
5f1aeb52c2 Auto merge of #84440 - Dylan-DPC:rollup-0xjb8oi, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #84343 (Remove `ScopeTree::closure_tree`)
 - #84376 (Uses flex to fix formatting of h1 at any width)
 - #84377 (Followup to #83944)
 - #84396 (Update LLVM submodule)
 - #84402 (Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock`)
 - #84404 (Check for intrinsics before coercing to a function pointer)
 - #84413 (Remove `sys::args::Args::inner_debug` and use `Debug` instead)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-04-22 18:17:23 +00:00
Dylan DPC
d1f5fc6017
Rollup merge of #84413 - CDirkx:args_inner_debug, r=m-ou-se
Remove `sys::args::Args::inner_debug` and use `Debug` instead

This removes the method `sys::args::Args::inner_debug` on all platforms and implements `Debug` for `Args` instead.

I believe this creates a more natural API for the different platforms under `sys`: export a type `Args: Debug + Iterator + ...` vs. `Args: Iterator + ...` and with a method `inner_debug`.
2021-04-22 18:14:43 +02:00
Dylan DPC
aac5125da4
Rollup merge of #84402 - CDirkx:rwlock, r=dtolnay
Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock`

This moves `sys_common::rwlock::StaticRwLock`, `RWLockReadGuard` and `RWLockWriteGuard` to `sys::unix::rwlock`. They are already `#[cfg(unix)]` and don't need to be in `sys_common`.
2021-04-22 18:14:41 +02:00
Christiaan Dirkx
7171fec13f Remove Once from init 2021-04-22 18:00:18 +02:00
Christiaan Dirkx
e1b1081d2f Document that init and cleanup are not guaranteed to run 2021-04-22 18:00:18 +02:00
Christiaan Dirkx
8aeea227da Apply suggestions from review 2021-04-22 18:00:17 +02:00
Christiaan Dirkx
11445c10ab Move most init to sys::init 2021-04-22 18:00:12 +02:00
bors
ccf171242b Auto merge of #77704 - AnthonyMikh:slice_index_with_ops_bound_pair, r=m-ou-se
Implement indexing slices with pairs of core::ops::Bound<usize>

Closes #49976.

I am not sure about code duplication between `check_range` and `into_maybe_range`. Should be former implemented in terms of the latter? Also this PR doesn't address code duplication between `impl SliceIndex for Range*`.
2021-04-22 15:36:27 +00:00
Mara Bos
f5d72ab69b Add better test for BinaryHeap::retain. 2021-04-22 14:24:30 +02:00
Mara Bos
62226eecb6 Improve BinaryHeap::retain.
It now doesn't fully rebuild the heap, but only the parts that are
necessary.
2021-04-22 14:24:30 +02:00
Christiaan Dirkx
1a6de8450e Remove sys::args::Args::inner_debug and use Debug instead 2021-04-22 11:04:29 +02:00
Christiaan Dirkx
cf470197ad Move all cleanup to sys::cleanup 2021-04-22 10:44:44 +02:00
Christiaan Dirkx
5b30662741 Rework at_exit to cleanup 2021-04-22 10:34:48 +02:00
Christiaan Dirkx
9cabbd0afc Move sys_common::poison to sync::poison 2021-04-22 10:27:21 +02:00
Caleb Sander
f505d619c4 Remove duplicated fn(Box<[T]>) -> Vec<T> 2021-04-21 23:32:10 -04:00
Mohsen Zohrevandi
5d9eeff062 Ensure TLS destructors run before thread joins in SGX 2021-04-21 14:45:45 -07:00
Mara Bos
268d29d75d
Rollup merge of #84406 - m-ou-se:drop-delete-alias, r=dtolnay
Remove `delete` alias from `mem::drop`.

See https://github.com/rust-lang/rust/pull/81988#issuecomment-824168459 and https://github.com/rust-lang/rust/pull/81988#issuecomment-824213843
2021-04-21 23:06:24 +02:00
Mara Bos
49a5c80a3b
Rollup merge of #84390 - m-ou-se:make-debug-non-exhaustive-without-fields-a-little-bit-less-verbose, r=kennytm
Format `Struct { .. }` on one line even with `{:#?}`.

The result of `debug_struct("A").finish_non_exhaustive()` before this change:
```
A {
    ..
}
```
And after this change:
```
A { .. }
```

If there's any fields, the result stays unchanged:
```
A {
    field: value,
    ..
}
2021-04-21 23:06:21 +02:00
Mara Bos
d341851f94
Rollup merge of #84301 - r00ster91:patch-1, r=kennytm
Document that `index` and `index_mut` can panic

I thought this was noteworthy and I think a bit more explicitness does no harm.
2021-04-21 23:06:16 +02:00
Mara Bos
47886ead1f
Rollup merge of #84251 - RalfJung:non-zero-const-since, r=kennytm
fix 'const-stable since' for NonZeroU*::new_unchecked

For the unsigned `NonZero` types, `new_unchecked` was const-stable from the start with https://github.com/rust-lang/rust/pull/50808. Fix the docs to accurately reflect that.

I think this `since` is also incorrect:
```rust
            #[stable(feature = "from_nonzero", since = "1.31.0")]
            impl From<$Ty> for $Int {
```
The signed nonzero types were only stabilized in 1.34, so that `From` impl certainly didn't exist before. But I had enough of digging through git histories after I figured out when `new_unchecked` became const-stable...^^
2021-04-21 23:06:15 +02:00
Mara Bos
31b83802a4
Rollup merge of #84212 - CDirkx:void, r=m-ou-se
Replace `Void` in `sys` with never type

This PR replaces several occurrences in `sys` of the type `enum Void {}` with the Rust never type (`!`).
The name `Void` is unfortunate because in other languages (C etc.) it refers to a unit type, not an uninhabited type.

Note that the previous stabilization of the never type was reverted, however all uses here are implementation details and not publicly visible.
2021-04-21 23:06:14 +02:00
Mara Bos
3897ad1128
Rollup merge of #84119 - CDirkx:vxworks, r=m-ou-se
Move `sys::vxworks` code to `sys::unix`

Follow-up to #77666, `sys::vxworks` is almost identical to `sys::unix`, the only differences are the `rand`, `thread_local_dtor`, and `process` implementation. Since `vxworks` is `target_family = unix` anyway, there is no reason for the code not to live inside of `sys::unix` like all the other unix-OSes.

e41f378f82/compiler/rustc_target/src/spec/vxworks_base.rs (L12)

``@rustbot`` label: +T-libs-impl
2021-04-21 23:06:12 +02:00
Mara Bos
a7a7737114
Rollup merge of #84013 - CDirkx:fmt, r=m-ou-se
Replace all `fmt.pad` with `debug_struct`

This replaces any occurrence of:
- `f.pad("X")` with `f.debug_struct("X").finish()`
- `f.pad("X { .. }")` with `f.debug_struct("X").finish_non_exhaustive()`

This is in line with existing formatting code such as
1255053067/library/std/src/sync/mpsc/mod.rs (L1470-L1475)
2021-04-21 23:06:11 +02:00
Mara Bos
6763a40eff
Bump slice_index_with_ops_bound_pair to 1.53.0 2021-04-21 22:40:19 +02:00
Mara Bos
f1f3069a98 Remove delete alias from mem::drop. 2021-04-21 21:54:39 +02:00
Christiaan Dirkx
eb9b0f6ab7 Move sys_common::rwlock::StaticRWLock etc. to sys::unix::rwlock 2021-04-21 17:53:00 +02:00
Christiaan Dirkx
aa46f08abd Apply suggestions from code review 2021-04-21 16:06:32 +02:00
Christiaan Dirkx
fccc75cf82 Fix alloc::test::test_show 2021-04-21 15:45:41 +02:00
Christiaan Dirkx
fdae75738b Change the Debug impl of Any and UnsafeCell to use finish_non_exhaustive 2021-04-21 14:51:04 +02:00
Christiaan Dirkx
1fb3256fcb Replace all fmt.pad with debug_struct 2021-04-21 14:38:24 +02:00
Mara Bos
82dc73b1ae Format Struct { .. } on one line even with {:#?}. 2021-04-21 13:50:56 +02:00
Christiaan Dirkx
d45e1314f3 Change uses of never type 2021-04-20 20:53:07 +02:00
Christiaan Dirkx
389fef3b30 Replace Void with never type 2021-04-20 20:53:07 +02:00
Dylan DPC
9f03385499
Rollup merge of #84337 - matklad:insert_or_insert, r=jyn514
Clarify the difference between insert and get_or_insert

Took me a while to realize that the two are actually different.
2021-04-20 11:08:27 +02:00
Dylan DPC
761243572e
Rollup merge of #84291 - RalfJung:thread-local-const-init, r=alexcrichton
fix aliasing violations in thread_local_const_init

Fixes https://github.com/rust-lang/rust/pull/83416#discussion_r615364774

r? `@alexcrichton` `@sfackler`
2021-04-19 22:00:09 +02:00
Dylan DPC
fb78dc05e4
Rollup merge of #84256 - tspiteri:pretty-minus-zero, r=workingjubilee
doc: use U+2212 for minus sign in floating-point -0.0 remarks

Also remove plus sign in `-0.0 == +0.0` to make it a valid expression.
2021-04-19 22:00:08 +02:00
Aleksey Kladov
de16951dad Clarify the difference between insert and get_or_insert 2021-04-19 18:17:45 +03:00
bors
41f0e13bc5 Auto merge of #84294 - WaffleLapkin:patch-2, r=jonas-schievink
Slightly change wording in doc comment and fix typo in vec/mod.rs

Suggested by `@pickfire` in https://github.com/rust-lang/rust/pull/82760
2021-04-19 11:55:52 +00:00
Christiaan Dirkx
9bd9cbb28e Fix vxworks compilation errors 2021-04-19 13:29:35 +02:00
Christiaan Dirkx
12120409d5 Move sys::vxworks code to sys::unix 2021-04-19 13:29:22 +02:00
Folyd
33cc3f5116 Stablize {HashMap,BTreeMap}::into_{keys,values} 2021-04-19 14:23:35 +08:00
Trevor Spiteri
4c6477026d
Update library/std/src/primitive_docs.rs
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2021-04-19 02:58:38 +02:00
bors
5a4ab26459 Auto merge of #78880 - CDirkx:not_supported, r=joshtriplett
Add `Unsupported` to `std::io::ErrorKind`

I noticed a significant portion of the uses of `ErrorKind::Other` in std is for unsupported operations.
The notion that a specific operation is not available on a target (and will thus never succeed) seems semantically distinct enough from just "an unspecified error occurred", which is why I am proposing to add the variant `Unsupported` to `std::io::ErrorKind`.

**Implementation**:

The following variant will be added to `std::io::ErrorKind`:

```rust
/// This operation is unsupported on this platform.
Unsupported
```
`std::io::ErrorKind::Unsupported` is an error returned when a given operation is not supported on a platform, and will thus never succeed; there is no way for the software to recover. It will be used instead of `Other` where appropriate, e.g. on wasm for file and network operations.

`decode_error_kind` will be updated  to decode operating system errors to `Unsupported`:
- Unix and VxWorks: `libc::ENOSYS`
- Windows: `c::ERROR_CALL_NOT_IMPLEMENTED`
- WASI: `wasi::ERRNO_NOSYS`

**Stability**:
This changes the kind of error returned by some functions on some platforms, which I think is not covered by the stability guarantees of the std? User code could depend on this behavior, expecting `ErrorKind::Other`, however the docs already mention:

> Errors that are `Other` now may move to a different or a new `ErrorKind` variant in the future. It is not recommended to match an error against `Other` and to expect any additional characteristics, e.g., a specific `Error::raw_os_error` return value.

The most recent variant added to `ErrorKind` was `UnexpectedEof` in `1.6.0` (almost 5 years ago), but `ErrorKind` is marked as `#[non_exhaustive]` and the docs warn about exhaustively matching on it, so adding a new variant per se should not be a breaking change.

The variant `Unsupported` itself could be marked as `#[unstable]`, however, because this PR also immediately uses this new variant and changes the errors returned by functions I'm inclined to agree with the others in this thread that the variant should be insta-stabilized.
2021-04-18 20:03:54 +00:00
Ralf Jung
fbfaab2cb7 separate feature flag for unsizing casts in const fn 2021-04-18 19:11:29 +02:00
Ralf Jung
fdad6ab3a3 move 'trait bounds on const fn' to separate feature gate 2021-04-18 18:36:41 +02:00
r00ster
c86ffe9e89
Say that it "may panic" 2021-04-18 18:16:10 +02:00
r00ster
df01b3a67b
Document that index and index_mut can panic 2021-04-18 15:51:16 +02:00
Waffle Lapkin
3ecaf57b29
Slightly change wording and fix typo in vec/mod.rs 2021-04-18 12:32:10 +03:00
Ralf Jung
7a5418dae1 fix aliasing violations in thread_local_const_init 2021-04-18 10:55:09 +02:00
CDirkx
b42e52f2cc Bump to 1.53.0
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-04-18 09:29:24 +02:00
Christiaan Dirkx
0895a693bd Fix test metadata_access_times to also check for Unsupported 2021-04-18 09:29:24 +02:00
Christiaan Dirkx
af0dec2795 Rename NotSupported to Unsupported 2021-04-18 09:29:23 +02:00
Christiaan Dirkx
1b5f117c47 Use NotSupported in more places 2021-04-18 09:29:23 +02:00
CDirkx
86592b9939 Bump since to 1.52.0 2021-04-18 09:29:22 +02:00
Christiaan Dirkx
9f589b023f Update decode_error_kind to decode os errors to NotSupported 2021-04-18 09:29:22 +02:00
Christiaan Dirkx
4a15bd8eaf Add and insta-stabilize std::io::ErrorKind::NotSupported 2021-04-18 09:29:22 +02:00
bors
d7c3386414 Auto merge of #84207 - SimonSapin:deprecate-core-raw, r=dtolnay
Deprecate the core::raw / std::raw module

It only contains the `TraitObject` struct which exposes components of wide pointer. Pointer metadata APIs are designed to replace this: https://github.com/rust-lang/rust/issues/81513
2021-04-18 07:23:54 +00:00
bors
83ca4b7e60 Auto merge of #84061 - AngelicosPhosphoros:issue-75598-add-inline-always-arithmetic, r=nagisa
Add some #[inline(always)] to arithmetic methods of integers

I tried to add it only to methods which return results of intrinsics and don't have any branching.
Branching could made performance of debug builds (`-Copt-level=0`) worse.
Main goal of changes is allowing wider optimizations in `-Copt-level=1`.

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

r? `@nagisa`
2021-04-17 23:31:10 +00:00
Scott McMurray
1864970430 Add the try_trait_v2 library basics
No compiler changes as part of this -- just new unstable traits and impls thereof.

The goal here is to add the things that aren't going to break anything, to keep the feature implementation simpler in the next PR.
2021-04-17 11:58:18 -07:00
Josh Triplett
9aa4d068a1 Add documentation to help people find Ipv4Addr::UNSPECIFIED
People looking for `INADDR_ANY` don't always find
`Ipv4Addr::UNSPECIFIED`; add some documentation and an alias to help.
2021-04-16 13:18:04 -07:00
Trevor Spiteri
18955203d3 doc: use U+2212 for minus sign in floating-point -0.0 remarks
Also remove plus sign in `-0.0 == +0.0` to make it a valid expression.
2021-04-16 21:48:41 +02:00
Ralf Jung
9aa6c1e0c9 fix 'const-stable since' for NonZeroU*::new_unchecked 2021-04-16 20:35:14 +02:00
Josh Stone
c020367b82 Document the edition behavior for array.into_iter() 2021-04-16 11:12:01 -07:00
Josh Stone
3dab4e22d4 Skip into_iter() for arrays before 2021 2021-04-16 11:12:01 -07:00
Lukas Kalbertodt
35b1590223 Adjust docs and tests for new IntoIterator impl for arrays 2021-04-16 11:12:01 -07:00
Lukas Kalbertodt
32aaea9c8f Add IntoIterator impl for [T; N] (arrays by value) 2021-04-16 11:12:01 -07:00
bors
0cc00c48d2 Auto merge of #83416 - alexcrichton:const-thread-local, r=sfackler
std: Add a variant of thread locals with const init

This commit adds a variant of the `thread_local!` macro as a new
`thread_local_const_init!` macro which requires that the initialization
expression is constant (e.g. could be stuck into a `const` if so
desired). This form of thread local allows for a more efficient
implementation of `LocalKey::with` both if the value has a destructor
and if it doesn't. If the value doesn't have a destructor then `with`
should desugar to exactly as-if you use `#[thread_local]` given
sufficient inlining.

The purpose of this new form of thread locals is to precisely be
equivalent to `#[thread_local]` on platforms where possible for values
which fit the bill (those without destructors). This should help close
the gap in performance between `thread_local!`, which is safe, relative
to `#[thread_local]`, which is not easy to use in a portable fashion.
2021-04-16 16:36:46 +00:00
Alex Crichton
c6eea222a9 std: Add a variant of thread locals with const init
This commit adds a variant of the `thread_local!` macro as a new
`thread_local_const_init!` macro which requires that the initialization
expression is constant (e.g. could be stuck into a `const` if so
desired). This form of thread local allows for a more efficient
implementation of `LocalKey::with` both if the value has a destructor
and if it doesn't. If the value doesn't have a destructor then `with`
should desugar to exactly as-if you use `#[thread_local]` given
sufficient inlining.

The purpose of this new form of thread locals is to precisely be
equivalent to `#[thread_local]` on platforms where possible for values
which fit the bill (those without destructors). This should help close
the gap in performance between `thread_local!`, which is safe, relative
to `#[thread_local]`, which is not easy to use in a portable fashion.
2021-04-16 09:21:38 -07:00
Dylan DPC
a5ec5cf72a
Rollup merge of #84145 - vojtechkral:vecdeque-binary-search, r=m-ou-se
Address comments for vecdeque_binary_search #78021
2021-04-16 14:08:32 +02:00
bors
5e7bebad1d Auto merge of #84220 - gpluscb:weak_doc, r=jyn514
Correct outdated documentation for rc::Weak

This was overlooked in ~~#50357~~ #51901
2021-04-16 02:31:15 +00:00
Vojtech Kral
44be1c2aa0 VecDeque: Improve doc comments in binary search fns
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-04-15 23:23:46 +02:00
Vojtech Kral
e68680d30d VecDeque: Add partition_point() #78021 2021-04-15 23:23:23 +02:00
Vojtech Kral
bccbf9db1c VecDeque: binary_search_by(): return right away if hit found at back.first() #78021 2021-04-15 23:23:22 +02:00
Simon Sapin
4d683c0292 Allow use of deprecated std::raw in a test for that feature 2021-04-15 19:16:18 +02:00
bors
2962e7c008 Auto merge of #84209 - pickfire:patch-3, r=jyn514
Merge same condition branch in vec spec_extend

Follow up of https://github.com/rust-lang/rust/pull/83726#discussion_r613438246
2021-04-15 15:18:16 +00:00
MarRue
288bd49528 Correct outdated rc::Weak::default documentation 2021-04-15 14:54:39 +02:00
bors
f1ca558db1 Auto merge of #84088 - m-ou-se:stabilize-option-insert, r=m-ou-se
Stabilize option_insert.

FCP finished here: https://github.com/rust-lang/rust/issues/78271#issuecomment-817201319
2021-04-15 12:37:19 +00:00
bors
043d916076 Auto merge of #84198 - mlodato517:patch-1, r=jyn514
Fix small typo in Drop documentation
2021-04-15 04:08:33 +00:00
Ivan Tham
eeac70c567
Merge same condition branch in vec spec_extend 2021-04-15 11:58:02 +08:00
David Tolnay
e9bd80f961
Requires deprecated *and* deprecated_in_future, depending on what stage is building 2021-04-14 19:28:39 -07:00
David Tolnay
28efb22745
s/deprecated_in_future/deprecated/ 2021-04-14 18:44:22 -07:00
Simon Sapin
b80a96c286 Deprecate the core::raw / std::raw module
It only contains the `TraitObject` struct which exposes components
of wide pointer. Pointer metadata APIs are designed to replace this:
https://github.com/rust-lang/rust/issues/81513
2021-04-15 02:32:33 +02:00
Dylan DPC
d783f399e5
Rollup merge of #84177 - ehuss:join_paths-err, r=kennytm
Fix join_paths error display.

On unix, the error from `join_paths` looked like this:

```
path segment contains separator `58`
```

This PR changes it to look like this:

```
path segment contains separator `:`
```
2021-04-15 01:27:53 +02:00
Dylan DPC
80ee7cbb37
Rollup merge of #82492 - CDirkx:sys_common_alloc, r=m-ou-se
Move `std::sys_common::alloc` to new module `std::sys::common`

6b56603e35/library/std/src/sys_common/mod.rs (L7-L13)

It was my impression that the goal for `std::sys` has changed from extracting it into a separate crate to making std work with features. However the fact remains that there is a lot of interdependence between `sys` and `sys_common`, this is because `sys_common` contains two types of code:

- abstractions over the different platform implementations in `std::sys` (for example [`std::sys_common::mutex`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/mutex.rs))
- code shared between platforms (for example [`std::sys_common::alloc`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/alloc.rs))

This PR attempts to address this by adding a new module `common` to `std::sys` which will contain code shared between platforms, `alloc.rs` in this case but more can be moved over in the future.
2021-04-15 01:27:52 +02:00
Mark Lodato
46d2a96fac
Fix small typo in Drop documentation 2021-04-14 16:05:56 -04:00
bors
7537b20626 Auto merge of #83948 - ABouttefeux:lint-nullprt-deref, r=RalfJung
add lint deref_nullptr detecting when a null ptr is dereferenced

fixes #83856
changelog: add lint that detect code like
```rust
unsafe {
      &*core::ptr::null::<i32>()
 };
unsafe {
     addr_of!(std::ptr::null::<i32>())
};
let x: i32 = unsafe {*core::ptr::null()};
let x: i32 = unsafe {*core::ptr::null_mut()};
unsafe {*(0 as *const i32)};
unsafe {*(core::ptr::null() as *const i32)};
```
```
warning: Dereferencing a null pointer causes undefined behavior
 --> src\main.rs:5:26
  |
5 |     let x: i32 = unsafe {*core::ptr::null()};
  |                          ^^^^^^^^^^^^^^^^^^
  |                          |
  |                          a null pointer is dereferenced
  |                          this code causes undefined behavior when executed
  |
  = note: `#[warn(deref_nullptr)]` on by default
```

Limitation:
It does not detect code like
```rust
const ZERO: usize = 0;
unsafe {*(ZERO as *const i32)};
```
or code where `0` is not directly a literal
2021-04-14 18:04:22 +00:00
Christiaan Dirkx
cac0dd63b3 Update documentation 2021-04-14 14:03:00 +02:00
Christiaan Dirkx
905d23b65c Move std::sys_common::alloc to std::sys::common 2021-04-14 13:24:10 +02:00
Tyson Nottingham
01e701828c BufWriter: improve safety comment 2021-04-13 21:20:59 -07:00
Eric Huss
a8fbe2f22f Fix join_paths error display. 2021-04-13 14:20:49 -07:00
Cameron Steffen
b319031808 Remove slice diagnostic item 2021-04-13 15:41:13 -05:00