10446 Commits

Author SHA1 Message Date
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
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
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
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 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 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
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
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
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
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 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
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
bors 0312a55fe4 Auto merge of #154802 - matthiaskrgr:rollup-HWNmEyC, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#154376 (Remove more BuiltinLintDiag variants - part 4)
 - rust-lang/rust#154731 (llvm: Fix array ABI test to not check equality implementation)
 - rust-lang/rust#127534 (feat(core): impl Step for NonZero<u*>)
 - rust-lang/rust#154703 (Fix trailing comma in lifetime suggestion for empty angle brackets)
 - rust-lang/rust#154776 (Fix ICE in read_discriminant for enums with non-contiguous discriminants)
2026-04-04 14:36:56 +00:00
Chris Down 2ae6c6176e 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 21:44:05 +09:00
Benno Lossin cb37ee2c87 make field representing types invariant over the base type
Reported-by: David Rheinsberg <david@readahead.eu>
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Multiple.20LockedBy.20with.20Single.20Lock/near/579275908
2026-04-03 21:34:31 +02:00
Matthias Krüger dd46057276 Rollup merge of #154653 - mejrs:append_const_msg, r=JonathanBrouwer
Remove rustc_on_unimplemented's append_const_msg

This does nothing because it is unreachable within the compiler. It also doesn't seem that useful since all the traits it was on are `const` now.

Will make pr to rustc-dev-guide docs later.
2026-04-03 20:47:38 +02:00
Matthias Krüger a4d278d889 Rollup merge of #153592 - zedddie:adt_const_params_restricted_privacy-gate, r=BoxyUwU
Add  `min_adt_const_params` gate

Add `min_adt_const_params` feature gate to disallow `ConstParamTy_` impl for types which fields visibility mismatches with struct itself

r? BoxyUwU
2026-04-03 20:47:37 +02:00
Jalil David Salamé Messina d6b280675e feat(core): impl Step for NonZero<u*>
Implement Step for NonZero unsigned integers as discussed in
[libs-team#130][1].

[1]: https://github.com/rust-lang/libs-team/issues/130

`step_nonzero_impls` was adapted from `step_integer_impls` and the tests
were adapted from the step tests.

Signed-off-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
2026-04-03 13:25:13 -03:00
David Wood 957320cdb1 cg_llvm: sve_cast intrinsic
Abstract over the existing `simd_cast` intrinsic to implement a new
`sve_cast` intrinsic - this is better than allowing scalable vectors to
be used with all of the generic `simd_*` intrinsics.
2026-04-03 10:37:42 +00:00
David Wood 4fbcb031de cg_llvm: sve_tuple_{create,get,set} intrinsics
Clang changed to representing tuples of scalable vectors as
structs rather than as wide vectors (that is, scalable vector types
where the `N` part of the `<vscale x N x ty>` type was multiplied by
the number of vectors). rustc mirrored this in the initial implementation
of scalable vectors.

Earlier versions of our patches used the wide vector representation and
our intrinsic patches used the legacy
`llvm.aarch64.sve.tuple.{create,get,set}{2,3,4}` intrinsics for creating
these tuples/getting/setting the vectors, which were only supported
due to LLVM's `AutoUpgrade` pass converting these intrinsics into
`llvm.vector.insert`. `AutoUpgrade` only supports these legacy intrinsics
with the wide vector representation.

With the current struct representation, Clang has special handling in
codegen for generating `insertvalue`/`extractvalue` instructions for
these operations, which must be replicated by rustc's codegen for our
intrinsics to use. This patch implements new intrinsics in
`core::intrinsics::scalable` (mirroring the structure of
`core::intrinsics::simd`) which rustc lowers to the appropriate
`insertvalue`/`extractvalue` instructions.
2026-04-03 10:27:30 +00:00
Jacob Pratt e1cd0ad490 Rollup merge of #154691 - tgross35:bool-try-from-int, r=cuviper
core: Update the feature gate on `TryFrom<integer> for bool`

This implementation was added recently in f12288ec26 ("TryFrom<integer> for bool") but used an old feature gate and stabilization version. Update to reflect when these were actually added.
2026-04-02 20:53:33 -04: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
zedddie 72fbd1c0b5 implement min_adt_const_params feature 2026-04-02 17:10:41 +02:00
Nik Revenco 8b06612c9a Make substr_range and subslice_range return the new Range type 2026-04-02 09:09:56 +00:00
Trevor Gross 02b516afd9 core: Update the feature gate on TryFrom<integer> for bool
This implementation was added recently in f12288ec26
("TryFrom<integer> for bool") but used an old feature gate and
stabilization version. Update to reflect when these were actually added.
2026-04-01 14:34:20 -04:00
bors 2bd7a97871 Auto merge of #154668 - jhpratt:rollup-ePnl7Di, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#154356 (    Add integer truncation and extension methods)
 - rust-lang/rust#154641 (build_helper: fix yarn locking, add check, and bump lockfile)
 - rust-lang/rust#154647 (change `c_double` to `f32` on `avr` targets)
 - rust-lang/rust#154655 (Fix associated type bound suggestion span issue)
2026-04-01 08:58:47 +00:00
Nik Revenco fec0998732 Export derive at core::derive and std::derive 2026-04-01 08:54:39 +00:00
Jacob Pratt 1fb655c590 Rollup merge of #154647 - folkertdev:avr-c_double-f32, r=tgross35
change `c_double` to `f32` on `avr` targets

Extracted from https://github.com/rust-lang/rust/pull/152980. That version also makes this change for `msp430` but that is actually incorrect based on https://www.ti.com/lit/ug/slau132r/slau132r.pdf table 5-1 that specifies `double` as `f64`.

r? tgross35
cc @Patryk27 @workingjubilee
2026-04-01 03:35:11 -04:00
Jacob Pratt 60e85c7ec3 Rollup merge of #154356 - joshtriplett:libs-api-integer-truncate-extend, r=jhpratt
Add integer truncation and extension methods

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

This provides `.truncate()`, `.saturating_truncate()`, `.checked_truncate()`, and `.extend()`.

These only work within the same signedness (use `.cast_signed()` and `.cast_unsigned()` to change sign).

The truncation methods only work to smaller (or equal) types. `.extend()` only works to larger (or equal) types.

For the purposes of truncation and extending, `u128` is considered larger than or equal to the size of `usize`, and `usize` is considered larger than `u16` or `u8`. We might, in the future, want to consider ways to expand this.

Much of this was pair-programmed with @Amanieu.

In order to seal the new traits, this PR also adds a `core::sealed::Sealed`, like the one in `std`. I didn't modify `std` to re-export the same one, since by definition it isn't nameable, and since doing that would require that it be nameable (even if it was `#[unstable]`).
2026-04-01 03:35:10 -04:00