Commit Graph

12675 Commits

Author SHA1 Message Date
Ben Kimock
2820568c2d Add #[inline] to some recalcitrant ops::range methods 2023-10-22 00:29:45 -04:00
Gimbles
695beca219
Update boxed.rs 2023-10-21 23:41:32 +05:30
Matthias Krüger
90671a0d70
Rollup merge of #114521 - devnexen:std_fbsd_13_upd, r=cuviper
std: freebsd build update.

since freebsd 11 had been removed, minimum is now 12.
2023-10-21 10:08:15 +02:00
David Carlier
f4791420ab changes from feedback 2023-10-20 23:55:14 +01:00
Oli Scherer
3beadb5ebd Fix stage0 core tests 2023-10-20 21:14:02 +00:00
Oli Scherer
e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
60956837cf s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
Chris Denton
46f68ccb8b
Skip test if Unix sockets are unsupported 2023-10-20 18:10:34 +01:00
Ralf Jung
98d54da1ee document that the null pointer has the 0 address 2023-10-20 19:10:20 +02:00
bors
7db4a89d49 Auto merge of #116966 - clarfonthey:atomic-docs-typo, r=workingjubilee
Fix typo in atomic docs

Maybe rustdoc or tidy should lint hanging backticks like this.
2023-10-20 14:56:08 +00:00
David CARLIER
9a963e8026 std: freebsd build update.
since freebsd 11 had been removed, minimum is now 12.
2023-10-20 14:59:13 +01:00
ltdk
b9c2d0e4ab Fix typo in atomic docs 2023-10-20 00:57:29 -04:00
bors
029d00c4a3 Auto merge of #116785 - nnethercote:spec-Bytes-read, r=the8472
Specialize `Bytes<R>::next` when `R` is a `BufReader`.

This reduces the runtime for a simple program using `Bytes::next` to iterate through a file from 220ms to 70ms on my Linux box.

r? `@the8472`
2023-10-20 04:01:07 +00:00
Nicholas Nethercote
181ce63183 Specialize Bytes<R>::next when R is a BufReader.
This reduces the runtime for a simple program using `Bytes::next` to
iterate through a file from 220ms to 70ms on my Linux box.
2023-10-20 08:52:56 +11:00
bors
3fbcfd2b6f Auto merge of #116132 - darthunix:connect_poll, r=cuviper
Make TCP connect handle EINTR correctly

