Commit Graph

10465 Commits

Author SHA1 Message Date
beetrees c021d2ddd4 Fallback {float} to f32 when f32: From<{float}> 2026-04-14 18:38:00 +02:00
bors 338dff3e3a Auto merge of #136006 - oli-obk:push-tzonluoyuwkq, r=wesleywiser
Start using pattern types in libcore



cc rust-lang/rust#135996

Replaces the innards of `NonNull` with `*const T is !null`.

This does affect LLVM's optimizations, as now reading the field preserves the metadata that the field is not null, and transmuting to another type (e.g. just a raw pointer), will also preserve that information for optimizations. This can cause LLVM opts to do more work, but it's not guaranteed to produce better machine code.

Once we also remove all uses of rustc_layout_scalar_range_start from rustc itself, we can remove the support for that attribute entirely and handle all such needs via pattern types
2026-04-13 21:54:46 +00:00
bors 17584a1819 Auto merge of #155253 - JonathanBrouwer:rollup-lERdTAB, r=JonathanBrouwer
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155162 (relnotes for 1.95)
 - rust-lang/rust#140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - rust-lang/rust#153604 (Fix thread::available_parallelism on WASI targets with threads)
 - rust-lang/rust#154193 (Implement EII for statics)
 - rust-lang/rust#154389 (Add more robust handling of nested query cycles)
 - rust-lang/rust#154435 (resolve: Some import resolution cleanups)
 - rust-lang/rust#155236 (Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`)
 - rust-lang/rust#155243 (cg_ssa: transmute between scalable vectors)
 - rust-lang/rust#153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - rust-lang/rust#154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - rust-lang/rust#154624 (Make `DerefPure` dyn-incompatible)
 - rust-lang/rust#154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - rust-lang/rust#154944 (Small refactor of `arena_cache` query values)
 - rust-lang/rust#155055 (UI automation)
 - rust-lang/rust#155062 (Move tests from `tests/ui/issues/` to appropriate directories)
 - rust-lang/rust#155131 (Stabilize feature `uint_bit_width`)
 - rust-lang/rust#155147 (Stabilize feature `int_lowest_highest_one`)
 - rust-lang/rust#155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
 - rust-lang/rust#155194 (Fix manpage version replacement and use verbose version)
2026-04-13 18:32:47 +00:00
Jonathan Brouwer 0af1a15c9a Rollup merge of #155147 - sorairolake:stabilize-int-lowest-highest-one, r=jhpratt
Stabilize feature `int_lowest_highest_one`

Tracking issue: rust-lang/rust#145203
FCP is finished in https://github.com/rust-lang/rust/issues/145203#issuecomment-4224883617

Closes rust-lang/rust#145203

@rustbot modify labels: +T-libs-api
2026-04-13 20:20:06 +02:00
Jonathan Brouwer 0bfc5efe04 Rollup merge of #155131 - sorairolake:stabilize-uint-bit-width, r=jhpratt
Stabilize feature `uint_bit_width`

Tracking issue: rust-lang/rust#142326
FCP is finished in https://github.com/rust-lang/rust/issues/142326#issuecomment-4224883142

Closes rust-lang/rust#142326

@rustbot modify labels: +T-libs-api
2026-04-13 20:20:05 +02:00
Jonathan Brouwer 8d8dcf142a Rollup merge of #154929 - davidgauch:const-default-lazy, r=jhpratt
Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank https://github.com/rust-lang/rust/pull/134628 and https://github.com/rust-lang/rust/pull/151190.
Tracking issue https://github.com/rust-lang/rust/issues/143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
2026-04-13 20:20:02 +02:00
Jonathan Brouwer 3f88653f77 Rollup merge of #154624 - theemathas:deref-pure-dyn-incompat, r=jackh726
Make `DerefPure` dyn-incompatible

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

If `DerefPure` were dyn-compatible, a trait object of a subtrait of `DerefPure` could be created by unsize-coercing an existing type that implements `DerefPure`. But then the trait object could have its own non-pure impl of `Deref`/`DerefMut`, which is unsound, since the trait object would implement `DerefPure`. Thus, we make `DerefPure` dyn-incompatible.

r? types
2026-04-13 20:20:01 +02:00
Oli Scherer 834137afd7 Use !null pattern type in libcore 2026-04-13 17:23:03 +02:00
David Wood ca6a85155b cg_llvm: replace sve_cast with simd_cast
Previously `sve_cast`'s implementation was abstracted to power both
`sve_cast` and `simd_cast` which supported scalable and non-scalable
vectors respectively. In anticipation of having to do this for another
`simd_*` intrinsic, `sve_cast` is removed and `simd_cast` is changed to
accept both scalable and non-scalable intrinsics, an approach that will
scale better to the other intrinsics.
2026-04-13 01:57:55 +00:00
bors 540f43a224 Auto merge of #155185 - matthiaskrgr:rollup-JYNqFhW, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#155171 (Patch musl's CVE-2026-6042 and CVE-2026-40200)
 - rust-lang/rust#153630 (Deprioritize doc(hidden) re-exports in diagnostic paths)
 - rust-lang/rust#152613 (unsafe keyword docs: bring back unsafe_op_in_unsafe_fn lint discussion)
 - rust-lang/rust#155142 (impl const Residual for ControlFlow)
2026-04-12 07:34:56 +00:00
Matthias Krüger 11469dc9f5 Rollup merge of #155142 - nxsaken:const_residual_control_flow, r=fee1-dead
impl const Residual for ControlFlow

Feature: rust-lang/rust#91285 (`try_trait_v2_residual`/`const_try_residual`)

r? @fee1-dead
2026-04-12 08:15:48 +02:00
bors d32e620a10 Auto merge of #155166 - JonathanBrouwer:rollup-YH2oUIz, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#155057 (Update libc to v0.2.184)
 - rust-lang/rust#154967 (Test(lib/sync): Fix `test_rwlock_max_readers` for x86 Win7)
 - rust-lang/rust#154994 (don't leak internal temporaries from `dbg!`)
 - rust-lang/rust#155130 (Stabilize feature `isolate_most_least_significant_one`)
 - rust-lang/rust#154925 (Make Box/Rc/Arc::into_array allocator-aware (and add doctest))
 - rust-lang/rust#155063 (`ty::Alias`: replace `def_id: did` with `def_id`)
2026-04-12 04:25:51 +00:00
Jacob Pratt d83352b491 Rollup merge of #155084 - scottmcm:add-transmute-prefix, r=Mark-Simulacrum
Initial functions to start on transmute v2

For context, see https://github.com/rust-lang/rfcs/pull/3844 and https://github.com/rust-lang/libs-team/issues/772

*Experimental* still, tracked under https://github.com/rust-lang/rust/issues/155079

This is just library functions.  A future PR will do compiler changes for things like lints.
2026-04-11 21:12:19 -04:00
Shun Sakai 63b5ab2994 Stabilize feature int_lowest_highest_one 2026-04-11 18:38:21 +09:00
nxsaken af2558094c impl const Residual for ControlFlow 2026-04-11 11:36:54 +04:00
Shun Sakai fe309a0bed Stabilize feature uint_bit_width 2026-04-11 07:46:34 +09:00
okaneco a69f989fe1 Stabilize feature isolate_most_least_significant_one 2026-04-10 17:59:02 -04:00
Scott McMurray 63d7f8e7ae Initial methods to start on transmute v2 2026-04-10 01:58:56 -07: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
David Gauch c7c9117326 Add const Default impls for LazyCell and LazyLock 2026-04-06 23:53:29 -07: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