Commit Graph

8548 Commits

Author SHA1 Message Date
Jacob Pratt 9ebe418dc6 Rollup merge of #153038 - pthariensflame:syncview-rename, r=Amanieu
core::sync: rename `Exclusive` to `SyncView` and make improvements

This PR implements the renaming of `core::sync::Exclusive` to `SyncView` as decided in rust-lang/rust#98407.  To preserve the ability to search for the old name, it adds `Exclusive` as a `doc_alias`.

It also makes the following additional changes:

- Converting the `get_mut` method to being an instance of `AsMut::as_mut`.  In the process, it makes both the new `impl AsMut` and the existing `impl AsRef` `const`, and it also renames `get_pin_mut` to `as_pin_mut` for consistency.  This direction follows a suggestion from rust-lang/rust#98407.
- Adding an `as_pin` method that can only be used when the wrapped type implements `Sync`, to complete the square of access methods.
- Making as many of the existing `impl`s `const` as possible; this involved making the existing `impl Default` no longer derived.
- Adding `impl`s for `AsyncFnOnce`, `AsyncFnMut`, and `AsyncFn`, akin to the existing `impls` for `FnOnce`, `FnMut`, and `Fn`.

It does not yet do the following, which may be desirable:

- Fixing/improving the documentation to address the concern pointed out in rust-lang/rust#146245.

It previously did the following, but this was removed after discussion:
- Adding an `impl` for (`const`) `Iterator`, which felt in line with the existing `impl`s for `Future` and `Coroutine`.
2026-04-09 02:31:08 -04:00
Jonathan Brouwer 87b48159c3 Rollup merge of #154837 - moturus:motor-os-abort, r=jhpratt
library: std: motor: use OS' process::exit in abort_internal

abort_internal() is used in panics; if it calls core::intrinsics::abort(), the process triggers an invalid op code (on x86_64), which is a much harder "abort" than a user-controlled exit via a panic.

Most other OSes don't use core::intrinsics::abort() here, but either libc::abort(), or a native OS abort/exit API.
2026-04-07 17:26:34 +02:00
Jonathan Brouwer 33528612ba Rollup merge of #154795 - ZuseZ4:autodiff-general-docs, r=oli-obk
Add more info about where autodiff can be applied

It's taken quite a few years, but we finally have a PR open to distribute Enzyme: https://github.com/rust-lang/rust/pull/154754
I therefore went over the docs once more and noticed we don't explain a lot of the most basic features, which we added over the years and have since taken for granted.

@Sa4dUs, do you think there are more interesting cases that we are missing?

Generally, there's still a lot of complexity in it, especially for people who haven't used Enzyme before.
To some extent, that's just a result of my general design goal to expose all performance-relevant features of Enzyme, and let users explore nice abstractions on top if it, via crates. Since we don't have those nightly users yet, users haven't had time to build nicer abstractions on top of it.

I also feel like a more guided book would be a better first introduction to Enzyme, but for now I just focused on the list of features.

r? @oli-obk
2026-04-07 17:26:32 +02:00
Laine Taffin Altman 5adc0312b8 core::sync: Rename Exclusive to SyncView 2026-04-06 18:00:21 -07:00
U. Lasiotus 92426ef482 library: std: motor: use OS' process::exit in abort_internal
abort_internal() is used in panics; if it calls
core::intrinsics::abort(), the process triggers an
invalid op code (on x86_64), which is a much harder "abort"
than a user-controlled exit via a panic.

Most other OSes don't use core::intrinsics::abort() here,
but either libc::abort(), or a native OS abort/exit API.
2026-04-04 18:53:09 -07:00
bors c92036b45b Auto merge of #154832 - JonathanBrouwer:rollup-xJmqF28, r=JonathanBrouwer
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#150129 (`BorrowedCursor`: make `init` a boolean)
 - rust-lang/rust#154830 (miri subtree update)
2026-04-05 00:08:46 +00:00
Jonathan Brouwer b7c319cfc4 Rollup merge of #150129 - a1phyr:improve_buf_api, r=joshtriplett
`BorrowedCursor`: make `init` a boolean

