Commit graph

7514 commits

Author SHA1 Message Date
Matthew Woodcraft 6fa061c5f9 Document rounding for floating-point primitive operations
State that the four primitive operations honour IEEE 754 roundTiesToEven.

Documenting under "Primitive Type f32"; f64 refers to that.
2022-04-16 21:58:36 +01:00
Dylan DPC 4ed7627117
Rollup merge of #96081 - eduardosm:masks_usize_size_agnostic, r=yaahc
Make some `usize`-typed masks definitions agnostic to the size of `usize`

Some masks where defined as
```rust
const NONASCII_MASK: usize = 0x80808080_80808080u64 as usize;
```
where it was assumed that `usize` is never wider than 64, which is currently true.

To make those constants valid in a hypothetical 128-bit target, these constants have been redefined in an `usize`-width-agnostic way
```rust
const NONASCII_MASK: usize = usize::from_ne_bytes([0x80; size_of::<usize>()]);
```

There are already some cases where Rust anticipates the possibility of supporting 128-bit targets, such as not implementing `From<usize>` for `u64`.
2022-04-16 14:26:01 +02:00
Dylan DPC bd007ba928
Rollup merge of #96038 - beyarkay:patch-1, r=m-ou-se
docs: add link from zip to unzip

The docs for `Iterator::unzip` explain that it is kind of an inverse operation to `Iterator::zip` and guide the reader to the `zip` docs, but the `zip` docs don't let the user know that they can undo the `zip` operation with `unzip`. This change modifies the docs to help the user find `unzip`.
2022-04-16 14:25:58 +02:00
Dylan DPC f559cf98b5
Rollup merge of #96099 - clarfonthey:maybeuninit_array_cleanup, r=dtolnay
MaybeUninit array cleanup

* Links `MaybeUninit::uninit_array` to meta-tracking issue
* Links `MaybeUninit::array_assume_init` to meta-tracking issue
* Unstably constifies `MaybeUninit::array_assume_init`

Another thing worth mentioning: this splits the const feature flag for `maybe_uninit_uninit_array` into `const_maybe_uninit_uninit_array` to avoid weird cases where only one gets stabilised.

Note that it may be desired to keep the `array_assume_init` method linked to its dedicated issue, but at least for now, I decided to link to the meta-tracking issue so that all of the methods lead users to the same place. But I can revert that bit if desired.

The meta-tracking issue that I filed is #96097.
2022-04-16 07:12:49 +02:00
Dylan DPC 04ccba8728
Rollup merge of #96070 - Gumichocopengin8:test/btree-map, r=thomcc
[test] Add test cases for untested functions for BTreeMap

- add `pop_first()`, `pop_last()`, `get_key_value()` and `try_insert()` test cases
2022-04-16 07:12:48 +02:00
Dylan DPC ea131bca17
Rollup merge of #95961 - RalfJung:gather-scatter, r=workingjubilee
implement SIMD gather/scatter via vector getelementptr

Fixes https://github.com/rust-lang/portable-simd/issues/271

However, I don't *really* know what I am doing here... Cc ``@workingjubilee`` ``@calebzulawski``

I didn't do anything for cranelift -- ``@bjorn3`` not sure if it's okay for that backend to temporarily break. I'm happy to cherry-pick a patch that adds cranelift support. :)
2022-04-16 07:12:45 +02:00
ltdk 63a8652961 MaybeUninit array cleanup
* Links MaybeUninit::uninit_array to meta-tracking issue
* Links MaybeUninit::array_assume_init to meta-tracking issue
* Unstably constifies MaybeUninit::array_assume_init
2022-04-15 20:53:50 -04:00
bors bb1a03c4fc Auto merge of #95224 - mjbshaw:patch-1, r=yaahc
Optimize RcInnerPtr::inc_strong()/inc_weak() instruction count

Inspired by this internals thread: https://internals.rust-lang.org/t/rc-optimization-on-64-bit-targets/16362

