Commit Graph

27809 Commits

Author SHA1 Message Date
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 ab05593ad9 Rollup merge of #154486 - pthariensflame:patch-1, r=Mark-Simulacrum
std_detect on AArch64 Darwin: Detect FEAT_SVE_B16B16

This is now exposed via `sysctl` as of macOS "Tahoe" 26.4 (or possibly earlier).
2026-03-29 21:39:29 +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
bors cd14b73b4a Auto merge of #154459 - tgross35:destabilize-range-iter-remainder, r=scottmcm
core: Destabilize beta-stable `RangeInclusiveIter::remainder`



Destabilize `RangeInclusiveIter::remainder` and move `{RangeIter,RangefromIter}::remainder` to the `new_range_api` feature gate.

Original tracking issue: https://github.com/rust-lang/rust/issues/125687
New tracking issue: https://github.com/rust-lang/rust/issues/154458
Discussion: https://rust-lang.zulipchat.com/#narrow/channel/327149-t-libs-api.2Fapi-changes/topic/.60RangeFrom.3A.3Aremainder.60.20possible.20panic/with/582108913
2026-03-29 16:22:03 +00:00
dianne 51816efcc0 don't drop arguments' temporaries in dbg! 2026-03-29 06:38:38 -07:00
Trevor Gross 0bb3fe315e core: Move {RangeIter, RangeFromIter}::remainder to new_range_remainder
Split the remainder functions from the rest of `std::range`.
2026-03-29 02:11:32 -05:00
Jonathan Brouwer b7ea4b70db Rollup merge of #154520 - GrigorenkoPV:doc/extract_if, r=JohnTitor
Add doc links to `ExtractIf` of `BTree{Set,Map}` and `LinkedList`

There were links for `Hash{Set,Map}` and `Vec{,Deque}` versions, but not these three.
2026-03-29 08:59:39 +02:00
Jonathan Brouwer e32b188e72 Rollup merge of #154512 - GrigorenkoPV:alignment/const, r=scottmcm
Constify comparisons and `Clone` for `core::mem::Alignment`

As suggested in https://github.com/rust-lang/rust/pull/153261#issuecomment-4136817185
2026-03-29 08:59:37 +02:00
Jonathan Brouwer df5f98513b Rollup merge of #154190 - Jules-Bertholet:nonfused, r=scottmcm
Don't fuse in `MapWindows`

cc https://github.com/rust-lang/rust/issues/87155

Fusing makes the iterator larger, slower, more complicated, and less useful. Users who need fusing behavior can always use `.fuse()`, but there is no way to get non-fusing behavior from the fused version.

@rustbot label A-iterators
2026-03-29 08:59:36 +02:00
Jonathan Brouwer 8287d4deb2 Rollup merge of #153632 - Lars-Schumann:issue-153158, r=fee1-dead
Fix Vec::const_make_global for 0 capacity and ZST's

fixes https://github.com/rust-lang/rust/issues/153158
2026-03-29 08:59:35 +02:00
Trevor Gross cbc94349d0 core: Destabilize beta-stable RangeInclusiveIter::remainder
As discussed, make this portion of the range API unstable again. This
will now be tracked under `new_range_remainder`.

Discussion: https://rust-lang.zulipchat.com/#narrow/channel/327149-t-libs-api.2Fapi-changes/topic/.60RangeFrom.3A.3Aremainder.60.20possible.20panic/with/582108913
2026-03-29 01:58:50 -05: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
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
Guillaume Gomez 67ab3ac423 Rollup merge of #154043 - RalfJung:simd-min-max, r=Amanieu,calebzulawski,antoyo
simd_fmin/fmax: make semantics and name consistent with scalar intrinsics

This is the SIMD version of https://github.com/rust-lang/rust/pull/153343: change the documented semantics of the SIMD float min/max intrinsics to that of the scalar intrinsics, and also make the name consistent. The overall semantic change this amounts to is that we restrict the non-determinism: the old semantics effectively mean "when one input is an SNaN, the result non-deterministically is a NaN or the other input"; the new semantics say that in this case the other input must be returned. For all other cases, old and new semantics are equivalent. This means all users of these intrinsics that were correct with the old semantics are still correct: the overall set of possible behaviors has become smaller, no new possible behaviors are being added.

In terms of providers of this API:
- Miri, GCC, and cranelift already implement the new semantics, so no changes are needed.
- LLVM is adjusted to use `minimumnum nsz` instead of `minnum`, thus giving us the new semantics.