This PR changes uninitialized bytes tracking in `BorrowedBuf` from being byte-wise to being buffer-wise.

I've put all the API around `init` a new unstable feature `borrowed_buf_init`, to split the part that needs it and the part that doesn't. It will avoids accidental stabilization of this part.

I'm not really convinced of the rename of `advance_unchecked` to `advance`, but I did it anyway. The old `advance` was kept as `advance_checked`.

Alternative of rust-lang/rust#148937

Cc rust-lang/rust#78485 rust-lang/rust#117693
Cc @joshtriplett

r? @Amanieu
2026-04-05 00:18:45 +02:00
bors 4e836866b5 Auto merge of #154824 - JonathanBrouwer:rollup-neQUhVI, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#147552 ([Debugger Visualizers] Optimize lookup behavior)
 - rust-lang/rust#154052 (float: Fix panic at max exponential precision)
 - rust-lang/rust#154706 (fix compilation of time/hermit.rs)
 - rust-lang/rust#154707 (Make `substr_range` and `subslice_range` return the new `Range` type)
 - rust-lang/rust#154767 (triagebot: roll library reviewers for `{coretests,alloctests}`)
 - rust-lang/rust#154797 (bootstrap: Include shorthand aliases in x completions)
2026-04-04 21:00:26 +00:00
Jonathan Brouwer ccac77a61a Rollup merge of #154706 - hermit-os:time-hermit, r=Mark-Simulacrum
fix compilation of time/hermit.rs

https://github.com/rust-lang/rust/pull/154518 has broken compiling std for Hermit by unwrapping an `i32`.

This PR converts the `i32` to an `io::Result` before unwrapping.

Closes https://github.com/rust-lang/rust/issues/154626.
Closes https://github.com/hermit-os/hermit-rs/issues/965.

r? @Mark-Simulacrum
2026-04-04 20:19:59 +02:00
Manuel Drehwald c0b383cf04 Add more info about where autodiff can be applied 2026-04-04 19:20:28 +02:00
Jonathan Brouwer 67898f832a Rollup merge of #154526 - asder8215:no_threads_read_overflow, r=Mark-Simulacrum
Panic/return false on overflow in no_threads read/try_read impl

As per discussion with Mark in rust-lang/rust#153555, it's possible for `no_threads` impl of `RwLock` to trigger a silent overflow on `RwLock::read`/`RwLock::try_read` if we try to acquire more than `isize::MAX` read locks. This PR adds an explicit panic/return false when our read lock counter is at `isize::MAX` for `RwLock::read`/`RwLock::try_read`; the message is similar to that of sys/sync/rwlock/futex.rs [here](https://github.com/rust-lang/rust/blob/fb27476aaf1012f1f6ace6306f9b990e0d989c31/library/std/src/sys/sync/rwlock/futex.rs#L143).
2026-04-04 17:19:12 +02:00
Jonathan Brouwer a660f77505 Rollup merge of #154461 - lms0806:issue_154452, r=Mark-Simulacrum
Edit the docs new_in() and with_capacity_in()

I have updated the documentation for new_in().

While reviewing the code, I noticed that the documentation for with_capacity_in() was also inaccurate, so I have corrected it.

Close rust-lang/rust#154452
2026-04-04 17:19:11 +02:00
Jonathan Brouwer 69751ec861 Rollup merge of #154051 - malezjaa:approximations-acosh-and-asinh, r=tgross35
use libm for acosh and asinh

Fixes rust-lang/rust#153878

Uses libm for `acosh` and `asinh`
2026-04-04 17:19:10 +02:00
Jonathan Brouwer a5d2326d6e Rollup merge of #152851 - fortanix:jb/fix-sgx-non-ip-addr, r=Mark-Simulacrum
Fix SGX delayed host lookup via ToSocketAddr

rust-lang/rust#146541 introduced a regression in the `x86_64-fortanix-unknown-sgx` target, where arguments to TcpStream::connect and TcpListener::bind are no longer being passed down correctly to the underlying platform, resulting in connection/bind failures

* Add a test for the desired behavior (this test passes on Rust 1.33 through 1.91)
* Refactor lookup_host logic again

Fixes rust-lang/rust#152848