According to the [POSIX](https://pubs.opengroup.org/onlinepubs/009695399/functions/connect.html) standard, if connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to EINTR, but the connection request shall not be aborted, and the connection shall be established asynchronously. When the connection has been established asynchronously, select() and poll() shall indicate that the file descriptor for the socket is ready for writing.

The previous implementation differs from the recomendation: in a case of the EINTR we tried to reconnect in a loop and sometimes get EISCONN error (this problem was originally detected on MacOS).

1. More details about the problem in an [article](http://www.madore.org/~david/computers/connect-intr.html).
2. The original [issue](https://git.picodata.io/picodata/picodata/tarantool-module/-/issues/157).
2023-10-19 11:22:28 +00:00
bors
36b61e5aa5 Auto merge of #116923 - fmease:rollup-ev7q387, r=fmease
Rollup of 7 pull requests

Successful merges:

 - #116663 (Don't ICE when encountering unresolved regions in `fully_resolve`)
 - #116761 (Fix podman detection in CI scripts)
 - #116795 (Add `#[track_caller]` to `Option::unwrap_or_else`)
 - #116829 (Make `#[repr(Rust)]` incompatible with other (non-modifier) representation hints like `C` and `simd`)
 - #116883 (Change my name in mailmap)
 - #116908 (Tweak wording of type errors involving type params)
 - #116912 (Some renaming nits for `rustc_type_ir`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-19 03:52:32 +00:00
León Orell Valerian Liehr
80c9588549
Rollup merge of #116795 - DaniPopes:track-caller-option, r=cuviper
Add `#[track_caller]` to `Option::unwrap_or_else`

Same as #116317 but for `Option`.

Closes #115302
2023-10-19 04:34:46 +02:00
bors
020d00867a Auto merge of #114534 - niluxv:strict_prov_unwind, r=cuviper,workingjubilee
Strict provenance unwind

1. Turned many `usize`s in the personality/unwind code that are actually pointers into `*const u8`.
2. Rewrote `read_encoded_pointer` to conform to strict-provenance, along the lines as described by `@eddyb` [in zulip some time ago](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/strict.20provenance.20in.20dwarf.3A.3Aeh/near/276197290).

This should make supporting CHERI in the future easier (but they use a [slightly modified format in the callsite table](https://cheri-compiler-explorer.cl.cam.ac.uk/z/n6GhhW), which requires a CHERI specific modification to `find_eh_action`).
2023-10-19 01:56:45 +00:00
bors
89432aadcb Auto merge of #116402 - joboet:global_alloc_tls_unsoundness, r=thomcc,workingjubilee
Panic when the global allocator tries to register a TLS destructor

Using a `RefCell` avoids the undefined behaviour encountered in #116390 and reduces the amount of `unsafe` code in the codebase.
2023-10-19 00:03:42 +00:00
Joshua Liebow-Feeser
3fea7cc7da
Guarantee that char has the same size and alignment as u32 2023-10-18 09:14:31 -07:00
Ali MJ Al-Nasrawy
a536d58607
Rollup merge of #116856 - oli-obk:no_effects, r=compiler-errors
Disable effects in libcore again

r? `@fee1-dead`

This was accidentally allowed by https://github.com/rust-lang/rust/pull/114776 without feature gates
2023-10-18 14:24:51 +03:00
Ben Kimock
33b0e4be06 Automatically enable cross-crate inlining for small functions 2023-10-17 19:53:51 -04:00
Slanterns
10e6372a83
Stabilize result_option_inspect 2023-10-18 07:35:23 +08:00
Oli Scherer
bcdd3d7739 Disable effects in libcore again 2023-10-17 17:55:49 +00:00
bors
93e62a260f Auto merge of #115577 - RalfJung:atomic-load, r=Amanieu
document when atomic loads are guaranteed read-only

Based on this [discussion in Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Can.20.60Atomic*.3A.3Aload.60.20perform.20a.20write).

The values for x86 and x86_64 are complete guesswork on my side, and I have no clue what the values might be for other architectures. I hope we can get the right people to chime in to gather the required information. :)

I'll update Miri to respect these rules once we have more data.
2023-10-17 14:11:31 +00:00
bors
2e57d647b0 Auto merge of #116518 - vita-rust:vita, r=workingjubilee
Updated libc and doc for Vita target

Doc changes:

- Updated Vita target readme. The recommended approach to build artifacts for the platform now is [cargo-vita](https://crates.io/crates/cargo-vita) which wraps all the convoluted steps previously described in a yaml for `cargo-make`
- Updated maintainer list for Vita target. (`@ZetaNumbers` `@pheki` please agree to be added to the list, `@amg98` please let us know if you're still planning on actively maintaining target support)

Code changes:
- ~Updated libc for rust-lang/libc#3284 and rust-lang/libc#3366~ (Already merged in #116527)
- In dupfd changed the flag same as for esp target, there is no CLOEXEC on Vita
- Enabled `new_pair` since we've implemented `socketpair` in Vita newlib
2023-10-17 10:22:14 +00:00
Nikolay Arhipov
ba13e37e30 Updated libc and doc for Vita target 2023-10-17 10:44:39 +03:00
Ralf Jung
e494df436d remove 128bit atomics, they are anyway not exposed on those targets 2023-10-17 07:56:49 +02:00
bors
64338796ab Auto merge of #116820 - GuillaumeGomez:rollup-l54ri5q, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #116754 (coverage: Several small cleanups in `spans`)
 - #116798 (Improve display of parallel jobs in rustdoc-gui tester script)
 - #116800 (Fix implied outlives check for GAT in RPITIT)
 - #116805 (Make `rustc_onunimplemented` export path agnostic)
 - #116808 (Add myself to smir triage)
 - #116811 (Preserve unicode escapes in format string literals when pretty-printing AST)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-16 23:01:20 +00:00
Chris Denton
3733316c6b
Create windows/api.rs for safer FFI 2023-10-16 20:04:54 +01:00
Nilstrieb
414135d522 Make rustc_onunimplemented export path agnostic
This makes it so that all the matchers that match against paths use the
definition path instead of the export path. This removes all duplication
around `std`/`alloc`/`core`.

This is not necessarily optimal because we now depend on internal
implementation details like `core::ops::control_flow::ControlFlow`,
which is not very nice and probably not acceptable for a stable
`on_unimplemented`.

An alternative would be to just string-replace normalize away
`alloc`/`core` to `std` as a special case, keeping the export paths but
making it so that we're still fully standard library flavor agnostic.
2023-10-16 19:37:12 +02:00
Ralf Jung
6605116463 use target-arch based table 2023-10-16 19:29:16 +02:00
Arthur Carcano
0bcac8a7f2 Add invariant to Vec::pop that len < cap if pop successful
Fixes: https://github.com/rust-lang/rust/issues/114334
2023-10-16 18:49:25 +02:00
DaniPopes
0df670fb67
Add #[track_caller] to Option::unwrap_or_else 2023-10-16 15:17:15 +02:00
bors
9ace9da2e0 Auto merge of #116782 - matthiaskrgr:rollup-t3yrgku, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #115196 (Suggest adding `return` if the for semi which can coerce to the fn return type)
 - #115955 (Stabilize `{IpAddr, Ipv6Addr}::to_canonical`)
 - #116776 (Enable `review-requested` feature for rustbot)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-16 06:02:25 +00:00
Matthias Krüger
17113f7db6
Rollup merge of #115955 - tgross35:ip-to-canonical, r=dtolnay
Stabilize `{IpAddr, Ipv6Addr}::to_canonical`

Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable (+const), as well as const stabilize `Ipv6Addr::to_ipv4_mapped`.

Newly stable API:

```rust
impl IpAddr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;
}

impl Ipv6Addr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;

    // Already stable, this makes it const stable under
    // `const_ipv6_to_ipv4_mapped`
    const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>
}
```

These stabilize a subset of the following tracking issues:

- https://github.com/rust-lang/rust/issues/27709
- https://github.com/rust-lang/rust/issues/76205

Stabilization of all methods under the `ip` gate was attempted once at https://github.com/rust-lang/rust/pull/66584 then again at https://github.com/rust-lang/rust/pull/76098. These were not successful because there are still unknowns about `is_documentation` `is_benchmarking` and similar; `to_canonical` is much more straightforward.

I have looked and could not find any known issues with `to_canonical`. These were added in 2021 in https://github.com/rust-lang/rust/pull/87708

cc implementor ``@the8472``

r? libs-api
``@rustbot`` label +T-libs-api +needs-fcp
2023-10-16 06:26:20 +02:00
bors
99592fdfa1 Auto merge of #116775 - nnethercote:inline-Bytes-next, r=the8472
Inline `Bytes::next` and `Bytes::size_hint`.

This greatly increases its speed. On one small test program using `Bytes::next` to iterate over a large file, execution time dropped from ~330ms to ~220ms.

r? `@the8472`
2023-10-16 04:05:32 +00:00
bors
58352c0649 Auto merge of #114589 - ijackson:exit-code-default, r=dtolnay
impl Default for ExitCode

As suggested here
  https://github.com/rust-lang/rust/pull/106425#issuecomment-1382952598

Needs FCP since this is an insta-stable impl.

Ideally we would have `impl From<ExitCode> for ExitStatus` and implement the default `ExitStatus` using that.   That is sadly not so easy because of the various strange confusions about `ExitCode` (unix: exit status) vs `ExitStatus` (unix: wait status) in the not-really-unix platforms in `library//src/sys/unix/process`.  I'll try to follow that up.
2023-10-16 02:06:01 +00:00
bors
30d310cc1f Auto merge of #113747 - clarfonthey:ip_bitops, r=dtolnay
impl Not, Bit{And,Or}{,Assign} for IP addresses

ACP: rust-lang/libs-team#235

Note: since these are insta-stable, these require an FCP.

Implements, where `N` is either `4` or `6`:

```rust
impl Not for IpvNAddr
impl Not for &IpvNAddr

impl BitAnd<IpvNAddr> for IpvNAddr
impl BitAnd<&IpvNAddr> for IpvNAddr
impl BitAnd<IpvNAddr> for &IpvNAddr
impl BitAnd<&IpvNAddr> for &IpvNAddr

impl BitAndAssign<IpvNAddr> for IpvNAddr
impl BitAndAssign<&IpvNAddr> for IpvNAddr

impl BitOr<IpvNAddr> for IpvNAddr
impl BitOr<&IpvNAddr> for IpvNAddr
impl BitOr<IpvNAddr> for &IpvNAddr
impl BitOr<&IpvNAddr> for &IpvNAddr

impl BitOrAssign<IpvNAddr> for IpvNAddr
impl BitOrAssign<&IpvNAddr> for IpvNAddr
```
2023-10-15 23:05:06 +00:00
bors
42b1224e9e Auto merge of #116772 - matthiaskrgr:rollup-mpff3lh, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116172 (Broaden the consequences of recursive TLS initialization)
 - #116341 (Implement sys::args for UEFI)
 - #116522 (use `PatKind::Error` when an ADT const value has violation)
 - #116732 (Make x capable of resolving symlinks)
 - #116755 (Remove me from libcore review rotation)
 - #116760 (Remove trivial cast in `guaranteed_eq`)
 - #116771 (Ignore let-chains formatting)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-15 21:10:50 +00:00
Nicholas Nethercote
4d6810844e Inline Bytes::next and Bytes::size_hint.
This greatly increases its speed.
2023-10-16 08:08:32 +11:00
Matthias Krüger
32da83d338
Rollup merge of #116760 - Nilstrieb:triviality, r=oli-obk
Remove trivial cast in `guaranteed_eq`

I found this while accidentally breaking trivial casts in another branch.

r? oli-obk
2023-10-15 21:29:09 +02:00
Matthias Krüger
835edc1397
Rollup merge of #116341 - Ayush1325:uefi-args, r=Mark-Simulacrum
Implement sys::args for UEFI

- Uses `EFI_LOADED_IMAGE_PROTOCOL`, which is implemented for all loaded images.

Tested on qemu with OVMF

cc ``@nicholasbishop``
cc ``@dvdhrm``
2023-10-15 21:29:07 +02:00
Matthias Krüger
e063d8a591
Rollup merge of #116172 - joboet:recursive_tls_initialization, r=dtolnay
Broaden the consequences of recursive TLS initialization

This PR updates the documentation of `LocalKey` to clearly disallow the behaviour described in [this comment](https://github.com/rust-lang/rust/issues/110897#issuecomment-1525738849). This allows using `OnceCell` for the lazy initialization of TLS variables, which panics on reentrant initialization instead of updating the value like TLS variables currently do.

``@rustbot`` label +T-libs-api
r? ``@m-ou-se``
2023-10-15 21:29:06 +02:00
bors
f70779b0fb Auto merge of #110604 - a1phyr:vecdeque_buf_read, r=dtolnay
Implement `BufRead` for `VecDeque<u8>`

Note: it would become insta-stable
2023-10-15 19:15:01 +00:00
David Tolnay
b149d16d3a
Deduplicate std::process Default impl feature names
error[E0711]: feature `process-exitcode-default` is declared stable since 1.74.0-beta.1, but was previously declared stable since 1.73.0
        --> library/std/src/process.rs:1964:1
         |
    1964 | #[stable(feature = "process-exitcode-default", since = "CURRENT_RUSTC_VERSION")]
         | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-15 11:42:28 -07:00
bors
64368d0279 Auto merge of #110729 - ColinFinck:decode-utf16-fused-iterator, r=dtolnay
Implement FusedIterator for DecodeUtf16 when the inner iterator does

I have just implemented an iterator that wraps `DecodeUtf16` and wanted to implement `FusedIterator` for my iterator when I noticed that `DecodeUtf16` currently doesn't implement `FusedIterator` at all.
A quick look at the code of `DecodeUtf16` revealed that `DecodeUtf16::next` only returns `None` when its inner iterator returns `None`:
3462f79e94/library/core/src/char/decode.rs (L45)

As a result, we can implement `FusedIterator` for `DecodeUtf16` when the inner iterator does.

I'm following the example of #96397 here and consider this change minor and non-controversial, which is why I haven't added an RFC. I have also added the required feature name (`"decode_utf16_fused_iterator"`), however without adding a chapter to the Rust Unstable book (same as #96397).
2023-10-15 17:09:37 +00:00
Ralf Jung
9d8506d27f acquire loads can be done as relaxed load; acquire fence 2023-10-15 17:41:50 +02:00
Ralf Jung
9b8686d832 only guarantee for Relaxed; add ptr-size fallback 2023-10-15 17:41:50 +02:00
Ralf Jung
275d5c8251 wording 2023-10-15 17:41:50 +02:00
Ralf Jung
69b62ecc69 define 'read-only memory' 2023-10-15 17:41:50 +02:00
Ralf Jung
07b8c10ed8 add general powerpc64le bound
(some powerpc64le targets can guarantee more, but for now it doesn't seem worth separating by OS/vendor)
2023-10-15 17:41:50 +02:00
Ralf Jung
7453235feb add ARM and RISC-V values 2023-10-15 17:41:50 +02:00
Ralf Jung
b5e67a00d9 document when atomic loads are guaranteed read-only 2023-10-15 17:41:50 +02:00
bors
d60d63fbf7 Auto merge of #116527 - sthibaul:libc, r=Mark-Simulacrum
Bump libc dependency

To get GNU/Hurd support, so that CI of external repositories (e.g. getrandom) can build std.
2023-10-15 15:17:17 +00:00
Ayush Singh
6713ae9d42
Implement args for UEFI
- Uses `EFI_LOADED_IMAGE_PROTOCOL`
- verify that cli args are valid UTF-16
- Update Docs

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-10-15 18:45:13 +05:30
Maybe Waffle
5c13c69f63 Add tests for SocketAddrV6 ordering with scope_id and flowinfo 2023-10-15 12:25:58 +00:00
Nilstrieb
fe9d422e7b Remove trivial cast in guaranteed_eq
I found this while accidentally breaking trivial casts in another
branch.
2023-10-15 12:33:44 +02:00
Matthias Krüger
e86e6b45e7
Rollup merge of #116594 - tae-soo-kim:convert-tryfrom-doc, r=scottmcm
Fix `std::convert::TryFrom` doc

Original text:

> truncating the [i64](https://doc.rust-lang.org/std/primitive.i64.html) to an [i32](https://doc.rust-lang.org/std/primitive.i32.html) (essentially giving the [i64](https://doc.rust-lang.org/std/primitive.i64.html)’s value modulo [i32::MAX](https://doc.rust-lang.org/std/primitive.i32.html#associatedconstant.MAX))

This can't be true, because `i32::MAX` is an odd number. The correct value seems `(i32::MAX + 1) * 2`, but this is complicated and distracting, and I suggest removing the parentheses entirely.
2023-10-15 11:37:23 +02:00
bors
ff5664d600 Auto merge of #116683 - ChrisDenton:exists, r=Mark-Simulacrum
Make `try_exists` return `Ok(true)` for Windows Unix Sockets

This is a follow up to #109106 but for[ `fs::try_exists`](https://doc.rust-lang.org/std/fs/fn.try_exists.html), which doesn't need to get the metadata of a file (which can fail even if a file exists).

`fs::try_exists` currently fails on Windows if encountering a Unix Domain Socket (UDS). This PR fixes it by checking for an error code that's returned when there's a failure to use a reparse point.

## Reparse points

A reparse point is a way to invoke a filesystem filter on a file instead of the file being opened normally. This is used to implement symbolic links (by redirecting to a different path) but also to implement other types of special files such as Unix domain sockets. If the reparse point is not a link type then opening it with `CreateFileW` may fail with `ERROR_CANT_ACCESS_FILE` because the filesystem filter does not implement that operation. This differs from resolving links which may fail with errors such as `ERROR_FILE_NOT_FOUND` or `ERROR_CANT_RESOLVE_FILENAME`.

So `ERROR_CANT_ACCESS_FILE` means that the file exists but that we can't open it normally. Still, the file does exist on the filesystem so `try_exists` should report that as `Ok(true)`.

r? libs
2023-10-15 05:50:30 +00:00
bors
0d410be23c Auto merge of #115515 - the8472:zip-for-arrays, r=scottmcm
optimize zipping over array iterators

Fixes #115339 (somewhat)

the new assembly:

```asm
zip_arrays:
        .cfi_startproc
        vmovups (%rdx), %ymm0
        leaq    32(%rsi), %rcx
        vxorps  %xmm1, %xmm1, %xmm1
        vmovups %xmm1, -24(%rsp)
        movq    $0, -8(%rsp)
        movq    %rsi, -88(%rsp)
        movq    %rdi, %rax
        movq    %rcx, -80(%rsp)
        vmovups %ymm0, -72(%rsp)
        movq    $0, -40(%rsp)
        movq    $32, -32(%rsp)
        movq    -24(%rsp), %rcx
        vmovups (%rsi,%rcx), %ymm0
        vorps   -72(%rsp,%rcx), %ymm0, %ymm0
        vmovups %ymm0, (%rsi,%rcx)
        vmovups (%rsi), %ymm0
        vmovups %ymm0, (%rdi)
        vzeroupper
        retq
```

This is still longer than the slice version given in the issue but at least it eliminates the terrible  `vpextrb`/`orb` chain. I guess this is due to excessive memcpys again (haven't looked at the llvmir)?

The `TrustedLen` specialization is a drive-by change since I had to do something for the default impl anyway to be able to specialize the `TrustedRandomAccessNoCoerce` impl.
2023-10-15 00:49:21 +00:00
Guillaume Gomez
fcd75ccc90
Rollup merge of #116540 - daxpedda:once-cell-lock-try-insert, r=Mark-Simulacrum
Implement `OnceCell/Lock::try_insert()`

I took inspiration from [`once_cell`](https://crates.io/crates/once_cell):
- [`once_cell::unsync::OnceCell::try_insert()`](874f9373ab/src/lib.rs (L551-L563))
- [`once_cell::sync::OnceCell::try_insert()`](874f9373ab/src/lib.rs (L1080-L1087))

I tried to change as little code as possible in the first commit and applied some obvious optimizations in the second one.

ACP: https://github.com/rust-lang/libs-team/issues/276
Tracking issue: #116693
2023-10-14 22:35:05 +02:00
Matthias Krüger
456139ff61
Rollup merge of #116723 - ivmarkov:master, r=dtolnay
Fix broken build on ESP-IDF caused by #115108

`@ijackson` #115108 broke the build for ESP-IDF. I'm still checking whether this PR fixes everything - once I'm ready will remove the "Draft" status.

`@dtolnay` FYI
2023-10-14 19:22:18 +02:00
Matthias Krüger
3899957086
Rollup merge of #115653 - joshlf:patch-9, r=dtolnay
Guarantee that Layout::align returns a non-zero power of two
2023-10-14 13:48:18 +02:00
ivmarkov
b3c95c522c Fix broken build on ESP-IDF caused by #115108 2023-10-14 10:20:48 +00:00
bors
39acbed8d6 Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkan
Bump bootstrap compiler to just-released beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2023-10-14 05:44:48 +00:00
Joshua Liebow-Feeser
9703cb2deb Guarantee representation of None in NPO 2023-10-14 04:41:17 +00:00
bors
2a7c2df506 Auto merge of #115719 - tgross35:atomic-from-ptr, r=dtolnay
Stabilize `atomic_from_ptr`

This stabilizes `atomic_from_ptr` and moves the const gate to `const_atomic_from_ptr`. Const stability is blocked on `const_mut_refs`.

Tracking issue:  #108652

Newly stable API:

```rust
// core::atomic

impl AtomicBool { pub unsafe fn from_ptr<'a>(ptr: *mut bool) -> &'a AtomicBool; }

impl<T> AtomicPtr<T> { pub unsafe fn from_ptr<'a>(ptr: *mut *mut T) -> &'a AtomicPtr<T>; }

impl AtomicU8    { pub unsafe fn from_ptr<'a>(ptr: *mut u8)    -> &'a AtomicU8;    }
impl AtomicU16   { pub unsafe fn from_ptr<'a>(ptr: *mut u16)   -> &'a AtomicU16;   }
impl AtomicU32   { pub unsafe fn from_ptr<'a>(ptr: *mut u32)   -> &'a AtomicU32;   }
impl AtomicU64   { pub unsafe fn from_ptr<'a>(ptr: *mut u64)   -> &'a AtomicU64;   }
impl AtomicUsize { pub unsafe fn from_ptr<'a>(ptr: *mut usize) -> &'a AtomicUsize; }

impl AtomicI8    { pub unsafe fn from_ptr<'a>(ptr: *mut i8)    -> &'a AtomicI8;    }
impl AtomicI16   { pub unsafe fn from_ptr<'a>(ptr: *mut i16)   -> &'a AtomicI16;   }
impl AtomicI32   { pub unsafe fn from_ptr<'a>(ptr: *mut i32)   -> &'a AtomicI32;   }
impl AtomicI64   { pub unsafe fn from_ptr<'a>(ptr: *mut i64)   -> &'a AtomicI64;   }
impl AtomicIsize { pub unsafe fn from_ptr<'a>(ptr: *mut isize) -> &'a AtomicIsize; }
```
2023-10-14 02:45:21 +00:00
Maybe Waffle
963131e99c Derive Ord, PartialOrd and Hash for SocketAddr*
...instead of hand rolling impls, since
1. It's nicer
2. It fixes a buggy `Ord` impl of `SocketAddrV6`, which ignored half of the fields
2023-10-14 00:48:22 +00:00
Trevor Gross
227c844b16 Stabilize 'atomic_from_ptr', move const gate to 'const_atomic_from_ptr' 2023-10-13 16:10:33 -04:00
Trevor Gross
3209d2d46e Correct documentation for atomic_from_ptr
* Remove duplicate alignment note that mentioned `AtomicBool` with other
  types
* Update safety requirements about when non-atomic operations are
  allowed
2023-10-13 16:10:29 -04:00
Peter Jaszkowiak
49aa5a23ca Revert "Invoke backtrace-rs buildscript in std buildscript"
This reverts commit 93677276bc
because it caused issues for projects building the standard
library with non-cargo build systems.
2023-10-13 13:43:00 -06:00
bors
57ef889852 Auto merge of #116233 - DaniPopes:stabilize-const_maybe_uninit_assume_init_read, r=dtolnay
Stabilize `const_maybe_uninit_assume_init_read`

AFAICT the only reason this was not included in the `maybe_uninit_extra` stabilization was because `ptr::read` was unstable (https://github.com/rust-lang/rust/pull/92768#issuecomment-1011101383), which has since been stabilized in 1.71.

Needs a separate FCP from the [original `maybe_uninit_extra` one](https://github.com/rust-lang/rust/issues/63567#issuecomment-964428807).

Tracking issue: #63567
2023-10-13 17:11:03 +00:00
bors
985795270e Auto merge of #115108 - ijackson:broken-wait-status, r=dtolnay
Fix exit status / wait status on non-Unix cfg(unix) platforms

Fixes #114593

Needs FCP due to behavioural changes (NB only on non-Unix `#[cfg(unix)]` platforms).

Also, I think this is likely to break in CI.  I have not been yet able to compile the new bits of `process_unsupported.rs`, although I have compiled the new module.  I'd like some help from people familiar with eg emscripten and fuchsia (which are going to be affected, I think).
2023-10-13 14:53:35 +00:00
daxpedda
dd34d9027a
Add some optimizations 2023-10-13 14:54:33 +02:00
daxpedda
6db2587999
Implement OnceCell/Lock::try_insert() 2023-10-13 14:54:32 +02:00
Denis Smirnov
dfadd177a9
Make TCP connect() handle EINTR correctly
According to the POSIX standard, if connect() is interrupted by a
signal that is caught while blocked waiting to establish a connection,
connect() shall fail and set errno to EINTR, but the connection
request shall not be aborted, and the connection shall be established
asynchronously.

If asynchronous connection was successfully established after EINTR
and before the next connection attempt, OS returns EISCONN that was
handled as an error before. This behavior is fixed now and we handle
it as success.

The problem affects MacOS users: Linux doesn't return EISCONN in this
case, Windows connect() can not be interrupted without an old-fashoin
WSACancelBlockingCall function that is not used in the library.
So current solution gives connect() as OS specific implementation.
2023-10-13 18:12:56 +07:00
ltdk
91405ab74a Clean up unchecked_math, separate out unchecked_shifts 2023-10-13 02:17:08 -04:00
ltdk
6b13950978 Remove Not for IpAddr 2023-10-13 02:15:19 -04:00
ltdk
46bb49acb5 impl Not, Bit{And,Or,Xor}{,Assign} for IP addresses 2023-10-13 02:15:19 -04:00
Chris Denton
2f5dea0978
Test that unix sockets exist on Windows 2023-10-13 06:02:38 +01:00
Chris Denton
2b7fe7e0a1
Make try_exists return Ok(true) for Windows UDS
`fs::try_exists` currently fails on Windows if encountering a Unix Domain Socket (UDS). Fix this by checking for an error code that's returned when there's a failure to use a reparse point.

A reparse point is a way to invoke a filesystem filter on a file instead of the file being opened normally. This is used to implement symbolic links (by redirecting to a different path) but also to implement other types of special files such as Unix domain sockets. If the reparse point is not a link type then opening it with `CreateFileW` may fail with `ERROR_CANT_ACCESS_FILE` because the filesystem filter does not implement that operation. This differs from resolving links which may fail with errors such as `ERROR_FILE_NOT_FOUND` or `ERROR_CANT_RESOLVE_FILENAME`.

So `ERROR_CANT_ACCESS_FILE` means that the file exists but that we can't open it normally. Still, the file does exist so `try_exists` should report that as `Ok(true)`.
2023-10-13 06:02:18 +01:00
Joshua Liebow-Feeser
a9b0966aa5
Update library/core/src/alloc/layout.rs
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2023-10-12 16:03:45 -07:00
Eduardo Sánchez Muñoz
89f9da2056 Bump stdarch submodule 2023-10-12 11:11:29 +02:00
bors
f562931178 Auto merge of #116506 - Wilfred:remove_tmp_var, r=workingjubilee
Remove unnecessary tmp variable in default_read_exact

This `tmp` variable has existed since the original implementation (added in ff81920f03), but it's not necessary (maybe non-lexical lifetimes helped?).

It's common to read std source code to understand how things actually work, and this tripped me up on my first read.
2023-10-12 00:45:22 +00:00
bors
156da98b29 Auto merge of #112818 - Benjamin-L:add-slice_split_once, r=cuviper
Implement `slice::split_once` and `slice::rsplit_once`

Feature gate is `slice_split_once` and tracking issue is #112811. These are equivalents to the existing `str::split_once` and `str::rsplit_once` methods.
2023-10-11 08:19:13 +00:00
bors
6d05c430d2 Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease
rustdoc: show crate name beside smaller logo

*Blocked on https://github.com/rust-lang/cargo/pull/12800*

## Summary

In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules.

Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc).

The Rust logo is also no longer shown by default for non-Rust docs.

### Screenshots

<details><summary>Before</summary>

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/d5db0a46-2bb6-44a2-a3aa-2d915ecb8595) |![image](https://github.com/rust-lang/rust/assets/1593513/61f8c1ee-c298-4e2c-b791-18ecb79ab83b)
| In module[^1] | ![image](https://github.com/rust-lang/rust/assets/1593513/73abca59-0b69-4650-a1e2-7278ca34795c) | ![image](https://github.com/rust-lang/rust/assets/1593513/0baf02c2-2ec7-4674-80e5-a6a74a973376)

[^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar

</details>

#### Whole sidebar screenshots

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/75d1bd07-41f7-4f11-ba24-fd5476e0586a) | ![image](https://github.com/rust-lang/rust/assets/1593513/52960259-2b65-4131-b380-01826f0a0eb7)
| In module | ![image](https://github.com/rust-lang/rust/assets/1593513/06e57928-8cb0-41bd-b152-be16cc53e5ec) | ![image](https://github.com/rust-lang/rust/assets/1593513/37291c69-2a07-4467-a382-d9b029084a47)

#### Different logo configurations

|         | Short crate name | Long crate name |
|---------|------------------|-----------------|
| Root    | ![short-root]    | ![long-root]
| Subpage | ![short-subpage] | ![long-subpage]

[short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79
[short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451
[long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056
[long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30

##### Without a logo

![image](https://github.com/rust-lang/rust/assets/1593513/66672b79-6c59-4be8-a527-25ef6f0b04ab)

### Preview pages

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html

## Motivation

This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically).

Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout).

[Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html
[Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018

## Guide-level explanation

This PR cleans up some of the sidebar navigation.

It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation).

It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item.

## Drawbacks

While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex.

## Rationale and alternatives

I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though.

## Prior art

This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name.

[`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html

## Unresolved questions

Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere.

## Future possibilities

Beyond this, plenty of other changes could be made to improve the layout, like

* Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top.
  * The [Internals demo](https://utherii.github.io/new.html) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing.
  * The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser.
* Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page.
  * We don't lack ideas to fix this one. We have *too many*.
* Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new).
  * A possibility: add a Back arrow next to the "In [module]" header?
    ![image](https://github.com/rust-lang/rust/assets/1593513/e969faf7-7722-457a-b8c6-8d962e9e1e23)
* Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, https://github.com/rust-lang/rust/pull/115660 is great, let's do it too.

But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-10-11 06:28:36 +00:00
Ali MJ Al-Nasrawy
38654ad741
Rollup merge of #95967 - CAD97:from-utf16, r=dtolnay
Add explicit-endian String::from_utf16 variants

This adds the following APIs under `feature(str_from_utf16_endian)`:

```rust
impl String {
    pub fn from_utf16le(v: &[u8]) -> Result<String, FromUtf16Error>;
    pub fn from_utf16le_lossy(v: &[u8]) -> String;
    pub fn from_utf16be(v: &[u8]) -> Result<String, FromUtf16Error>;
    pub fn from_utf16be_lossy(v: &[u8]) -> String;
}
```

These are versions of `String::from_utf16` that explicitly take [UTF-16LE and UTF-16BE](https://unicode.org/faq/utf_bom.html#gen7). Notably, we can do better than just the obvious `decode_utf16(v.array_chunks::<2>().copied().map(u16::from_le_bytes)).collect()` in that:

- We handle the case where the byte slice is not an even number of bytes, and
- In the case that the UTF-16 is native endian and the slice is aligned, we can forward to `String::from_utf16`.

If the Unicode Consortium actively defines how to handle character replacement when decoding a UTF-16 bytestream with a trailing odd byte, I was unable to find reference. However, the behavior implemented here is fairly self-evidently correct: replace the single errant byte with the replacement character.
2023-10-11 03:53:16 +03:00
Chris Denton
367d7ed67d
On Windows make readdir error on the empty path 2023-10-10 17:56:31 +01:00
Guillaume Gomez
b72db84fd0
Rollup merge of #116559 - Kritzefitz:btree-new-in-const, r=Amanieu
Mark `new_in` as `const` for BTree collections

Discussed in and closes rust-lang/wg-allocators#118
2023-10-10 18:44:46 +02:00
niluxv
b48039f6fe
Rewrite read_encoded_pointer conforming to strict provenance
* Entries in the callsite table now use a dedicated function for reading an offset rather than a pointer
* `read_encoded_pointer` uses that new function for reading offsets when the "application" part of the encoding indicates an offset (relative to some pointer)
* It now errors out on nonsensical "application" and "value encoding" combinations

Inspired by @eddyb's comment on zulip about this:
<https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/strict.20provenance.20in.20dwarf.3A.3Aeh/near/276197290>
2023-10-10 09:59:46 +02:00
niluxv
e7a3c341dd
Use pointers instead of usize addresses for landing pads
This bring unwind and personality code more in line with strict-provenance
2023-10-10 09:59:39 +02:00
tae-soo-kim
e15e9a673e
Update mod.rs 2023-10-10 07:05:25 +00:00
joboet
88efb1bdef
std: explain unconventional choice of let-else binding over while-let loop 2023-10-09 15:09:18 +02:00
Sven Bartscher
d60b43c06a Make BTreeSet::new_in const 2023-10-09 11:17:56 +02:00
Sven Bartscher
bbc230478c Make BTreeMap::new_in const
Closes rust-lang/wg-allocators#118
2023-10-09 11:08:48 +02:00
Qiu Chaofan
14d29be03c Support AIX in Rust standard library 2023-10-09 14:02:57 +08:00
Michael Howell
c6e6ecb1af rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
Mark Rousskov
ea1066d0be Bump to latest beta 2023-10-08 19:57:43 -04:00
Samuel Thibault
04d4336009 Bump libc dependency
To get GNU/Hurd support, so that CI of external repositories (e.g. getrandom)
can build std.
2023-10-08 19:56:44 +02:00
bors
598e29bf70 Auto merge of #100806 - timvermeulen:split_inclusive_double_ended_bound, r=dtolnay
Fix generic bound of `str::SplitInclusive`'s `DoubleEndedIterator` impl

`str::SplitInclusive`'s `DoubleEndedIterator` implementation currently uses a `ReverseSearcher` bound for the corresponding searcher. A `DoubleEndedSearcher` bound should have been used instead.

`DoubleEndedIterator` requires that repeated `next_back` calls produce the same items as repeated `next` calls, in opposite order. `ReverseSearcher` lets you search starting from the back of a string, but it makes no guarantees about how its matches correspond to the matches found by a forward search. `DoubleEndedSearcher` is a subtrait of `ReverseSearcher` and does require that the same matches are found in both directions.

This bug fix is a breaking change. Calling `next_back` on `"a+++b".split_inclusive("++")` is currently accepted with repeated calls producing `"b"` and `"a+++"`, while forward iteration yields `"a++"` and `"+b"`. Also see https://github.com/rust-lang/rust/issues/100756#issuecomment-1221307166 for more details.

I believe that this is the only iterator that uses this bound incorrectly — other related iterators such as `str::Split` do have a `DoubleEndedSearcher` bound for their `DoubleEndedIterator` implementation. And `slice::SplitInclusive` doesn't face this problem at all because it doesn't use patterns, only a predicate.

cc `@SkiFire13`
2023-10-07 17:10:02 +00:00
joboet
65c66a15bf
std: fix registering of Windows TLS destructors 2023-10-07 16:01:18 +02:00
bors
fc01a7432b Auto merge of #109214 - tosti007:std_collection_hash_new_rework, r=workingjubilee
Use `HashMap::with_capacity_and_hasher` instead of using base

Cleans up the internal logic for `HashMap::with_capacity` slightly.
2023-10-07 05:26:12 +00:00
Wilfred Hughes
dca90f7ec1 Remove unnecessary tmp variable in default_read_exact
This variable seems to serve no purpose, and it's a little confusing
when reading std source code, so remove it.
2023-10-07 01:16:45 -04:00
bors
4ea5190026 Auto merge of #116318 - pitaj:android-backtrace-build, r=workingjubilee
Invoke `backtrace-rs` buildscript in `std` buildscript

Based on #99883 by `@Arc-blroth`
Depends on rust-lang/backtrace-rs#556 and rust-lang/cc-rs#705
2023-10-07 02:20:50 +00:00
bors
93b6a36568 Auto merge of #116501 - workingjubilee:rollup-fpzov6m, r=workingjubilee
Rollup of 4 pull requests

Successful merges:

 - #116277 (dont call mir.post_mono_checks in codegen)
 - #116400 (Detect missing `=>` after match guard during parsing)
 - #116458 (Properly export function defined in test which uses global_asm!())
 - #116500 (Add tvOS to target_os for register_dtor)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-07 00:27:14 +00:00
Jubilee
4b102b0d8d
Rollup merge of #116500 - simlay:tvos-support-for-register_dtor, r=workingjubilee
Add tvOS to target_os for register_dtor

Closes #116491.
2023-10-06 16:37:48 -07:00
bors
8fdb0a9b57 Auto merge of #114709 - ShE3py:wasi-io-error-more, r=workingjubilee
Use `io_error_more` on WASI

#86442 added many variants to [`io::ErrorKind`](https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html), but `sys::wasi::decode_error_kind()` wasn't modified to use them.

The preview1 `errno` list:
4712d490fd/legacy/preview1/docs.md (-errno-variant)

Original implementation: #63814

`@rustbot` label +A-error-handling +C-enhancement +O-wasi
2023-10-06 22:39:41 +00:00
Sebastian Imlay
3abef68e63 Add tvOS to target_os for register_dtor 2023-10-06 18:11:49 -04:00
Matthias Krüger
7f0cf8c0e4
Rollup merge of #116484 - peterjoel:once-doc-clarify, r=cuviper
Minor doc clarification in Once::call_once
2023-10-06 21:17:51 +02:00
Matthias Krüger
f8dae0c20a
Rollup merge of #116481 - scottmcm:tweak-combinators, r=cuviper
Reuse existing `Some`s in `Option::(x)or`

LLVM still has trouble re-using discriminants sometimes when rebuilding a two-variant enum, so when we have the correct variant already built, just use it.

That's shorter in the Rust code, as well as simpler in MIR and the optimized LLVM, so might as well: <https://rust.godbolt.org/z/KhdE8eToW>

Thanks to `@veber-alex` for pointing out this opportunity in https://github.com/rust-lang/rust/issues/101210#issuecomment-1732470941
2023-10-06 21:17:50 +02:00
Matthias Krüger
4dfa5e5dec
Rollup merge of #114564 - scottmcm:when-to-from, r=dtolnay
Attempt to describe the intent behind the `From` trait further

Inspired by the <https://internals.rust-lang.org/t/allow-use-as-and-try-as-for-from-and-tryfrom-traits/19240/26?u=scottmcm> thread.

`@rustbot` label +T-libs-api
2023-10-06 21:17:48 +02:00
ShE3py
3706e6f61a
Use io_error_more on WASI 2023-10-06 19:05:45 +02:00
The 8472
b018ad3d41 optimize zipping over array iterators 2023-10-06 18:33:25 +02:00
bors
1bc0463b18 Auto merge of #116483 - GuillaumeGomez:rollup-z65pno1, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #115454 (Clarify example in docs of str::char_slice)
 - #115522 (Clarify ManuallyDrop bit validity)
 - #115588 (Fix a comment in std::iter::successors)
 - #116198 (Add more diagnostic items for clippy)
 - #116329 (update some comments around swap())
 - #116475 (rustdoc-search: fix bug with multi-item impl trait)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-06 13:07:15 +00:00
Peter Hall
c95015c295 Minor doc clarification in Once::call_once 2023-10-06 12:20:39 +01:00
Guillaume Gomez
9e28a9349c
Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcm
update some comments around swap()

Based on ``@eddyb's`` comment [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/461#issuecomment-1742156410).

And then I noticed the wrong capitalization for Miri and fixed it in some other places as well.
2023-10-06 13:18:35 +02:00
Guillaume Gomez
3785fed021
Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkin
Add more diagnostic items for clippy
2023-10-06 13:18:34 +02:00
Guillaume Gomez
382701e6b6
Rollup merge of #115588 - tifv:fix-comment-successors, r=scottmcm
Fix a comment in std::iter::successors

The `unfold` function have since #58062 been renamed to `from_fn`.
(I'm not sure if this whole comment is still useful—it's not like there are many iterators that *can't* be based on `from_fn`. Anyway, in its current form this comment is not correct, and it sent me into a half-hour research of what happened to `unfold` function, so I want to do *something* with it 🙃 deleting these three lines is a perfectly fine alternative, in my opinion.)
2023-10-06 13:18:34 +02:00
Guillaume Gomez
525c661842
Rollup merge of #115522 - joshlf:patch-8, r=scottmcm
Clarify ManuallyDrop bit validity

Clarify that `ManuallyDrop<T>` has the same bit validity as `T`.
2023-10-06 13:18:33 +02:00
Guillaume Gomez
4e818f6b72
Rollup merge of #115454 - vwkd:patch-1, r=scottmcm
Clarify example in docs of str::char_slice

Just a one word improvement.

“Last” can be misread as meaning the last (third) instead of the previous (first).
2023-10-06 13:18:33 +02:00
bors
6683f13fa1 Auto merge of #111595 - fortanix:raoul/waitqueue_clarifications, r=workingjubilee
`waitqueue` clarifications for SGX platform

The documentation of `waitqueue` functions on the `x86_64-fortanix-unknown-sgx` platform is incorrect at some places and on others missing. This PR improves upon this.

cc: `@jethrogb`
2023-10-06 11:12:13 +00:00
Scott McMurray
5432d13bb0 Reuse existing Somes in Option::(x)or
LLVM still has trouble re-using discriminants sometimes when rebuilding a two-variant enum, so when we have the correct variant already built, just use it.

That's simpler in LLVM *and* in MIR, so might as well: <https://rust.godbolt.org/z/KhdE8eToW>
2023-10-06 01:41:48 -07:00
Scott McMurray
1651f1f4b8 Elaborate some caveats to lossless 2023-10-05 23:03:02 -07:00
scottmcm
44f92c1f80
Don't mention "recover the original" in From docs
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2023-10-06 05:31:54 +00:00
Scott McMurray
b80e653ca1 Attempt to describe the intent behind the From trait further 2023-10-05 22:21:45 -07:00
Chris Denton
fca182b6a0
Windows: Support sub-millisecond sleep
Use `CreateWaitableTimerExW` with `CREATE_WAITABLE_TIMER_HIGH_RESOLUTION`. Does not work before Windows 10, version 1803 so in that case we fallback to using `Sleep`.
2023-10-06 06:06:43 +01:00
bors
fd80c02c16 Auto merge of #116463 - ChrisDenton:nlibc, r=workingjubilee
Remove libc

We don't use much libc on Windows and it seemed silly to keep if for the sake of [two well documented constants](https://learn.microsoft.com/en-us/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-170).
2023-10-06 03:39:22 +00:00
bors
579be69de9 Auto merge of #101150 - jethrogb:jb/cleanup-sgx-user-memory-copies, r=workingjubilee
Clean up SGX user memory copies

Follow-up on #98126 and #100383

r? `@cuviper`
cc `@raoulstrackx`
2023-10-06 01:50:10 +00:00
Chris Denton
c8f3aa451a
Remove libc
We don't use much libc on Windows.
2023-10-06 00:35:00 +01:00
Jason Newcomb
d464b72970 Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
bors
cdca82c2c8 Auto merge of #116455 - matthiaskrgr:rollup-p226a5u, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #116220 (stabilize `Option::as_`(`mut_`)`slice`)
 - #116288 (Add Span to various smir types)
 - #116415 (Move subtyper below reveal_all and change reveal_all)
 - #116428 (Add a note to duplicate diagnostics)
 - #116452 (Do not assert that hidden types don't have erased regions.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-05 17:50:50 +00:00
Matthias Krüger
864e5d8d94
Rollup merge of #116220 - llogiq:stabilize-option-as-slice, r=BurntSushi
stabilize `Option::as_`(`mut_`)`slice`

This is the stabilization to #108545. Thanks to everyone who helped getting this into Rust proper.
2023-10-05 19:24:33 +02:00
bors
3bcad65fbf Auto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee
docs: Correct terminology in std::cmp

This PR is the result of some discussions on URLO:

* [Traits in `std::cmp` and mathematical terminology](https://users.rust-lang.org/t/traits-in-std-cmp-and-mathematical-terminology/69887)
* [Are poker hands `Ord` or `PartialOrd`?](https://users.rust-lang.org/t/are-poker-hands-ord-or-partialord/82644)

Arguably, the documentation currently isn't very precise regarding mathematical terminology. This can lead to misunderstandings of what `PartialEq`, `Eq`, `PartialOrd`, and `Ord` actually do.

While I believe this PR doesn't give any new API guarantees, it expliclitly mentions that `PartialEq::eq(a, b)` may return `true` for two distinct values `a` and `b` (i.e. where `a` and `b` are not equal in the mathematical sense). This leads to the consequence that `Ord` may describe a weak ordering instead of a total ordering.

In either case, I believe this PR should be thoroughly reviewed, ideally by someone with mathematical background to make sure the terminology is correct now, and also to ensure that no unwanted new API guarantees are made.

In particular, the following problems are addressed:

* Some clarifications regarding used (mathematical) terminology:
    * Avoid using the terms "total equality" and "partial equality" in favor of "equivalence relation" and "partial equivalence relation", which are well-defined and unambiguous.
    * Clarify that `Ordering` is an ordering between two values (and not an order in the mathematical sense).
    * Avoid saying that `PartialEq` and `Eq` are "equality comparisons" because the terminology "equality comparison" could be misleading: it's possible to implement `PartialEq` and `Eq` for other (partial) equivalence relations, in particular for relations where `a == b` for some `a` and `b` even when `a` and `b` are not the same value.
    * Added a section "Strict and non-strict partial orders" to document that the `<=` and `>=` operators do not correspond to non-strict partial orders.
    * Corrected section "Corollaries" in documenation of `Ord` in regard to `<` only describing a strict total order in cases where `==` conforms to mathematical equality.
    * ~~Added a section "Weak orders" to explain that `Ord` may also describe a weak order or total preorder, depending on how `PartialEq::eq` has been implemented.~~ (Removed, see [comment](https://github.com/rust-lang/rust/pull/103046#issuecomment-1279929676))
* Made documentation easier to understand:
    * Explicitly state at the beginning of `PartialEq`'s documentation comment that implementing the trait will provide the `==` and `!=` operators.
    * Added an easier to understand rule when to implement `Eq` in addition to `PartialEq`: "if it’s guaranteed that `PartialEq::eq(a, a)` always returns `true`."
    *  Explicitly mention in documentation of `Eq` that the properties "symmetric" and "transitive" are already required by `PartialEq`.
2023-10-05 15:24:54 +00:00
bors
cf9fd95b1c Auto merge of #114042 - liushuyu:ubuntu/i586-fpmath, r=workingjubilee
core library: Disable fpmath tests for i586 ...

This patch disables the floating-point epsilon test for i586 since x87 registers are too imprecise and can't produce the expected results.
2023-10-05 13:35:18 +00:00
Jan Behrens
86b031b734 docs: Correct terminology in std::cmp
Some clarifications regarding used (mathematical) terminology:

* Avoid using the terms "total equality" and "partial equality" in favor
  of "equivalence relation" and "partial equivalence relation", which
  are well-defined and unambiguous.
* Clarify that `Ordering` is an ordering between two values (and not an
  order in the mathematical sense).
* Avoid saying that `PartialEq` and `Eq` are "equality comparisons"
  because the terminology "equality comparison" could be misleading:
  it's possible to implement `PartialEq` and `Eq` for other (partial)
  equivalence relations, in particular for relations where `a == b` for
  some `a` and `b` even when `a` and `b` are not the same value.
* Added a section "Strict and non-strict partial orders" to document
  that the `<=` and `>=` operators do not correspond to non-strict
  partial orders.
* Corrected section "Corollaries" in documenation of Ord in regard to
  `<` only describing a strict total order in cases where `==` conforms
  to mathematical equality.

Made documentation easier to understand:

* Explicitly state at the beginning of `PartialEq`'s documentation
  comment that implementing the trait will provide the `==` and `!=`
  operators.
* Added an easier to understand rule when to implement `Eq` in addition
  to `PartialEq`: "if it’s guaranteed that `PartialEq::eq(a, a)` always
  returns `true`."
* Explicitly mention in documentation of `Eq` that the properties
  "symmetric" and "transitive" are already required by `PartialEq`.
2023-10-05 14:44:42 +02:00
bors
90f3a6f920 Auto merge of #104153 - tspiteri:doc-float-constants, r=workingjubilee
doc: expand description for f32 and f64 associated constants

This explains the meaning of some of the floating-point associated constants.
2023-10-05 11:46:55 +00:00
Jubilee
ea3454eabb
Rollup merge of #116223 - catandcoder:master, r=cjgillot
Fix misuses of a vs an

Fixes the misuse of "a" vs "an", according to English grammatical
expectations and using https://www.a-or-an.com/
2023-10-05 00:56:29 -07:00
Ramon de C Valle
7b45674015 Disable CFI for core and std CFI violations
Works around #115199 by temporarily disabling CFI for core and std CFI
violations to allow the user rebuild and use both core and std with CFI
enabled using the Cargo build-std feature.
2023-10-04 10:05:54 -07:00
joboet
b18990b1e9
std: abort instead of panicking if the global allocator uses TLS 2023-10-04 11:49:48 +02:00
bors
a7bb2f67bf Auto merge of #116408 - matthiaskrgr:rollup-hmolg4m, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #115961 (Replace 'mutex' with 'lock' in RwLock documentation)
 - #116146 (Clarify `arg` and `args` documentation)
 - #116363 (Adapt `todo!` documentation to mention displaying custom values)
 - #116365 (bootstrap: make copying linker binaries conditional)
 - #116388 (rustdoc: fix & clean up handling of cross-crate higher-ranked parameters)
 - #116393 (Emit feature gate *warning* for `auto` traits pre-expansion)
 - #116395 (Mark myself as vacation or whatever)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-04 03:38:42 +00:00
Matthias Krüger
0363cc561d
Rollup merge of #116363 - Colonial-Dev:issue-116130-fix, r=thomcc
Adapt `todo!` documentation to mention displaying custom values

Resolves #116130.

I copied from the [existing documentation](https://doc.rust-lang.org/std/macro.unimplemented.html) for `unimplemented!` more or less directly, down to the example trait used. I also took the liberty of fixing some formatting and typographical errors that I noticed.
2023-10-04 05:02:04 +02:00
Matthias Krüger
d5bd019645
Rollup merge of #116146 - Milo123459:milo/clarify-arg-documentation, r=thomcc
Clarify `arg` and `args` documentation

Fixes #95400
2023-10-04 05:02:04 +02:00
Matthias Krüger
36e234a0fa
Rollup merge of #115961 - Kriskras99:master, r=thomcc
Replace 'mutex' with 'lock' in RwLock documentation

When copying the documentation for `clear_poison` from Mutex, not every occurence of 'mutex' was replaced with 'lock'.
2023-10-04 05:02:03 +02:00
bors
4910642aab Auto merge of #116386 - elichai:patch-2, r=thomcc
Add missing inline attributes to Duration trait impls

Currently `Duration::checked_add` is marked `#[inline]` but it's trait relative `Add::add` is not.
Leading to a case where:
```rust
pub fn foo() -> Duration {
    Duration::from_secs(10) + Duration::from_millis(6)
}

pub fn bar() -> Duration {
    Duration::from_secs(10).checked_add(Duration::from_millis(6)).expect("overflow when adding durations")
}
```
compiles to:
```asm

playground::foo:
	movl	$10, %edi
	xorl	%esi, %esi
	xorl	%edx, %edx
	movl	$6000000, %ecx
	jmpq	*<core::time::Duration as core::ops::arith::Add>::add@GOTPCREL(%rip)

playground::bar:
	movl	$10, %eax
	movl	$6000000, %edx
	retq
```
(The same happens for all arithmetic operation)
2023-10-04 01:49:24 +00:00
Mark Rousskov
787d32324c Bump version placeholders 2023-10-03 20:26:36 -04:00
bors
79f38b7914 Auto merge of #116367 - scottmcm:more-addr-eq, r=workingjubilee
Use `addr_eq` in `{Arc,Rc}::ptr_eq`

Since it's made for stuff like this (see #106447)
2023-10-04 00:03:54 +00:00
cui fliter
f44d116e1f Fix misuses of a vs an
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-04 08:01:11 +08:00
joboet
fd23276ca8
std: panic when the global allocator tries to register a TLS destructor 2023-10-03 23:57:37 +02:00
bors
187b8131d4 Auto merge of #105394 - Patiga:improve-udpsocket-docs, r=workingjubilee
Improve UdpSocket documentation

I tried working with `UdpSocket` and ran into `EINVAL` errors with no clear indication of what causes the error. Also, it was uncharacteristically hard to figure this module out, compared to other Rust `std` modules.

1. `send` and `send_to` return a `usize` This one is just clarity. Usually, returned `usize`s indicate that the buffer might have only been sent partially. This is not the case with UDP. Since that `usize` must always be `buffer.len()`, I have documented that.

2. `bind` limits `connect` and `send_to` When you bind to a limited address space like localhost, you can only `connect` to addresses in that same address space. Error kind: `AddrNotAvailable`.

3. `connect`ing to localhost locks you to localhost On Linux, if you first `connect` to localhost, subsequent `connect`s to
non-localhost addresses fail. Error kind: `InvalidInput`.

For debugging the third one, it was really hard to find someone else who already had that problem. I only managed to find this thread: https://www.mail-archive.com/netdev@vger.kernel.org/msg159519.html
2023-10-03 20:35:38 +00:00
Elichai Turkel
92c9bcdff4
Add missing inline attributes to Duration trait impls 2023-10-03 18:39:56 +03:00
Matthias Krüger
a4ba529474
Rollup merge of #116282 - rustaceanclub:master, r=davidtwco
Fix broken links

The previous address is no longer available, replace it with the latest available one.
2023-10-03 16:24:16 +02:00
Matthias Krüger
c3daf77132
Rollup merge of #116361 - eduardosm:bump-stdarch, r=Amanieu
Bump stdarch submodule

r? `@Amanieu`
2023-10-03 08:58:50 +02:00
Matthias Krüger
043fcc487a
Rollup merge of #116355 - orlp:signed-zero-rounding-mode, r=thomcc
Clarify float rounding direction for signed zero

Closes https://github.com/rust-lang/rust/issues/116339.
2023-10-03 08:58:50 +02:00
Matthias Krüger
cebe393a4a
Rollup merge of #116351 - asquared31415:ptr_eq_must_use, r=workingjubilee
Add `must_use` on pointer equality functions

`ptr == ptr` (like all use of `==`) has a similar warning, and these functions are simple convenience wrappers over that.
2023-10-03 08:58:49 +02:00
Peter Jaszkowiak
93677276bc Invoke backtrace-rs buildscript in std buildscript
Based on #99883 by @Arc-blroth
Depends on rust-lang/backtrace-rs#556 and rust-lang/cc-rs#705
2023-10-02 19:34:27 -06:00
Scott McMurray
f8fc0d7716 Use addr_eq in {Arc,Rc}::ptr_eq
Since it's made for stuff like this (see 106447)
2023-10-02 17:32:01 -07:00
James Haywood
0c6d279728 Appease tidy 2023-10-02 19:22:42 -04:00
James Haywood
f96cfb533a Adapt todo! documentation to mention displaying custom values
Correct hidden trait in doc test
2023-10-02 19:09:11 -04:00
Eduardo Sánchez Muñoz
f2918b4a3d Bump stdarch submodule 2023-10-02 23:43:35 +02:00
Tyler Mandry
132e38366f
Rollup merge of #116350 - Nilstrieb:in-situ, r=Dylan-DPC
Improve wording of `hint::black_box` docs

The wording is a bit confusing.

squash of #109634
2023-10-02 16:09:43 -04:00
Tyler Mandry
1edf7233fa
Rollup merge of #116289 - linkmauve:patch-1, r=the8472
Add missing #[inline] on AsFd impl for sys::unix::fs::File

This operation should be extremely cheap, at most the `mov` of the underlying file descriptor, but due to this missing `#[inline]` it is currently a function call.
2023-10-02 16:09:42 -04:00
Orson Peters
07e96314ec Clarify float rounding direction for signed zero 2023-10-02 22:05:17 +02:00
4gboframram
44c9818993 Improve wording of hint::black_box docs
The wording is a bit confusing.

Co-authored-by: Chris Denton <christophersdenton@gmail.com>
2023-10-02 20:07:14 +02:00
asquared31415
34ea540720 add must_use on pointer equality functions 2023-10-02 15:10:51 +00:00
Matthias Krüger
b3853ccc9d
Rollup merge of #116326 - Colonial-Dev:issue-116165-fix, r=joshtriplett
Correct misleading std::fmt::Binary example (#116165)

Nothing too crazy...

- Add two to the width specifier (so all 32 bits are correctly displayed)
- Pad out the compared string so the assert passes
- Add `// Note` comment highlighting the need for the extra width when using the `#` flag.

The exact contents (and placement?) of the note are, of course, highly bikesheddable.
2023-10-02 16:23:53 +02:00
Ralf Jung
bfc0f23acb MIRI -> Miri 2023-10-02 08:35:08 +02:00
Ralf Jung
ec2e00c404 update some comments around swap() 2023-10-02 08:34:10 +02:00
bors
15783292e5 Auto merge of #116325 - scottmcm:addr_eq, r=dtolnay
Add `ptr::addr_eq`

Seconded ACP: https://github.com/rust-lang/libs-team/issues/274#issuecomment-1741853598
Tracking issue: https://github.com/rust-lang/rust/issues/116324
cc `@dtolnay` https://github.com/rust-lang/rust/issues/106447
2023-10-02 04:17:01 +00:00
James Haywood
f2ecf7c511 Correct misleading std::fmt::Binary example 2023-10-01 23:58:54 -04:00
bors
30ec74728d Auto merge of #116317 - ravenclaw900:track-caller-unwrap-or-else, r=Mark-Simulacrum
Add track_caller attribute to Result::unwrap_or_else

Fixes issue where panics in unwrap_or_else callbacks marked with the `track_caller` attribute appear as errors in core.
2023-10-02 02:26:38 +00:00
Scott McMurray
18787914aa Add ptr::addr_eq 2023-10-01 18:56:38 -07:00
bors
79bfd93d5a Auto merge of #116207 - Ayush1325:uefi_stdio, r=Mark-Simulacrum
Stdio support for UEFI

- Uses Simple Text Output Protocol and Simple Text Input Protocol
- Reading is done one character at a time
- Writing is done with max 4096 characters

# Quirks
## Output Newline
- UEFI uses CRLF for newline. So when running the application in UEFI shell (qemu VGA), the output of `println` looks weird.
- However, since the UEFI shell supports piping output, I am unsure if doing any output post-processing is a good idea. UEFI shell `cat` command seems to work fine with just LF.

## Input Newline
- `Stdin.read_line()` method is broken in UEFI shell. Pressing enter seems to be read as CR, which means LF is never encountered.
- Works fine with input redirection from file.

CC `@dvdhrm`
2023-10-02 00:03:52 +00:00
Ayush Singh
3f4a289016
Stdio for UEFI
- Uses Simple Text Output Protocol and Simple Text Input Protocol
- Reading is done one character at a time
- Writing is done with max 4096 characters

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-10-02 00:07:11 +05:30
ravenclaw900
ba0b7f0f01
Add track_caller attribute to Result::unwrap_or_else 2023-10-01 09:42:37 -05:00
Matthias Krüger
de7053133a
Rollup merge of #116295 - asquared31415:mem_drop_docs, r=WaffleLapkin
Fix `core::mem::drop` docs inaccuracy

r? `@Nilstrieb`
2023-10-01 12:18:12 +02:00
bors
8fa7bdf191 Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum
Partially outline code inside the panic! macro

This outlines code inside the panic! macro in some cases. This is split out from https://github.com/rust-lang/rust/pull/115562 to exclude changes to rustc.
2023-10-01 05:56:47 +00:00
bors
2f89c414f2 Auto merge of #116157 - the8472:doc-monotonoic-suspend, r=Mark-Simulacrum
Document that Instant may or may not include system-suspend time

Since people are still occasionally surprised by this let's make it more explicit. This doesn't add any new guarantees, only documents the status quo.

Related issues: #87906 #79462
2023-09-30 19:49:34 +00:00
asquared31415
bc3c445764 mem::drop docs 2023-09-30 14:41:56 -04:00
linkmauve
133aa56a84
Add missing #[inline] on AsFd impl for sys::unix::fs::File
This operation should be extremely cheap, at most the mov of the underlying
file descriptor, but due to this missing #[inline] it is currently a function
call.
2023-09-30 17:56:42 +02:00
cui fliter
6ef3fd7138 Fix broken links
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-09-30 10:26:04 +08:00
bors
4efd65571e Auto merge of #115546 - SUPERCILEX:patch-2, r=Amanieu
Weaken needlessly restrictive orderings on Arc::*_count

Follow up to https://github.com/rust-lang/rust/pull/95183 from this zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Why.20does.20Arc.3A.3Astrong_count.20use.20Acquire.20instead.20of.20Relaxed.3F/near/386213850

I'd like to use the strong_count for a lockless algorithm I'm writing, but I don't need acquire semantics so that's pointlessly restrictive on arm/risc-v.
2023-09-30 02:15:19 +00:00
Matthias Krüger
4db2b741c8
Rollup merge of #116241 - dtolnay:exclusivefwd, r=Amanieu
Add Exclusive forwarding impls (FnOnce, FnMut, Generator)

This is adapted from #104057.
2023-09-29 22:27:51 +02:00
bors
a6dfd89fa7 Auto merge of #113797 - RalfJung:offset_from_docs, r=workingjubilee
offset_from: docs improvements

This is the part of https://github.com/rust-lang/rust/pull/112837 that doesn't add a new function, just tweaks the existing docs.
2023-09-29 13:53:11 +00:00
bors
b8536c1aa1 Auto merge of #116176 - FedericoStra:isqrt, r=dtolnay
Add "integer square root" method to integer primitive types

For every suffix `N` among `8`, `16`, `32`, `64`, `128` and `size`, this PR adds the methods

```rust
const fn uN::isqrt() -> uN;
const fn iN::isqrt() -> iN;
const fn iN::checked_isqrt() -> Option<iN>;
```

to compute the [integer square root](https://en.wikipedia.org/wiki/Integer_square_root), addressing issue #89273.

The implementation is based on the [base 2 digit-by-digit algorithm](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Binary_numeral_system_(base_2)) on Wikipedia, which after some benchmarking has proved to be faster than both binary search and Heron's/Newton's method. I haven't had the time to understand and port [this code](http://atoms.alife.co.uk/sqrt/SquareRoot.java) based on lookup tables instead, but I'm not sure whether it's worth complicating such a function this much for relatively little benefit.
2023-09-29 07:35:44 +00:00
Christopher Durham
5facc32e22 fix char imports 2023-09-29 00:04:57 -04:00
Christopher Durham
1efea31385 add str_from_utf16_endian tracking issue 2023-09-28 23:56:27 -04:00
Christopher Durham
3d448bd067 style nits
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2023-09-28 23:56:10 -04:00
CAD97
8047f8fb51 Add feature(str_from_utf16_endian) 2023-09-28 23:54:38 -04:00
Tamir Duberstein
bc300102d4
time: use clock_gettime on macos
Replace `mach_{absolute_time,timebase_info}` with
`clock_gettime(CLOCK_REALTIME)` on:

```
all(target_os = "macos", not(target_arch = "aarch64")),
    target_os = "ios",
    target_os = "watchos",
    target_os = "tvos"
))]
```

`mach_{absolute_time,timebase_info}` were first used in
cc367edd95
which predated the introduction of `clock_gettime` support in macOS
10.12 Sierra which became the minimum supported version in
58bbca958d.

Note that this change was made for aarch64 in
5008a317ce which predated 10.12 becoming
the minimum supported version. The discussion took place in
https://github.com/rust-lang/rust/issues/91417 and in particular
https://github.com/rust-lang/rust/issues/91417#issuecomment-992151582
and
https://github.com/rust-lang/rust/issues/91417#issuecomment-1033048064
are relevant.
2023-09-28 18:20:09 -04:00
Tamir Duberstein
b21eb4f046
time: use clock_gettime on macos
Replace `gettimeofday` with `clock_gettime(CLOCK_REALTIME)` on:

```
all(target_os = "macos", not(target_arch = "aarch64")),
    target_os = "ios",
    target_os = "watchos",
    target_os = "tvos"
))]
```

`gettimeofday` was first used in
cc367edd95
which predated the introduction of `clock_gettime` support in macOS
10.12 Sierra which became the minimum supported version in
58bbca958d.
2023-09-28 17:21:56 -04:00
David Tolnay
fd207e67d5
Const stabilize mem::discriminant 2023-09-28 11:07:06 -07:00
David Tolnay
a95f20c9ad
Add Exclusive forwarding impls (FnOnce, FnMut, Generator) 2023-09-28 10:22:19 -07:00
Tamir Duberstein
f264d28f2c
time: cfg(any(x)) is the same as cfg(x)
This was left over in c043a0e7d6.
2023-09-28 12:13:50 -04:00
Federico Stra
25648de28f isqrt: disable long running tests in Miri 2023-09-28 17:43:01 +02:00
bors
925f844164 Auto merge of #116230 - matthiaskrgr:rollup-hi1ciwy, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #116191 (Add regression test for rust-lang#56098)
 - #116214 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names)
 - #116221 (core/slice: Fix inconsistency between docs for `rotate_left` and `rotate_right`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-28 15:24:06 +00:00
DaniPopes
58ed8ad0df
Stabilize const_maybe_uninit_assume_init_read 2023-09-28 16:19:33 +02:00
Matthias Krüger
ff958ae3e4
Rollup merge of #116221 - ArchUsr64:patch-1, r=ChrisDenton
core/slice: Fix inconsistency between docs for `rotate_left` and `rotate_right`

A minor fix for documentation inconsistency as shown below:
## Before:
![2023_09_28_0k3_Kleki](https://github.com/rust-lang/rust/assets/83179501/569a49d3-0d72-49ac-92a2-ef5e1d94130b)
## After:
![image](https://github.com/rust-lang/rust/assets/83179501/afd0c8d7-6fb7-4878-801b-b47c8fe23c7d)
Docs url: https://doc.rust-lang.org/stable/core/primitive.slice.html#method.rotate_left
2023-09-28 15:58:44 +02:00
bors
dd91aba2fd Auto merge of #114882 - ChrisDenton:riddle-me, r=dtolnay
Update windows ffi bindings

Bump `windows-bindgen` to version 0.51.1. This brings with it some changes to the generated FFI bindings, but little that affects the code.

One change that does have more of an impact is `SOCKET` being `usize` instead of either `u64` or `u32` (as is used in std's public `SOCKET` type). However, it's now easy enough to abstract over that difference.

Finally I added a few new bindings that are likely to be used in pending PRs, mostly to make sure they're ok with the new metadata.

r? libs
2023-09-28 13:35:36 +00:00
Federico Stra
fcdfd5b0b9 isqrt: assume that isqrt takes half as many bits
https://github.com/rust-lang/rust/issues/89273#issuecomment-970581089
2023-09-28 14:05:10 +02:00