[The generated assembly is a bit smaller](https://rust.godbolt.org/z/TeTnf6144) and is a more efficient usage of the CPU's instruction cache. `unlikely` doesn't impact any of the small artificial tests I've done, but I've included it in case it might help more complex scenarios when this is inlined.
2022-04-15 23:15:51 +00:00
Dylan DPC aa978addb3
Rollup merge of #96040 - m-ou-se:futex-u32, r=Amanieu
Use u32 instead of i32 for futexes.

This changes futexes from i32 to u32. The [Linux man page](https://man7.org/linux/man-pages/man2/futex.2.html) uses `uint32_t` for them, so I'm not sure why I used i32 for them. Maybe because I first used them for thread parkers, where I used -1, 0, and 1 as the states.

(Wasm's `memory.atomic.wait32` does use `i32`, because wasm doesn't support `u32`.)

It doesn't matter much, but using the unsigned type probably results in fewer surprises when shifting bits around or using comparison operators.

r? ```@Amanieu```
2022-04-15 20:50:50 +02:00
Dylan DPC 224afadb3b
Rollup merge of #96034 - Gumichocopengin8:test/btree-set, r=Dylan-DPC
[test] Add test cases of untested functions for BTreeSet

- add [`is_superset()`](https://doc.rust-lang.org/std/collections/struct.BTreeSet.html#method.is_superset) and [`remove()`](https://doc.rust-lang.org/std/collections/struct.BTreeSet.html#method.remove) test cases for BTreeSet since these functions has no test cases.
2022-04-15 20:50:49 +02:00
Dylan DPC 20bf34f8c5
Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelix
Create (unstable) 2024 edition

[On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition.

This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024.

For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical.

````@rustbot```` label +T-lang +S-waiting-on-review

Not sure on the relevant team, to be honest.
2022-04-15 20:50:43 +02:00
Dylan DPC 27e2d811e6
Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwco
Stabilize `derive_default_enum`

This stabilizes `#![feature(derive_default_enum)]`, as proposed in [RFC 3107](https://github.com/rust-lang/rfcs/pull/3107) and tracked in #87517. In short, it permits you to `#[derive(Default)]` on `enum`s, indicating what the default should be by placing a `#[default]` attribute on the desired variant (which must be a unit variant in the interest of forward compatibility).

```````@rustbot``````` label +S-waiting-on-review +T-lang
2022-04-15 20:50:43 +02:00
bors 1e6fe5855a Auto merge of #94079 - petrochenkov:cstr, r=joshtriplett
library: Move `CStr` to libcore, and `CString` to liballoc

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

Interesting points:
- Stability:
    - To make `CStr(ing)` from libcore/liballoc unusable without enabling features I had to make these structures unstable, and reexport them from libstd using stable type aliases instead of `pub use` reexports. (Because stability of `use` items is not checked.)
- Relying on target ABI in libcore is ok:
    - https://github.com/rust-lang/rust/pull/94079#issuecomment-1044263371
- `trait CStrExt` (UPDATE: used only in `cfg(bootstrap)` mode, otherwise lang items are used instead)
    - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450
- `strlen`
    - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450

Otherwise it's just a code move + some minor hackery usual for liballoc in `cfg(test)` mode.
2022-04-15 15:47:17 +00:00
Eduardo Sánchez Muñoz 93ae6f80e3 Make some usize-typed masks definition agnostic to the size of usize
Some masks where defined as
```rust
const NONASCII_MASK: usize = 0x80808080_80808080u64 as usize;
```
where it was assumed that `usize` is never wider than 64, which is currently true.

To make those constants valid in a hypothetical 128-bit target, these constants have been redefined in an `usize`-width-agnostic way
```rust
const NONASCII_MASK: usize = usize::from_ne_bytes([0x80; size_of::<usize>()]);
```

There are already some cases where Rust anticipates the possibility of supporting 128-bit targets, such as not implementing `From<usize>` for `u64`.
2022-04-15 17:04:59 +02:00
bors 69a5ae35fe Auto merge of #95841 - ChrisDenton:pipe-server, r=m-ou-se
Windows: Use a pipe relay for chaining pipes

Fixes #95759

This fixes the issue by chaining pipes synchronously and manually pumping messages between them. It's not ideal but it has the advantage of not costing anything if pipes are not chained ("don't pay for what you don't use") and it also avoids breaking existing code that rely on our end of the pipe being asynchronous (which includes rustc's own testing framework).

Libraries can avoid needing this by using their own pipes to chain commands.
2022-04-15 13:19:25 +00:00
Keita Nonaka 3f46ba6028 chore: formatting 2022-04-15 01:30:05 -07:00
Keita Nonaka 3f2f4a35ed test: add try_insert() test cases for BTreeSet 2022-04-15 01:12:00 -07:00
Keita Nonaka e1626020d3 test: add get_key_value() test cases for BTreeSet 2022-04-15 00:04:03 -07:00
Keita Nonaka 4117e8c2d3 test: add pop_first() pop_last() test cases for BTreeSet 2022-04-14 23:40:05 -07:00
Vadim Petrochenkov 6eaec56ef7 library: Remove definitions and reexports of strlen from libstd 2022-04-14 21:57:01 +03:00
Vadim Petrochenkov afa2e6f2ff Fix targets not supporting target_has_atomic = "ptr" 2022-04-14 21:53:11 +03:00
Vadim Petrochenkov 7f3cc2fbbf library: Use type aliases to make CStr(ing) in libcore/liballoc unstable 2022-04-14 21:53:11 +03:00
Vadim Petrochenkov 5bee741a08 library: Move CStr to libcore, and CString to liballoc 2022-04-14 21:53:11 +03:00
Mara Bos 7a35c0f52d Use u32 instead of i32 for futexes. 2022-04-14 11:44:12 +02:00
Boyd Kane d73e32867f
Remove trailing whitespace
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2022-04-14 11:19:49 +02:00
Boyd Kane f6d957701f
docs: add link from zip to unzip
The docs for `Iterator::unzip` explain that it is kind of an inverse operation to `Iterator::zip` and guide the reader to the `zip` docs, but the `zip` docs don't let the user know that they can undo the `zip` operation with `unzip`. This change modifies the docs to help the user find `unzip`.
2022-04-14 09:51:47 +02:00
Keita Nonaka 50c339e8f5 test: add remove() test cases for BTreeSet 2022-04-13 22:19:08 -07:00
Keita Nonaka 21d3f8444a test: add is_superset test cases for BTreeSet 2022-04-13 22:09:03 -07:00
bors dc4bfcbdff Auto merge of #95958 - jhpratt:bump-stdarch, r=Dylan-DPC
Update stdarch

library/stdarch bcbe0106...d215afe9 (7):
  - Add the rdm target feature to the sqrdmlsh intrinsic. (rust-lang/stdarch#1285)
  - Remove use of `#[rustc_deprecated]`
  - Remove feature gates for stabilized features
  - Change remaining _undefined_ functions to zero-init
  - Use SPDX license format and update packed_simd crate link (rust-lang/stdarch#1297)
  - Fix broken links (rust-lang/stdarch#1294)
  - Import the asm macro in std_detect (rust-lang/stdarch#1290)
2022-04-13 18:44:35 +00:00
bors 0d13f6afeb Auto merge of #96015 - Dylan-DPC:rollup-vhdprid, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #93217 (Improve Rustdoc UI for scraped examples with multiline arguments, fix overflow in line numbers)
 - #95885 (Improve error message in case of missing checksum)
 - #95962 (Document that DirEntry holds the directory open)
 - #95991 (fix: wrong trait import suggestion for T:)
 - #96005 (Add missing article to fix "few" to "a few".)
 - #96006 (Add a missing article)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-13 16:04:06 +00:00
Dylan DPC e95f2db98f
Rollup merge of #96006 - hkBst:patch-2, r=Dylan-DPC
Add a missing article

Add a missing article
2022-04-13 17:35:37 +02:00
Dylan DPC e8050c0b0a
Rollup merge of #96005 - hkBst:patch-1, r=Dylan-DPC
Add missing article to fix "few" to "a few".

Add missing article to fix "few" (not many) to "a few" (some).
2022-04-13 17:35:35 +02:00
Dylan DPC 032358bd30
Rollup merge of #95962 - sourcefrog:doc-direntry, r=Dylan-DPC
Document that DirEntry holds the directory open

I had a bug where holding onto DirEntry structs caused file descriptor exhaustion, and thought it would be good to document this.
2022-04-13 17:35:33 +02:00
bors ab33f71a8b Auto merge of #95727 - m-ou-se:futex-reentrantmutex, r=Amanieu
Replace ReentrantMutex by a futex-based one on Linux.

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

r? `@Amanieu`
2022-04-13 13:42:19 +00:00
Marijn Schouten c008d45187
Add a missing article
Add a missing article
2022-04-13 13:33:09 +02:00
Marijn Schouten 212e98bc3e
Add missing article to fix "few" to "a few".
Add missing article to fix "few" (not many) to "a few" (some).
2022-04-13 13:24:28 +02:00
Dylan DPC 633c391225
Rollup merge of #95984 - wcampbell0x2a:fix-spelling, r=thomcc
Fix spelling in docs for `can_not_overflow`

Introduced in https://github.com/rust-lang/rust/pull/95399
2022-04-13 05:54:13 +02:00
Dylan DPC 6aa875aa96
Rollup merge of #95914 - c410-f3r:meta-vars, r=petrochenkov
Implement tuples using recursion

Because it is c00l3r™, requires less repetition and can be used as a reference for external people.

This change is non-essential and I am not sure about potential performance impacts so feel free to close this PR if desired.

r? `@petrochenkov`
2022-04-12 23:16:58 +02:00
Caio 23bf977758 Implement tuples using recursion 2022-04-12 16:23:36 -03:00
wcampbell 9ea89e1d3d Fix spelling in docs for can_not_overflow 2022-04-12 13:29:56 -04:00
Ralf Jung e886dc52ee portable-simd: use simd_arith_offset to avoid ptr-int transmutation 2022-04-12 11:09:26 -04:00
fee1-dead 1d76dd9ee7
Rollup merge of #95947 - cuviper:default-box, r=dtolnay
`impl const Default for Box<[T]>` and `Box<str>`

The unstable `const_default_impls` (#87864) already include empty `Vec<T>` and `String`. Now we extend that concept to `Box<[T]>` and `Box<str>` as well.

This obviates a hack in `rustc_ast`'s `P::<[T]>::new`.
2022-04-12 22:44:45 +10:00
fee1-dead cdbdf1ef2e
Rollup merge of #95900 - o01eg:fix-wasm-doc, r=Mark-Simulacrum
Fix documentation for wasm32-unknown-unknown

Fixes https://github.com/rust-lang/rust/issues/76526#issuecomment-1094208720
2022-04-12 22:44:44 +10:00
Mara Bos d4e44a6391 Add missing unsafe marker.
This is now necessary because of deny(unsafe_op_in_unsafe_fn).
2022-04-12 08:44:39 +02:00
Mara Bos 8a2c9a9615 Allow cvt_nz to be unused on some platforms. 2022-04-12 08:44:39 +02:00
Mara Bos 5b2591299a Add #[deny(unsafe_op_in_unsafe_fn)] to thread_local!(const).
This avoids 'unused unsafe' warnings when using this feature inside std.
2022-04-12 08:44:39 +02:00
Mara Bos 83e8b9e4dd Add debug asserts to futex ReentrantMutex impl. 2022-04-12 08:44:39 +02:00
Mara Bos 43651aa34f Initialize thread local with const{}. 2022-04-12 08:44:39 +02:00
Mara Bos 319a9b0f71 Move current_thread_unique_ptr to the only module that uses it. 2022-04-12 08:44:39 +02:00
Mara Bos ebebe6f837 Make current_thread_unique_ptr work during thread destruction.
Otherwise we can't use println!() within atexit handlers etc.
2022-04-12 08:44:38 +02:00