Commit graph

3773 commits

Author SHA1 Message Date
Christiaan Dirkx
1a6de8450e Remove sys::args::Args::inner_debug and use Debug instead 2021-04-22 11:04:29 +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
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
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
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
Eric Huss
a8fbe2f22f Fix join_paths error display. 2021-04-13 14:20:49 -07:00
bors
5c1304205b Auto merge of #84135 - rust-lang:GuillaumeGomez-patch-1, r=kennytm
Improve code example for length comparison

Small fix/improvement: it's much safer to check that you're under the length of an array rather than chacking that you're equal to it. It's even more true in case you update the length of the array while iterating.
2021-04-13 14:03:49 +00:00
Dylan DPC
cf67c9bbf7
Rollup merge of #84121 - workingjubilee:stabilize-btree-retain, r=dtolnay
Stabilize BTree{Map,Set}::retain

Closes #79025.
FCP concluded here: https://github.com/rust-lang/rust/issues/79025#issuecomment-817201302

This is an approved feature on BTree{Map,Set} to mirror a functionality in Hash{Map,Set}, which has had some adequate testing since its introduction in https://github.com/rust-lang/rust/pull/79026 and doesn't seem to have caused any problems since.
2021-04-13 11:10:42 +02:00
Dylan DPC
3d6a364e33
Rollup merge of #84084 - m-ou-se:stabilize-zero, r=scottmcm
Stabilize duration_zero.

FCP here: https://github.com/rust-lang/rust/issues/73544#issuecomment-817201305
2021-04-13 11:10:40 +02:00
Dylan DPC
1cc4b6de3e
Rollup merge of #83707 - exrook:unsafecell, r=m-ou-se
Remove `T: Debug` bound on UnsafeCell Debug impl

Prior art: #65013
2021-04-13 11:10:39 +02:00
bors
23aef90b4e Auto merge of #84086 - m-ou-se:stabilze-is-subnormal, r=dtolnay
Stabilize is_subnormal.

FCP completed here: https://github.com/rust-lang/rust/issues/79288#issuecomment-817201311
2021-04-13 05:59:10 +00:00
bors
7ce470fd9b Auto merge of #84082 - andjo403:stabilize_nonzero_leading_trailing_zeros, r=m-ou-se
Stabilize nonzero_leading_trailing_zeros

Stabilizing nonzero_leading_trailing_zeros and due to this also stabilizing the intrinsic cttz_nonzero

FCP finished here: https://github.com/rust-lang/rust/issues/79143#issuecomment-817216153
`@rustbot` modify labels: +T-libs

Closes #79143
2021-04-13 03:18:10 +00:00
bors
d4d7ebf142 Auto merge of #82992 - philippeitis:stabilize_bufreader_seek_relative, r=workingjubilee
Stabilize `bufreader_seek_relative`

This PR marks `BufReader::seek_relative` as stable - the associated issue, #31100, has passed the final comment period without any issues, and from what I understand, the only thing left to stabilize this is to submit a PR marking the method as stable.

Closes #31100.
2021-04-13 00:52:00 +00:00
bors
11d0528483 Auto merge of #82918 - Manishearth:edition-2015-warn, r=oli-obk
Turn old edition lint (anonymous-parameters) into warn-by-default on 2015

This makes `anonymous_parameters` <s>and `keyword_idents` </s>warn-by-default on the 2015 edition. I would also like to do this for `absolute_paths_not_starting_with_crate`, but I feel that case is slightly less clear-cut.

Note that this only affects code on the 2015 edition, such code is illegal in future editions anyway.

This was spurred by https://github.com/dtolnay/syn/issues/972: old edition syntax breaks tooling (like syn), and while the tooling should be free to find its balance on how much to support prior editions, it does seem like we should be nudging such code towards the newer edition, and we can do that by turning this Allow lint into a Warn.

In general, I feel like migration lints from an old edition should be made Warn after a year or so, and idiom lints for the new edition should be made Warn after a couple months.

cc `@m-ou-se,` this is for stuff from the 2015-2018 migration but you might be interested.
2021-04-12 22:26:15 +00:00
bors
d0695c9081 Auto merge of #83776 - jyn514:update-stdarch-docs, r=Amanieu
Update stdarch submodule (to before it switched to const generics)

https://github.com/rust-lang/rust/pull/83278#issuecomment-812389823: This unblocks #82539.

Major changes:
- More AVX-512 intrinsics.
- More ARM & AArch64 NEON intrinsics.
- Updated unstable WASM intrinsics to latest draft standards.
- std_detect is now a separate crate instead of a submodule of std.

I double-checked and the first use of const generics looks like 8d5017861e, which isn't included in this PR.

r? `@Amanieu`
2021-04-12 18:29:25 +00:00
Guillaume Gomez
b89c464bed
Improve code example for length comparison 2021-04-12 19:59:52 +02:00
Manish Goregaokar
664c3e71b8 Turn old edition lints (anonymous-parameters, keyword-idents) into warn-by-default on 2015 2021-04-12 09:45:59 -07:00
Mara Bos
b44ae964e2 Mark Duration::is_zero as rustc_const_stable. 2021-04-12 16:32:57 +02:00
Mara Bos
d1e23b8af8 Stabilize duration_zero. 2021-04-12 16:32:56 +02:00
Joshua Nelson
1b0b7e95be Update stdarch submodule (to before it switched to const generics)
This also includes a cherry-pick of
ec1461905b
and https://github.com/rust-lang/stdarch/pull/1108 to fix a build
failure.

It also adds a re-export of various macros to the crate root of libstd -
previously they would show up automatically because std_detect was defined
in the same crate.
2021-04-12 09:39:04 -04:00
bors
5e73bd1040 Auto merge of #82300 - andersk:libtest-id, r=Amanieu
libtest: Index tests by a unique TestId

This more robustly avoids problems with duplicate `TestDesc`. See #81852 and #82274.

Cc `@Mark-Simulacrum.`
2021-04-12 13:30:30 +00:00