27923 Commits

Author SHA1 Message Date
dianne b4d644b3b6 don't leak internal temporaries from dbg!
(cherry picked from commit 35be9f2208)
2026-04-16 09:57:24 -07:00
Mark Rousskov 6a605e2640 Apply replace-version-placeholder 2026-04-12 15:56:55 -04:00
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
Jacob Pratt 0cea5eef5e Rollup merge of #155004 - okaneco:fix_truncate_extend_label, r=jhpratt
core/num: Fix feature name for unstable `integer_extend_truncate` functions

Tracking issue: https://github.com/rust-lang/rust/issues/154330
Feature gate: `#![feature(integer_extend_truncate)]`

---

The feature name for the const unstable attribute was accidentally transposed when const traits were added in https://github.com/rust-lang/rust/pull/154356/changes/68c833906666fb428e6a32f8006f3bc8f6a7833e.
```diff
        #[unstable(feature = "integer_extend_truncate", issue = "154330")]
+       #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")]
```
2026-04-08 23:04:00 -04:00
Jacob Pratt f869e45669 Rollup merge of #154995 - RalfJung:minmaxby-tests, r=jhpratt
min/max_by tests: also check result

These tests were recently added in https://github.com/rust-lang/rust/pull/154761. IMO there's no reason to ignore the actual result of the function in the test, so let's also assert that this is correct.
2026-04-08 23:03:59 -04:00
okaneco c1ac7693f6 Fix feature name for unstable integer_extend_truncate functions
The feature name for the const unstable attribute was
accidentally transposed when const traits were added.
2026-04-08 15:55:00 -04:00
Jake Goulding eef4363403 Clarify that core::range::{Range,RangeFrom,RangeToInclusive} do not have special syntax
I'm ignoring the fact that there's a feature to change the behavior of
the syntax. I just want to help prevent confusing the people reading
the docs.
2026-04-08 14:05:12 -04:00
Jake Goulding 092f0ca1bd Clarify that core::range::RangeInclusive does not have special syntax
I'm ignoring the fact that there's a feature to change the behavior of
the syntax. I just want to help prevent confusing the people reading
the docs.
2026-04-08 14:02:37 -04:00
Ralf Jung 923311c40b min/max_by tests: also check result 2026-04-08 17:59:14 +02:00
Jonathan Brouwer 532c2b64d8 Rollup merge of #154778 - BennoLossin:frt-invariant, r=oli-obk
make field representing types invariant over the base type

We probably don't want to have any subtype relationship between any FRTs.

Reported-by: @dvdhrm "David Rheinsberg" <david@readahead.eu>
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Multiple.20LockedBy.20with.20Single.20Lock/near/579275908

r? @oli-obk
2026-04-08 14:22:02 +02:00
Jonathan Brouwer c8b04b6468 Rollup merge of #151898 - Randl:const-double-iter, r=oli-obk
constify DoubleEndedIterator

The only functions that can't be constified are `advance_back_by` (requires const range or const-hack), `nth_back` (requires `advance_back_by`), and `rfind` (requires const closures).

I've put it under `const_iter`, but I can open a separate tracking issue, though I think tracking all `Iterator` traits separately would be quite annoying, and we probably would prefer to constify them together anyway.
2026-04-08 14:21:59 +02:00
bors c753cef0df Auto merge of #154976 - jhpratt:rollup-e8XWRVU, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#154460 (Deduplication: Pulled common logic out from lower_const_arg_struct)
 - rust-lang/rust#154609 (Enable `#[diagnostic::on_const]` for local impls)
 - rust-lang/rust#154678 (Introduce #[diagnostic::on_move] on `Rc`)
 - rust-lang/rust#154902 (rustdoc: Inherit inline attributes for declarative macros)
2026-04-08 05:22:42 +00:00
Jacob Pratt 3be7b83ddc Rollup merge of #154678 - rperier:diagnostic_on_move_for_the_rc_type, r=tgross35
Introduce #[diagnostic::on_move] on `Rc`