In terms of consumers of this API:
- Portable SIMD almost certainly wants to match the scalar behavior, so this is strictly a bugfix here.
- Stdarch mostly stopped using the intrinsic, except on nvptx, where arguably the new semantics are closer to what we actually want than the old semantics (https://github.com/rust-lang/stdarch/issues/2056).

Q: Should there be an `f` in the intrinsic name to indicate that it is for floats? E.g., `simd_fminimum_number_nsz`?

Also see https://github.com/rust-lang/rust/issues/153395.
2026-03-29 00:06:50 +01:00
Guillaume Gomez e6f17e4bbb Rollup merge of #153834 - N1ark:generic-float-intrinsics, r=tgross35,RalfJung
Merge `fabsf16/32/64/128` into `fabs::<F>`

Following [a small conversation on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Float.20intrinsics/with/521501401) (and because I'd be interested in starting to contribute on Rust), I thought I'd give a try at merging the float intrinsics :)

This PR just merges `fabsf16`, `fabsf32`, `fabsf64`, `fabsf128`, as it felt like an easy first target.

Notes:
- I'm opening the PR for one intrinsic as it's probably easier if the shift is done one intrinsic at a time, but let me know if you'd rather I do several at a time to reduce the number of PRs.
- Currently this PR increases LOCs, despite being an attempt at simplifying the intrinsics/compilers. I believe this increase is a one time thing as I had to define new functions and move some things around, and hopefully future PRs/commits will reduce overall LoCs
- `fabsf32` and `fabsf64` are `#[rustc_intrinsic_const_stable_indirect]`, while `fabsf16` and `fabsf128` aren't; because `f32`/`f64` expect the function to be const, the generic version must be made indirectly stable too. We'd need to check with T-lang this change is ok; the only other intrinsics where there is such a mismatch is `minnum`, `maxnum` and `copysign`.
- I haven't touched libm because I'm not familiar with how it works; any guidance would be welcome!
2026-03-29 00:06:50 +01:00
Guillaume Gomez aad3710227 Rollup merge of #153380 - pitaj:stabilize-new_range_from_api, r=tgross35
stabilize new RangeFrom type and iterator

```rust
// in core and std
pub mod range;

// in core::range

pub struct RangeFrom<Idx> {
    pub start: Idx,
}

impl<Idx: fmt::Debug> fmt::Debug for RangeFrom<Idx> { /* ... */ }

impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
    pub const fn contains<U>(&self, item: &U) -> bool
    where
        Idx: [const] PartialOrd<U>,
        U: ?Sized + [const] PartialOrd<Idx>;
}

impl<Idx: Step> RangeFrom<Idx> {
    pub fn iter(&self) -> RangeFromIter<Idx>;
}

impl<T> const RangeBounds<T> for RangeFrom<T> { /* ... */ }
impl<T> const RangeBounds<T> for RangeFrom<&T> { /* ... */ }

impl<T> const From<RangeFrom<T>> for legacy::RangeFrom<T> { /* ... */ }
impl<T> const From<legacy::RangeFrom<T>> for RangeFrom<T> { /* ... */ }

pub struct RangeFromIter<A>(/* ... */);

// `RangeFromIter::remainder` left unstable

impl<A: Step> Iterator for RangeFromIter<A> {
    type Item = A;
    /* ... */
}

impl<A: Step> FusedIterator for RangeFromIter<A> { }
impl<A: Step> IntoIterator for RangeFrom<A> {
    type Item = A;
    type IntoIter = RangeFromIter<A>;
    /* ... */
}

unsafe impl<T> const SliceIndex<[T]> for range::RangeFrom<usize> {
    type Output = [T];
    /* ... */
}
unsafe impl const SliceIndex<str> for range::RangeFrom<usize> {
    type Output = str;
    /* ... */
}

impl ops::Index<range::RangeFrom<usize>> for CStr {
    type Output = CStr;
    /* ... */
}
```

Tracking issue: https://github.com/rust-lang/rust/issues/125687
2026-03-29 00:06:49 +01:00
Pavel Grigorenko 18a3bda091 Add doc links to ExtractIf of BTree{Set,Map} and LinkedList 2026-03-29 01:11:52 +03:00
Stepan Koltsov 27242aa319 Panic in Hermit clock_gettime 2026-03-28 21:00:03 +00:00
Peter Jaszkowiak 085dff4944 stabilize new RangeFrom type and iterator
stabilizes `core::range::RangeFrom`
stabilizes `core::range::RangeFromIter`

add examples for `remainder` method on range iterators
`RangeFromIter::remainder` was not stabilized (see issue 154458)
2026-03-28 12:00:10 -06:00
Pavel Grigorenko c45bfa8d73 const_clone for core::mem::Alignment 2026-03-28 20:38:43 +03:00
Pavel Grigorenko 219420573b const_cmp for core::mem::Alignment 2026-03-28 20:38:42 +03:00
bors 0d4eb09831 Auto merge of #154503 - RalfJung:rollup-DkU2JXL, r=RalfJung
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#152880 (Tweak incorrect assoc item note)
 - rust-lang/rust#153526 (Fix LegacyKeyValueFormat report from docker build: i686)
 - rust-lang/rust#153613 (interpreter error reporting: remove arguments that are always the same)
 - rust-lang/rust#154029 (Replace `truncate(0)` with `clear()`)
 - rust-lang/rust#154125 (Inline and remove `DepGraphData::try_mark_parent_green`.)
 - rust-lang/rust#154185 (Prevent no_threads RwLock's write() impl from setting mode to -1 when it is locked for reading)
 - rust-lang/rust#154394 (Normalize rustc path prefix when testing `-Z track-diagnostics`)
 - rust-lang/rust#154450 (Use the normal arg-parsing machinery for `-Zassert-incr-state`)
 - rust-lang/rust#154475 (Emit a pre-expansion feature gate warning for `box`'ed struct field patterns)
 - rust-lang/rust#154500 (EnumSizeOpt: use Allocation::write_scalar instead of manual endianess logic)
 - rust-lang/rust#154502 (interpret: ensure that untupled arguments are actually tuples)
2026-03-28 13:54:29 +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
bors 7e28c7438a Auto merge of #153821 - Lars-Schumann:const-step, r=Mark-Simulacrum
constify `Step` trait and all of its `impl`ementations

constifying [Step](https://github.com/rust-lang/rust/issues/42168) trait and all of its implementations, with some friendly help from [const_cmp](https://github.com/rust-lang/rust/issues/143800)
2026-03-28 10:44:18 +00: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 4c86e7c565 Rollup merge of #154221 - DanielEScherzer:isize-lc, r=Mark-Simulacrum
`vec::as_mut_slice()`: use lowercase "isize" in safety comment

To match other references to that type
2026-03-28 15:01:39 +11:00
Stuart Cook 50fe743b9b Rollup merge of #154196 - Jules-Bertholet:ipv6-multicast-discriminant, r=Mark-Simulacrum
Make `Ipv6Addr::multicast_scope()` exhaustive

And make `Ipv6MulticastScope` exhaustive, with `repr(u8)` and the proper discriminant values. The variants for the two reserved scopes are gated behind a perma-unstable feature, in order to avoid committing to names for them.

[IETF RFC 4291](https://datatracker.ietf.org/doc/html/rfc4291#section-2.7) and [IETF RFC 7346](https://datatracker.ietf.org/doc/html/rfc7346#section-2) define the list of multicast scopes. The former document says:

> scopes labeled "(unassigned)" are available for administrators to define additional multicast regions.

Tracking issue: https://github.com/rust-lang/rust/issues/27709
@rustbot label A-io
2026-03-28 15:01:38 +11:00
Stuart Cook 3c6a2bc0af Rollup merge of #154081 - safer-rust:main, r=Mark-Simulacrum
format safety doc of Rc/Arc::from_raw/from_raw_in

The following APIs previously had safety notes, but they were not placed under a dedicated Safety section. This PR adds a Safety section for each API and moves the original safety descriptions there:
- [`Rc::from_raw`](https://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html#method.from_raw)
- [`Rc::from_raw_in`](https://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html#method.from_raw_in)
- [`Arc::from_raw`](https://doc.rust-lang.org/nightly/alloc/sync/struct.Arc.html#method.from_raw)
- [`Arc::from_raw_in`](https://doc.rust-lang.org/nightly/alloc/sync/struct.Arc.html#method.from_raw_in)

Additionally, we updated the parameter requirements to clarify that the raw pointer may be returned not only from `into_raw`, but also from `into_raw_with_allocator`.
2026-03-28 15:01:37 +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
Laine Taffin Altman 1f17857123 std_detect on AArch64 Darwin: Detect FEAT_SVE_B16B16
This is now exposed via `sysctl` as of macOS "Tahoe" 26.4 (or possibly earlier).
2026-03-27 17:24:27 -07:00
Jules Bertholet 4ca6328536 Remove repr(u8) 2026-03-27 18:50:08 -04:00
Jacob Pratt f229fc0e77 Rollup merge of #153675 - RalfJung:simd-overflow, r=scottmcm
simd_add/sub/mul/neg: document overflow behavior

`simd_neg` had an odd comment about overflow not being UB, without saying what the behavior is instead. Replace that by just saying this uses wrapping arithmetic, and add the same for add/sub/mul. div/rem are already documented to cause UB on div-by-zero and min-div-by-minus-one, and shl/shr cause UB on too large shift amounts.
2026-03-27 02:30:08 -04:00
bors ac40f5e105 Auto merge of #154004 - GrigorenkoPV:alignment/as_nonzero_usize, r=scottmcm
`Alignment`: move from `ptr` to `mem` and rename `as_nonzero` to `as_nonzero_usize`



- tracking issue: rust-lang/rust#102070
- split off from rust-lang/rust#153261
2026-03-27 01:25:29 +00:00
Jonathan Brouwer 2ff9f8db5f Rollup merge of #154407 - theemathas:document-debug_assert_matches, r=Amanieu
Link from `assert_matches` to `debug_assert_matches`

This resolves a FIXME which was added in https://github.com/rust-lang/rust/pull/151423.

r? @Amanieu
(Reviewer of rust-lang/rust#151423.)
2026-03-26 15:20:11 +01: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
Tim (Theemathas) Chirananthavat 91e4524bfe Link from assert_matches to debug_assert_matches
This resolves a FIXME which was added in
https://github.com/rust-lang/rust/pull/151423.
2026-03-26 12:12:53 +07:00
Jonathan Brouwer f85b70f2eb Rollup merge of #153068 - sayantn:avxvnni, r=Amanieu
Require avxvnni for avx10.2

AVX10.2 supports masked (and 512-bit) versions of some intrinsics available in AVXVNNI, AVXVNNIINT8 and AVXVNNIINT16 (e.g. AVX10.2 introduces `_mm{,256,512}_{mask{z}}_dpbuud_epi32` corresponding to `_mm{,256}_dpbuud_epi32` from AVXVNNIINT8). But Intel (being Intel), didn't (at least not in SDM) enforce that AVX10.2 (or at least AVX10_VNNI_INT, which is a "discrete AVX10 feature", introduced alongside AVX10.2, and expected to house more such instructions) requires AVXVNNI etc.

To make this (admittedly very Intel) situation a bit better, we can just require these features from the Rust frontend

r? @Amanieu

This also corrects a mistake in std-detect which allowed AVX10 to be enabled without AVX512F, in the (odd) case when F16C or FMA are not available (we require these for AVX512F because otherwise the LLVM assembler doesn't work)
2026-03-26 00:23:10 +01:00
Jonathan Brouwer bd919a0ee7 Rollup merge of #154288 - Jules-Bertholet:patch-2, r=JohnTitor
Fix typo in doc comment for `char::to_titlecase`

@rustbot label A-docs
2026-03-25 19:53:00 +01:00
Jonathan Brouwer 4783d35218 Rollup merge of #154216 - airblast-dev:main, r=tgross35
unstably mark `NonNull::with_exposed_provenance` as const

Feature: `const_nonnull_with_exposed_provenance`
Tracking issue: https://github.com/rust-lang/rust/issues/154215

This PR constifies `NonNull::with_exposed_provenance`.

r? @tgross35
2026-03-25 19:52:58 +01:00
Pavel Grigorenko ba1e06a722 core::mem::Alignemnt: rename as_nonzero to as_nonzero_usize 2026-03-25 16:18:33 +03:00
Pavel Grigorenko f8d658ab81 core: move Alignment from ptr to mem 2026-03-25 16:18:33 +03:00
Ralf Jung 3271d4cadf uefi: extend comment for TcpStream Send impl 2026-03-25 08:33:35 +01:00
Theemathas Chirananthavat f55c8cca4c Rewrite safety comment for PinCoerceUnsized 2026-03-25 11:40:27 +07: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
bors 8a703520e8 Auto merge of #154339 - JonathanBrouwer:rollup-FPeeGxJ, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#154311 ([libcore] Disable `doc(auto_cfg)` for integers trait impls)
 - rust-lang/rust#154331 (allow `incomplete_features` in all ui tests)
 - rust-lang/rust#154336 (Remove more BuiltinLintDiag variants - part 3)
2026-03-24 22:00:08 +00:00