cc @joboet
2026-04-04 17:19:10 +02:00
Jonathan Brouwer 08343b5707 Rollup merge of #153555 - asder8215:rwlock_docs, r=Mark-Simulacrum
Clarified docs in std::sync::RwLock + added test to ensure that max reader count is respected

This addresses the issue with the [`std::sync::RwLock` docs](https://doc.rust-lang.org/std/sync/struct.RwLock.html) in rust-lang/rust#115338. It centers around the following lines:

> An `RwLock` will allow any number of readers to acquire the lock as long as a writer is not holding the lock.

It's true that the `RwLock` in theory should allow any number of readers to acquire the lock when a writer is not holding it, but this may not be true in the implementation and could be os dependent. I decided to replace "any number of readers" to "multiple", so that it implies that more than 1 reader can acquire the lock, but you can't necessarily take away that this value is unbounded.

@rustbot label +A-docs
2026-04-04 17:19:09 +02:00
malezjaa a1feab1638 use libm for acosh and asinh 2026-04-04 09:28:39 +02:00
Jacob Pratt 53af5aba8f Rollup merge of #154732 - xtqqczze:GH154679, r=tgross35
fix(std): avoid AT_MINSIGSTKSZ on uclibc targets

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

`AT_MINSIGSTKSZ` is not defined on uclibc.

r? @tgross35
2026-04-02 20:53:34 -04:00
xtqqczze b0c4b6ef46 fix(std): avoid AT_MINSIGSTKSZ on uclibc targets 2026-04-02 23:03:28 +01:00
Jonathan Brouwer f0ce20c438 Rollup merge of #154442 - nik-contrib:derive-root, r=jhpratt
Export `derive` at the crate root: `core::derive` and `std::derive`

This PR makes the `derive` macro available at the crate root:

```rust
#[std::derive(Clone)]
#[core::derive(Copy)]
struct X;
```

ACP: https://github.com/rust-lang/libs-team/issues/766

Tracking issue: https://github.com/rust-lang/rust/issues/154645
2026-04-02 22:13:54 +02:00
Martin Kröning 3d55f38a7f fix compilation of time/hermit.rs
https://github.com/rust-lang/rust/pull/154518 has broken compiling std for Hermit by unwrapping an `i32`.
This commit converts the `i32` to an `io::Result` before unwrapping.
2026-04-02 10:37:15 +02:00
Nik Revenco fec0998732 Export derive at core::derive and std::derive 2026-04-01 08:54:39 +00:00
Yukang 8296e03d86 Rollup merge of #153207 - devnexen:net_set_linger_fix, r=Amanieu
std::net: clamp linger timeout value to prevent silent truncation.

Duration::as_secs() returns u64 but l_linger field type is narrower, c_int on most unix platforms, c_ushort on cygwin and windows. clamping before the cast, consistent with how set_timeout handles this.
2026-04-01 10:43:55 +08:00
bors 700cfa8c93 Auto merge of #154649 - JonathanBrouwer:rollup-3KmleSY, r=JonathanBrouwer
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#154249 (Mention on which items the `missing_doc_code_examples` is not emitted)
 - rust-lang/rust#154266 (UdpSocket: document `recv/recv_from` differences)
2026-03-31 23:24:59 +00:00
Jonathan Brouwer 807b9aec35 Rollup merge of #154266 - nia-e:udp-socket-docs, r=Mark-Simulacrum
UdpSocket: document `recv/recv_from` differences

Per libs-api consensus, fixes rust-lang/rust#149392 by documenting possible platform-specific behavior in `UdpSocket`.

r? libs
2026-03-31 22:18:34 +02:00
bors 48cc71ee88 Auto merge of #154638 - JonathanBrouwer:rollup-oLBZ6Tr, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#150752 (Update libc to v0.2.183)
 - rust-lang/rust#152432 (add rustc option -Zpacked-stack)
 - rust-lang/rust#154634 (Use `Hcx`/`hcx` consistently for `StableHashingContext`.)
 - rust-lang/rust#154635 (./x run miri: default to edition 2021)
2026-03-31 20:16:05 +00:00
Jonathan Brouwer 470facce55 Rollup merge of #150752 - thesummer:update-libc-0.2.179, r=tgross35
Update libc to v0.2.183

Follow-up of https://github.com/rust-lang/rust/pull/150484.
This PR updates libc to include the latest patches to make rtems target (and probably others) compile again.
2026-03-31 15:27:18 +02:00
Jan Sommer 05cda351da Don't use field initializers for libc::timespec
This create conflict if the timespec of a target has additional fields.
Use libc::timespec::default() instead
2026-03-31 08:44:14 +02:00
Peter Jaszkowiak 620e92f016 stabilize new Range type and iterator
stabilizes `core::range::Range`
stabilizes `core::range::RangeIter`
stabilizes `std::range` which was missed in prior PRs

Updates docs to reflect stabilization (removed "experimental")

`RangeIter::remainder` is excluded from stabilization
2026-03-30 22:17:27 -06:00
lms0806 a374727025 resolve: issue 154452 solve 2026-03-30 16:31:15 +09:00
Mahdi Ali-Raihan 1d7d435d08 Panic on unlocking a non-read locked RwLock + provided better error msgs 2026-03-29 20:06:25 -04:00
Jonathan Brouwer de649f4462 Rollup merge of #154530 - fee1-dead-contrib:push-syplyyvkpsol, r=Noratrieb
update zulip link in `std` documentation

#docs doesn't seem to exist anymore, so point people to `t-libs`. Also include direct link to topic since Zulip is world-viewable now.
2026-03-29 21:39:31 +02:00
Jonathan Brouwer 95acbdfd8f Rollup merge of #154518 - stepancheg:hermit-panic, r=Mark-Simulacrum
Panic in Hermit clock_gettime

Follow-up to rust-lang/rust#154234.

r? @Mark-Simulacrum
2026-03-29 21:39:30 +02:00
Jonathan Brouwer 46dcf270c2 Rollup merge of #154416 - vitkyrka:split-diag, r=Noratrieb
Add `IoSplit` diagnostic item for `std::io::Split`

Similar to the existing `IoLines` item.  It will be used in Clippy to detect uses of `Split` leading to infinite loops similar to the existing lint for `Lines`.
2026-03-29 21:39:29 +02:00
Jonathan Brouwer 880fe193a1 Rollup merge of #154322 - m4rch3n1ng:hash-map-macro, r=Mark-Simulacrum
feat: reimplement `hash_map!` macro

originally implemented in rust-lang/rust#144070, this had to be reverted in rust-lang/rust#148049 due to name ambiguity, as the macro was automatically put into the prelude. now, that rust-lang/rust#139493 has landed, it is possible to have a top-level macro, that is not exported by default, which should make it possible to reland this again.

implements rust-lang/rust#144032
implementation from rust-lang/rust#144070, original author has been added as co-author
effectively reverts rust-lang/rust#148049
2026-03-29 21:39:29 +02:00
Jonathan Brouwer 2a18b885ce Rollup merge of #154074 - dianne:dbg-temp-scopes, r=Mark-Simulacrum
don't drop arguments' temporaries in `dbg!`

Fixes rust-lang/rust#153850

Credit to @theemathas for help with macro engineering ^^

r? libs
2026-03-29 21:39:26 +02:00
dianne 51816efcc0 don't drop arguments' temporaries in dbg! 2026-03-29 06:38:38 -07:00
Deadbeef 64ee85d511 update zulip link in std documentation
#docs doesn't seem to exist anymore, so point people to `t-libs`.
Also include direct link to topic since Zulip is world-viewable now.
2026-03-29 01:02:53 -04:00
Mahdi Ali-Raihan 4b0caec04b Panic/return false on overflow in no_threads read/try_read impl 2026-03-28 22:14:10 -04:00
Guillaume Gomez 16d2a68103 Rollup merge of #154320 - bend-n:trim_prefix_suffix_for_paths, r=Mark-Simulacrum
`trim_prefix` for paths

under rust-lang/rust#142312?

its a useful method.
2026-03-29 00:06:52 +01:00
Mahdi Ali-Raihan 83a7a4ad74 Clarified docs in std::sync::RwLock and added a test that checks if we can reach max reader 2026-03-28 18:55:55 -04:00
Stepan Koltsov 27242aa319 Panic in Hermit clock_gettime 2026-03-28 21:00:03 +00:00
Ralf Jung 54b4b990cd Rollup merge of #154185 - asder8215:no_threads_write_impl, r=joboet
Prevent no_threads RwLock's write() impl from setting mode to -1 when it is locked for reading

In my time updating the docs to `std::sync::RwLock` and adding a test verifying that max reader count is reachable in rust-lang/rust#153555, I noticed that the no_threads RwLock's `write()` implementation always sets the `mode` to `-1` (denoting writer locked) even though it could be reader locked. I feel like that's logically incorrect and that it should only be setting the `mode` to `-1` when we know that the mode is unlocked (`0`); `write()` should mirror the code that `read()` and `try_read()` has with `try_write()`.

For reference on read/try_read and write/try_write current implementations:
```rust
    #[inline]
    pub fn read(&self) {
        let m = self.mode.get();
        if m >= 0 {
            self.mode.set(m + 1);
        } else {
            rtabort!("rwlock locked for writing");
        }
    }

    #[inline]
    pub fn try_read(&self) -> bool {
        let m = self.mode.get();
        if m >= 0 {
            self.mode.set(m + 1);
            true
        } else {
            false
        }
    }

    #[inline]
    pub fn write(&self) {
        if self.mode.replace(-1) != 0 { // <-- This behavior logically does something different than what `try_write` does
            rtabort!("rwlock locked for reading")
        }
    }

    #[inline]
    pub fn try_write(&self) -> bool {
        if self.mode.get() == 0 {
            self.mode.set(-1);
            true
        } else {
            false
        }
    }
```

r? @jhpratt
2026-03-28 13:15:51 +01:00
Ralf Jung d289cc4a38 Rollup merge of #154029 - xtqqczze:clear, r=joboet
Replace `truncate(0)` with `clear()`
2026-03-28 13:15:50 +01:00
Stuart Cook d471d0ba1b Rollup merge of #154234 - stepancheg:hermit-timespec, r=Mark-Simulacrum
Use common Timestamp impl in Hermit (attempt 2)

The goal is to have less code to maintain, so to be able to make changes easier.

Previous attempt https://github.com/rust-lang/rust/pull/148847 was asked to postpone because there was restructure of code, which is complete now.

r? joboet
2026-03-28 15:01:39 +11:00
Stuart Cook cd28898c15 Rollup merge of #154357 - RalfJung:uefi-tcp-send, r=joboet
uefi: extend comment for TcpStream Send impl

Based on discussion on [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Send.20on.20thread-free.20targets/with/581473760).
2026-03-28 15:01:36 +11:00
Ralf Jung 632d24c144 adjust wording
Co-authored-by: David Rheinsberg <david@readahead.eu>
2026-03-26 11:17:47 +01:00
Vincent Whitchurch eee01dd211 Add IoSplit diagnostic item for std::io::Split
Similar to the existing `IoLines` item.  It will be used in Clippy to
detect uses of `Split` leading to infinite loops similar to the existing
lint for `Lines`.
2026-03-26 09:40:58 +00:00
Ralf Jung 3271d4cadf uefi: extend comment for TcpStream Send impl 2026-03-25 08:33:35 +01:00
Theemathas Chirananthavat 1e4c1d6f75 Make PinCoerceUnsized require Deref
Also, delete impls on non-Deref types.

Pin doesn't do anything useful for non-Deref types, so PinCoerceUnsized
on such types makes no sense.

This is a breaking change, since stable code can observe the deleted
`PinCoerceUnsized` impls by uselessly coercing between such types
inside a `Pin`.

There is still some strange behavior, such as `Pin<&mut i32>` being
able to coerce to `Pin<&dyn Send>`, but not being able to coerce to
`Pin<&i32>`. However, I don't think it's possible to fix this.

Fixes https://github.com/rust-lang/rust/issues/145081
2026-03-25 11:40:27 +07:00
bendn cc65ec1892 trim prefix/suffix for paths 2026-03-24 23:07:22 +07:00