This is related to the tracking issue rust-lang/rust#154181 and to the original issue rust-lang/rust#149862.
2026-04-07 23:05:31 -04:00
bors 30d0309fa8 Auto merge of #148486 - kpreid:vec-iter-drop, r=jhpratt
Explicitly forget the zero remaining elements in `vec::IntoIter::fold()`.



[Original description:] ~~This seems to help LLVM notice that dropping the elements in the destructor of `IntoIter` is not necessary. In cases it doesn’t help, it should be cheap since it is just one assignment.~~

This PR adds a function to `vec::IntoIter()` which is used used by `fold()` and `spec_extend()`, when those operations complete, to forget the zero remaining elements and only deallocate the allocation, ensuring that there will never be a useless loop to drop zero remaining elements when the iterator is dropped.

This is my first ever attempt at this kind of codegen micro-optimization in the standard library, so please let me know what should go into the PR or what sort of additional systematic testing might indicate this is a good or bad idea.
2026-04-08 02:06:51 +00:00
Jonathan Brouwer 2895451ff3 Rollup merge of #154950 - davidtwco:scalable-no-cfg, r=RalfJung
library: no `cfg(target_arch)` on scalable intrinsics

These intrinsics don't technically need to be limited to a specific architecture, they'll probably only make sense to use on AArch64, but this just makes it harder to use them in stdarch where it is appropriate (such as on `arm64ec`): requiring a rustc patch to land and be on nightly before stdarch work can proceed. So let's just not `cfg` them at all, they're perma-unstable anyway.

Fixes CI failure in rust-lang/stdarch#2071
2026-04-07 17:26:38 +02:00
Jonathan Brouwer a96fa87ee4 Rollup merge of #154922 - tgross35:builtins-inverse-trig, r=RalfJung
c-b: Export inverse hyperbolic trigonometric functions

Since a1feab1638 ("Use libm for acosh and asinh"), the standard library may link these functions to get a more accurate approximation; however, some targets do not have the needed symbols available. Add them to the compiler-builtins export list to make sure the fallback is usable.

Closes: https://github.com/rust-lang/rust/issues/154919
2026-04-07 17:26:36 +02: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 df0712da44 Rollup merge of #154825 - Lars-Schumann:non-zero-const-step, r=jhpratt
constify `Step for NonZero<u*>`

Tracking Issue: https://github.com/rust-lang/rust/issues/42168

I missed the constification of `Step for NonZero<u*>` in the recent https://github.com/rust-lang/rust/pull/153821, so here they are.

Had to constify the `Clone` / `TrivialClone` impls along the way https://github.com/rust-lang/rust/issues/142757 .
2026-04-07 17:26:33 +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
Jonathan Brouwer 6ee4118299 Rollup merge of #154761 - Vastargazing:add-regression-tests-cmp-argument-order, r=jhpratt
coretests: add argument order regression tests for min_by/max_by/minmax_by

PR rust-lang/rust#136307 introduced a regression in min_by, max_by, and minmax_by:
the compare closure received arguments as (v2, v1) instead of (v1, v2),
contrary to the documented contract.
Although this was fixed in rust-lang/rust#139357, no regression tests were added.
This PR adds regression tests for all three functions, verifying that compare
always receives arguments in the documented order (v1, v2).
As a bonus: first coretests coverage for minmax_by.
2026-04-07 17:26:31 +02:00
Jonathan Brouwer bdc9dc453d Rollup merge of #154928 - guiyuanju:fix-pin-doc, r=chenyukang
Fix pin docs

Split a long sentence to improve readability.

The original sentence required multiple readings for me to understand as a non-native speaker. The revised version is clearer and more readable, and likely easier for others as well.
2026-04-07 17:26:26 +02:00
David Wood 86f9e83b2d intrinsics: no cfg(target_arch) on scalable
These intrinsics don't technically need to be limited to a specific
architecture, they'll probably only make sense to use on AArch64,
but this just makes it harder to use them in stdarch where it is
appropriate (such as on `arm64ec`), requiring a rustc patch to land and
be on nightly before stdarch work can proceed - so just don't `cfg` them
at all.
2026-04-07 09:41:56 +00:00
guiyuanju db373833ce Fix pin docs
Split a long sentence to improve readability.
2026-04-07 17:22:59 +08:00
Trevor Gross 8930f50b96 c-b: Export inverse hyperbolic trigonometric functions
Since a1feab1638 ("Use libm for acosh and asinh"), the standard
library may link these functions to get a more accurate approximation;
however, some targets do not have the needed symbols available. Add them
to the compiler-builtins export list to make sure the fallback is
usable.
2026-04-06 23:17:13 -05:00
Laine Taffin Altman 99d09862b1 impl AsyncFn{,Mut,Once} for core::sync::SyncView 2026-04-06 18:10:00 -07:00
Laine Taffin Altman f5830a71c8 core::sync::SyncView: minor doc nits 2026-04-06 18:05:35 -07:00
Laine Taffin Altman 4b35912a03 Add core::sync::SyncView<T: Sync>::as_pin
This completes the existing suite of `as_ref`, `as_mut`, and `as_pin_mut` methods.
2026-04-06 18:05:34 -07:00
Laine Taffin Altman b36062071e core::sync::SyncView: constify all the impls 2026-04-06 18:00:22 -07:00
Laine Taffin Altman 4a3dbe3642 core::sync::SyncView: make use of AsMut
This moves the inherent `get_mut` method to be `AsMut::as_mut`, and renames `get_pin_mut` to `as_pin_mut` accordingly.  It also constifies the `AsRef` (and `AsMut`) implementations, preserving the `const` status of the original `get_mut`, albeit only unstably.
2026-04-06 18:00:22 -07:00
Laine Taffin Altman 5adc0312b8 core::sync: Rename Exclusive to SyncView 2026-04-06 18:00:21 -07:00
Jacob Pratt 7913288d66 Rollup merge of #154891 - WaffleLapkin:deregress-manually-drop-matching, r=JohnTitor
implement `StructuralPartialEq` for `MaybeDangling`

This fixes -- a stable-to-stable regression where constants of type `ManuallyDrop<T>` would not be allowed to be used as a pattern due to `MaybeDangling<T>` in `ManuallyDrop<T>` not implementing `StructuralPartialEq`.

Fixes https://github.com/rust-lang/rust/issues/154890

I'm sorry, @theemathas, I forgot to address your [comment](https://github.com/rust-lang/rust/pull/149614#discussion_r2587340079) 😭
2026-04-06 19:56:41 -04:00
Lars Schumann fc71bad873 de-non_const some iterator methods 2026-04-06 21:16:10 +00:00
Romain Perier 92ed4a21ff Introduce #[diagnostic::on_move] on Rc
This annotates the `Rc` type with the diagnostic attribute
`#[diagnostic::on_move]`. Now when a moved `Rc` is borrowed,
a suggestion to clone it is made, with a label explaining why.
2026-04-06 19:05:55 +02:00
Waffle Lapkin d5f98fbb27 implement StructuralPartialEq for MaybeDangling
This fixes a stable-to-stable regression where constants of type
`ManuallyDrop<T>` would not be allowed to be used as a pattern due to
`MaybeDangling<T>` in `ManuallyDrop<T>` not implementing
`StructuralPartialEq`.
2026-04-06 18:18:32 +02:00
Jonathan Brouwer 6bf2ce0f38 Rollup merge of #154849 - Jules-Bertholet:case-ignorable, r=Mark-Simulacrum
Promote `char::is_case_ignorable` from perma-unstable to unstable

(Take two of https://github.com/rust-lang/rust/pull/154658, which was closed when GitHub Codespaces somehow managed to squash the entire commit history of rust-lang/rust into one commit)

This function is currently used in the implementation of `str::to_lowercase()`. There is no reason to restrict it to the stdlib, though. Reimplementations of string casing for types other than `str` -> `String` shouldn't need to waste space with a duplicate copy of this table.

@rustbot label A-unicode T-libs-api

r? @Mark-Simulacrum
2026-04-06 08:27:52 +02:00
Jonathan Brouwer e6ea1ae6a3 Rollup merge of #151899 - Randl:const-iter-fold, r=oli-obk
Constify fold, reduce and last for iterator

These functions only require the addition of `[const]` in appropriate places, so it feels like almost a trivial change. Most of the others require either consitifying additional traits, const closures, or both.
2026-04-06 08:27:50 +02:00
Jules Bertholet c88ef81131 Promote char::is_case_ignorable from perma-unstable to unstable 2026-04-05 13:35:09 +00: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
Lars Schumann 256f036558 constify Step for NonZero ints 2026-04-04 18:27:08 +00:00
Jonathan Brouwer 617fdd824b Rollup merge of #154707 - nik-contrib:substr-new-range, r=Mark-Simulacrum
Make `substr_range` and `subslice_range` return the new `Range` type

Makes the unstable `substr_slice` and `substr_range` functions return the new `core::range::Range` type, instead of the old `core::ops::Range`.

Unblocks the [stabilization](https://github.com/rust-lang/rust/pull/141266) of `#![feature(substr_range)]`, see https://github.com/rust-lang/rust/pull/141266#issuecomment-3599724293
2026-04-04 20:19:59 +02: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
Jonathan Brouwer f523f841db Rollup merge of #154052 - cdown:cdown/2026-03-19/precision, r=Mark-Simulacrum
float: Fix panic at max exponential precision

Rust's formatting machinery allows precision values of up to u16::MAX. Exponential formatting works out the number of significant digits to use by adding one (for the integral digit before the decimal point).

This previously used usize precision, so the maximum validated precision did not overflow, but in commit fb9ce02976 ("Limit formatting width and precision to 16 bits.") the precision type was narrowed to u16 without widening that addition first.

As a result an exponential precision value of 65535 is no longer handled correctly, because the digit count wraps to 0, and thus "{:.65535e}" panics in flt2dec::to_exact_exp_str with "assertion failed: ndigits > 0". Other formats (and the parser) accept values up to u16::MAX.

A naive fix would be to widen that addition back to usize, but that still does not properly address 16-bit targets, where usize is only guaranteed to be able to represent values up to u16::MAX. The real issue is that this internal API is expressed in the wrong units for the formatter.

Fix this by changing exact exponential formatting to take fractional digits internally as well, and compute the temporary significant digit bound only when sizing the scratch buffer. To support that let's also make formatted length accounting saturate so that extremely large rendered outputs do not reintroduce overflows in padding logic.

This preserves the existing intent and keeps FormattingOptions compact while making formatting work consistently again.
2026-04-04 20:19:58 +02:00
bors e0e95a7187 Auto merge of #154815 - JonathanBrouwer:rollup-sdqRx2J, r=JonathanBrouwer
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#149868 (rustc: Stop passing `--allow-undefined` on wasm targets)
 - rust-lang/rust#153555 (Clarified docs in std::sync::RwLock + added test to ensure that max reader count is respected)
 - rust-lang/rust#152851 (Fix SGX delayed host lookup via ToSocketAddr)
 - rust-lang/rust#154051 (use libm for acosh and asinh)
 - rust-lang/rust#154581 (More informative `Debug for vec::ExtractIf`)
 - rust-lang/rust#154461 (Edit the docs new_in() and with_capacity_in())
 - rust-lang/rust#154526 (Panic/return false on overflow in no_threads read/try_read impl)
 - rust-lang/rust#154798 (rustdoc-search: match path components on words)
2026-04-04 17:46:11 +00:00
Manuel Drehwald 3a7ffdc12d add current autodiff limitations 2026-04-04 19:20:32 +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