Commit Graph

582 Commits

Author SHA1 Message Date
Yara
74890b1ed2 reflection: update tests to use methods on TypeId 2026-08-15 01:03:06 +02:00
Zac Harrold
f7eb24dfd5 Add const-compatible cmp_splat test 2026-08-13 11:40:14 +10:00
Jonathan Brouwer
cc2a0a42c2 Rollup merge of #160732 - SomeFlyingThing:agent/optimize-bytewise-contains, r=joboet
Optimize slice::contains for one-byte BytewiseEq types

add optimized searches for NonZeroI8, option<NonZeroI8> ordering, and other one-byte types
2026-08-08 22:16:46 +02:00
Jacob Pratt
255e28735f Rollup merge of #160543 - bushrat011899:raw_os_error_c_int_default, r=clarfonthey
Default `RawOsError` to `i16` for 16-bit targets

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: rust-lang/rust#154046 & rust-lang/rust#107792
Fixes rust-lang/rust#160541

# Description

As noted by @tgross35, it's likely desirable for `RawOsError` to default to `i16` for 16-bit platforms. Practically, this only affects AVR and MSP430. Since `c_int` is defined as:

```rust
crate::cfg_select! {
    any(target_arch = "avr", target_arch = "msp430") => {
        pub(super) type c_int = i16;
        pub(super) type c_uint = u16;
    }
    _ => {
        pub(super) type c_int = i32;
        pub(super) type c_uint = u32;
    }
}
```

This also ensures for all platforms (excluding UEFI), `RawOsError` is equivalent to `c_int`. Since neither sets of targets had an implementation of `std`, this hasn't yet been litigated. While `RawOsError` is unstable, it seems reasonable to choose a default more likely to align with the underlying OS (if any).

---

## Notes

- No AI tooling of any kind was used during the creation of this PR.
2026-08-08 03:10:10 -04:00
SomeFlyingThing
8109a4b8cf Optimize slice::contains for one-byte BytewiseEq types 2026-08-07 21:35:01 -07:00
Jonathan Brouwer
34d9f1ed42 Rollup merge of #159784 - SomeFlyingThing:agent/hint-memchr-result-bounds, r=Darksonn
Hint that memchr returns an in-bounds index

`memchr_aligned` always returns an index within the input slice, but that fact was not visible to callers after inlining. Record the invariant with `assert_unchecked` so LLVM can simplify callers such as `str::find(char)`

 In x86_64 codegen, `find(char)` shrank from 463 to 377 bytes.
2026-08-08 00:38:19 +02:00
Zac Harrold
bbc212a143 Default RawOsError to i16 on 16-bit targets 2026-08-05 20:12:01 +10:00
Jonathan Brouwer
ad0ba38714 Rollup merge of #159727 - oli-obk:reflection_stuff, r=JohnTitor
Various steps in moving away from the big reflection enum to reflection functions

tracking issue: rust-lang/rust#146922

Some more of these and we can turn the big TyKind enum into one without any data, but I think these are enough steps for one PR, don't wanna turn it into a mega PR
2026-08-04 18:35:27 +02:00
Oli Scherer
cecd4a4fcb Add reflection method for getting a type's generic args 2026-08-04 11:20:25 +02:00
Oli Scherer
538f556305 Add reflection method for fetching non-exhaustiveness 2026-08-04 11:20:06 +02:00
Oli Scherer
c7fc5f2646 Add reflection method for field names 2026-08-04 11:13:53 +02:00
Jakub Beránek
01296edd3b Rollup merge of #159535 - SomeFlyingThing:optimize-slice-contains-bytewise, r=Mark-Simulacrum
Optimize slice::contains for bytewise types

generalize the SliceContains implementation from u8 to all types implementing UnsignedBytewiseOrd since these types have a one byte representation compatible with the
memchr implementation
2026-08-04 11:10:12 +02:00
Stuart Cook
f173ba251d Rollup merge of #160143 - ywxt:add-neon-support-is-ascii, r=Amanieu
Add NEON support for is_ascii and eq_ignore_ascii_case

Results on my aarch64 machine.

## 1. `is_ascii`

### 1.1 Raw Data (ns/iter, case00_libcore only — the path that calls `bytes.is_ascii()`)

| Input | Baseline (NEON off) | Optimized (NEON on) | Change |
|---|---|---|---|
| long | 19.69 | 6.46 | **-67.2%** |
| unaligned_both_long | 22.60 | 8.92 | **-60.5%** |
| unaligned_head_long | 20.62 | 8.81 | **-57.3%** |
| unaligned_tail_long | 21.15 | 8.68 | **-59.0%** |
| medium | 3.10 | 2.92 | -5.8% |
| short | 3.77 | 3.81 | +1.1% |
| unaligned_both_medium | 2.59 | 2.83 | +9.3% |
| unaligned_head_medium | 2.95 | 5.00 | +69.5% |
| unaligned_tail_medium | 2.37 | 2.96 | +24.9% |

### 1.2 Grouped Comparison (case00_libcore — the path affected by the change)

| Group | Baseline sum (ns) | Optimized sum (ns) | Change |
|---|---|---|---|
| **LONG (~350B, 4 items)** | 84.06 | 32.87 | **-60.9%** |
| **MEDIUM/SHORT (~16–32B, 5 items)** | 14.78 | 17.52 | +18.5% |
| All 9 items | 98.84 | 50.39 | **-49.0%** |

## 2. `eq_ignore_ascii_case`

### 2.1 Raw Data (ns/iter)

| Bench | Baseline (NEON off) | Optimized (NEON on) | Change |
|---|---|---|---|
| bench_large_str_eq | 6235.89 | 546.61 | **-91.2%** |
| bench_medium_str_eq | 780.81 | 68.05 | **-91.3%** |
| bench_medium_str_tail_mismatch | 786.84 | 65.76 | **-91.6%** |
| bench_str_31_bytes_eq | 35.87 | 3.98 | **-88.9%** |
| bench_str_17_bytes_eq | 19.62 | 4.05 | **-79.4%** |
| bench_medium_str_early_mismatch | 1.32 | 2.42 | +0.75 ns |
| bench_str_of_8_bytes_eq | 9.20 | 9.20 | 0.0% |
| bench_str_under_8_bytes_eq | 3.49 | 3.49 | 0.0% |

### 2.2 Grouped Comparison

| Group | Scenario | Baseline | Optimized | Change |
|---|---|---|---|---|
| **≥16B equal** | 17B / 31B / MEDIUM / LARGE | 19.6–6236 ns | 4.0–547 ns | **-79% ~ -91%** |
| **≥16B tail mismatch** | MEDIUM, last byte differs | 786.84 ns | 65.76 ns | **-91.6%** |
| **≥16B early mismatch** | MEDIUM, first byte differs | 1.32 ns | 2.42 ns | +0.75 ns |
| **<16B** | 8B / <8B equal | 3.49–9.20 ns | 3.49–9.20 ns | no change |

r? @Amanieu
2026-08-03 12:25:26 +10:00
Jonathan Brouwer
2825c037bc Rollup merge of #160025 - asder8215:step_by_nth_one, r=clarfonthey
Fix an edge case with `StepBy::nth` on non-fused iterators

Fixes rust-lang/rust#159965.

From the `nth` documentation as pointed out by theemathas:

> `nth()` will return `None` if `n` is greater than or equal to the length of the iterator.

Currently, there is an edge case for non-fused iterator where it's able to return `Some` through `StepBy::nth` iterator even though the first item from the non-fused iterator returns `None` (it is logically an empty iterator).

The issue came from how in the first take block it advances the underlying iterator forward using `.next()` and does not check if what it returns is a `None` value or not. This wouldn't be a problem for fused iterators because all the values that it would return after reaching the `None` point will also be `None`. However since non-fused iterators do not have to abide by continuously yielding `None` after reaching a `None`, it allows for a case, where after falling down from `first_take` block it can return `Some(_)` from a `self.iter.nth()` call in there.

In the `first_take` block we should definitely check if the first item we got from `self.iter.next()` is `None` item, and return `None` if it is so.
2026-08-01 19:16:28 +02:00
Jonathan Brouwer
6149c62791 Rollup merge of #157572 - RalfJung:layout-of-raw, r=saethlin
stabilize size_of_val_raw, align_of_val_raw, Layout::for_value_raw

Stabilizes versions of `size_of_val_raw` and friends that can be invoked on raw pointers, which means they can be used even if one does not have a pointer to a "valid value". This was held up for a while because figuring out the exact safety requirements is tricky, but I think the ones we now have had for a while (plus the minor clarifications in this PR) are "good enough": we basically do case distinction on the unsized tail of the type, and spell out the appropriate requirement for each case. This avoids making blanket statements about future kinds of DST that we may introduce eventually.

These are the requirements I should we should stabilize:

```
    /// - If `T` is `Sized`, this function is always safe to call.
    /// - If the unsized tail of `T` is:
    ///     - a [slice] `[U]`, `str`, or a [trait object] `dyn Trait`, then the size of the *entire value*
    ///       (dynamic tail length + statically sized prefix) must fit in `isize`.
    ///       For the special case where the dynamic tail length is 0, this function
    ///       is safe to call.
    //        NOTE: the reason this is safe is that if an overflow were to occur already with size 0,
    //        then we would stop compilation as even the "statically known" part of the type would
    //        already be too big (or the call may be in dead code and optimized away, but then it
    //        doesn't matter).
    ///     - No other kind of unsized tail currently exists that satisfies the trait bounds for this
    ///       function. If more kinds of unsized tails get introduced in the future, the documentation
    ///       of this function will have to be extended before it can be used for such types.
```

Going over the open questions from the [tracking issue](https://github.com/rust-lang/rust/issues/69835):
-  What should the exact safety requirements of these functions be? -> the currently documented requirement look good to me.
- How should this interact with extern types? -> what we document looks good here; we can still adjust this until extern types are stabilized.
- Are the functions sound to call on invalid data pointers? -> for the unsized tails that currently exist: yes; that's kind of the only reason to use them.

Cc @rust-lang/opsem @rust-lang/lang
(FCP should probably include both teams, unless lang is okay with fully delegating this to t-opsem)
I'll nominate the tracking issue for libs-api so we can get their approval as well for how the operation is exposed.

Fixes https://github.com/rust-lang/rust/issues/69835
2026-08-01 15:56:36 +02:00
Ralf Jung
d9c81f700a stabilize size_of_val_raw, align_of_val_raw, Layout::for_value_raw 2026-08-01 09:01:27 +02:00
Mahdi Ali-Raihan
366ebd6a8e If the first_take is set to true and our first item returned None, return None always. Additionally, if any self.iter.nth() calls return a None, early return None as well. This fixes an edge case with non fused iterators to not advance the iterator beyond the first None item it observed in accordance with nth documentation saying that nth() will return None if n is greater than or equal to the length of the iterator. 2026-08-01 02:11:59 -04:00
bors
922325bb13 Auto merge of #160238 - JonathanBrouwer:rollup-6GZndbU, r=JonathanBrouwer
Rollup of 25 pull requests

Successful merges:

 - rust-lang/rust#160204 (Sync from portable simd 2026 07 30)
 - rust-lang/rust#138230 (Add `raw_borrows_via_references` lint)
 - rust-lang/rust#158057 (Don't escape U+FF9E and U+FF9F in `escape_debug_ext`)
 - rust-lang/rust#160015 (refactor(mir-transform): Merge `can_be_overridden`, `is_required` and `is_enabled` into one)
 - rust-lang/rust#160031 (std: make positioned I/O unsupported on VxWorks)
 - rust-lang/rust#160125 (Fix typing mode handling in transmute checks and rustc_dump_layout)
 - rust-lang/rust#160152 (Create on-demand CI job for testing EC2 instances)
 - rust-lang/rust#160232 (rustdoc: fix ICE when a grapheme cluster joins a Prepend-class character to `_` or `:`)
 - rust-lang/rust#159214 (std: improve the documentation of the random feature)
 - rust-lang/rust#159818 (Resolve vars before calling `unnormalized_obligations`)
 - rust-lang/rust#159955 (Stop using higher-order macros to declare arenas)
 - rust-lang/rust#159958 (Fix avoid cycle for self referential return type notation)
 - rust-lang/rust#160040 (Split function parsing out of `item.rs` to a new module.)
 - rust-lang/rust#160044 (Add regression tests for fixed dead-code issues)
 - rust-lang/rust#160144 (renovate: group lockfiles PRs)
 - rust-lang/rust#160149 (Fix Windows on Arm PAC default)
 - rust-lang/rust#160164 (Derive `GenericTypeVisitable` for `RegionConstraint`)
 - rust-lang/rust#160175 (Try to recover less from incorrectly parsed const arg)
 - rust-lang/rust#160177 (A few more "predicate"-to-"clause" renamings)
 - rust-lang/rust#160181 (Mark `Tuple` and `FnPtr` traits `#[fundamental]`)
 - rust-lang/rust#160192 (Fix ICE for parsing issue with a closing brace)
 - rust-lang/rust#160209 (bootstrap: Remove method `Subcommand::kind`)
 - rust-lang/rust#160221 (Remove `Copy` supertrait from `VaList`)
 - rust-lang/rust#160223 (interpret: rename validate_operand → validate_place)
 - rust-lang/rust#160234 (Always use short ty path for call with missing arguments suggestion)
2026-07-31 04:19:17 +00:00
Jonathan Brouwer
639d011010 Rollup merge of #158057 - Jules-Bertholet:halfwidth-dakuten-noescape, r=Darksonn
Don't escape U+FF9E and U+FF9F in `escape_debug_ext`

The two characters `゙` U+FF9E HALFWIDTH KATAKANA VOICED SOUND MARK and `゚` U+FF9F HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK are the odd ones out when it comes to grapheme extenders, in that *graphically* they are not combining at all. See https://github.com/microsoft/terminal/issues/18087 for more background on these characters.

I think this needs FCP? It affects `char::escape_debug`, and various `Debug` impls for characters and strings.

@rustbot labels T-libs-api needs-fcp A-Unicode
2026-07-31 00:06:28 +02:00
bors
8ab9fdff5a Auto merge of #159817 - teor2345:splat-rename-nightly, r=jieyouxu
Rename splat to avoid stable name collisions

Tracking issue: rust-lang/rust#153629



This PR renames `#[splat]` to `#[rustc_splat]`, in a mostly automated way (using `fastmod`).

The rename commands I used were:
```sh
fastmod --fixed-strings '#[splat]' '#[rustc_splat]'
fastmod --fixed-strings '`splat` attribute' '`rustc_splat` attribute'
# I'm pretty sure the symbol demangling commands are no-ops on beta
# Legacy symbol demangling
fastmod --fixed-strings '$splat$' '$rustc_splat$'
# Revert some changes that aren't in rustc_demangle yet
fastmod 'v0(.*)#\[rustc_splat\]' 'v0${1}#[splat]' tests/ui/splat/splat-mangling.rs
```

Part of rust-lang/rust#159428

#### Backport Advice

Cherry-pick the first commit to the beta branch, then run the fastmod commands above.
I've tested this locally (with a slightly different name), and it works, see my [`splat-rename-beta` branch](https://github.com/teor2345/rust/tree/splat-rename-beta).

#### Remaining Work

rustc_demangle needs an update to the attribute name, a release, and then a version bump in rust-lang/rust. I'll do that separately. It doesn't need to be backported, because the last version bump was after beta branched.

There's also some external code that needs updates, the full list is in the ticket: https://github.com/rust-lang/rust/issues/159428#issuecomment-5040163201

@rustbot label +beta-nominated +A-attributes +A-macros +A-resolve +C-bug +F-splat +P-high +T-compiler
2026-07-30 19:53:05 +00:00
teor
e574edfbac Automatically rename rustc_splat attribute
fastmod --fixed-strings '#[splat]' '#[rustc_splat]'
fastmod --fixed-strings '`splat` attribute' '`rustc_splat` attribute'
fastmod --fixed-strings '$splat$' '$rustc_splat$'
fastmod 'v0(.*)#\[rustc_splat\]' 'v0${1}#[splat]' tests/ui/splat/splat-mangling.rs
2026-07-30 10:59:40 +10:00
Rachit2323
d80021794e iter: specialize Take::count using advance_by 2026-07-29 21:05:21 +05:30
ywxt
ccbf7c658d Add NEON support for is_ascii and eq_ignore_ascii_case 2026-07-29 19:14:57 +08:00
Jacob Pratt
f8ee207a51 Rollup merge of #153563 - Urgau:lint-panics-when-n-is-zero, r=fee1-dead,ShoyuVanilla
Lint against iterator functions that panic when `N` is zero

This PR extends the deny-by-default `unconditional_panic` lint, by linting on iterator functions that panics when `N` (chunks/windows size) is zero[^attr].

Those methods are [documented](https://doc.rust-lang.org/std/primitive.slice.html#panics-11) to panic if `N` is zero.

```
error: this operation will panic at runtime
  --> $DIR/const-n-is-zero.rs:11:13
   |
LL |     let _ = s.array_windows::<0>();
   |             ^^^^^^^^^^^^^^^^^^^^^^ const parameter `N` is zero
   |
   = note: `#[deny(unconditional_panic)]` on by default
```

cc @rust-lang/libs-api

[^attr]: this is done by introducing a new internal attribute on the const parameter: `#[rustc_panics_when_zero]`
2026-07-28 01:38:30 -04:00
Urgau
d67cce722c Apply #[rustc_panics_when_zero] to the relevant core functions 2026-07-27 22:44:12 +02:00
Jonathan Brouwer
d095883e47 Rollup merge of #159554 - ajtribick:int_from_ascii_bytes, r=Mark-Simulacrum
feat: Update method signature of int_from_ascii

* Tracking issue: rust-lang/rust#134821

Following [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/327149-t-libs-api.2Fapi-changes/topic/How.20to.20proceed.20with.20int_from_ascii/with/611508226) it appears the preference is to change the API for this feature as follows:

```rust
// core::num

impl X {
    pub const fn from_ascii_bytes<T>(src: T) -> Result<X, ParseIntError>
    where
        T: [const] AsRef<[u8]> + [const] core::marker::Destruct;

    pub const fn from_ascii_bytes_radix<T>(src: T, radix: u32) -> Result<X, ParseIntError>
    where
        T: [const] AsRef<[u8]> + [const] core::marker::Destruct;
}
```

and similarly for `NonZero<X>`.

Reasons behind the change:

* Future-proof the naming convention for future string-like types
* Support the upcoming `ByteStr`/`ByteString` types: rust-lang/rust#134915

This pull request applies this change. The const-ness of these functions is now feature gated behind rust-lang/rust#143773
2026-07-27 11:58:05 +02:00
Jacob Pratt
2993efbc36 Rollup merge of #159518 - Lfan-ke:fix/step-by-range-iter-specialization, r=Darksonn
iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>

`StepBy<Range<{integer}>>` already has a fast path that converts the range
into a yield-count before iteration, avoiding per-step overflow checks and
enabling better loop structure for the optimizer. `StepBy<RangeIter<{integer}>>`
did not benefit from the same optimization even though `RangeIter<T>` is a thin
newtype wrapper around `legacy::Range<T>`.

## Changes

- `library/core/src/range/iter.rs`: make `RangeIter<A>.0` `pub(crate)` so the
  step_by adapter can access the inner legacy range's start/end fields.
- `library/core/src/iter/adapters/step_by.rs`: add `spec_int_ranges_new!` and
  `spec_int_ranges_new_r!` macros that mirror the existing `spec_int_ranges!` /
  `spec_int_ranges_r!` implementations. Forward specialization covers `u8 u16
  u32 u64 usize` (pointer-width-gated for u32/u64); backward specialization is
  limited to `u8 u16 usize` since `RangeIter<u32>` / `RangeIter<u64>` do not
  implement `ExactSizeIterator`.
- `library/coretests/tests/iter/adapters/step_by.rs`: add
  `test_step_by_new_range_iter` covering forward, backward, and interleaved
  iteration via the new-range iterator.

## Motivation

Fixes rust-lang/rust#157754. The inner loop for `core::range::Range::from(0..n).into_iter().step_by(2)` currently generates noticeably worse assembly than the equivalent `(0..n).step_by(2)` because specialization did not cover `RangeIter`.

r? libs
2026-07-26 00:21:43 -04:00
林晨 (Leo Cheng)
dcc9c46efc iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>
Signed-off-by: 林晨 (Leo Cheng) <leo-cheng@vip.qq.com>
2026-07-26 00:55:33 +08:00
SomeFlyingThing
0439f4ef09 Hint that memchr returns an in-bounds index 2026-07-23 18:32:21 +01:00
Oli Scherer
e9ad00c5af Remove 'static requirement on try_as_dyn 2026-07-23 10:59:01 +02:00
Folkert de Vries
e547ba4ed7 relax f16 LOG_APPROX when running tests under Miri 2026-07-21 12:59:07 +02:00
Andrew Tribick
0bd28eaf0c feat: Update method signature of int_from_ascii 2026-07-19 11:20:31 +02:00
SomeFlyingThing
19c60651fe Optimize slice::contains for bytewise types 2026-07-18 20:23:30 +01:00
Jana Dönszelmann
25745ee1f1 fix all tidy annotations 2026-07-13 10:54:53 +02:00
Peter Jaszkowiak
b3c94df68b introduce Step::forward/backward_overflowing
and optimize the RangeInclusive iterator implementation with them

This changes the `exhausted` field to represent an overflow flag
for the bounds, essentially acting as an extra bit for `Idx`.
This was found to enable optimizations previously only applicable
to the exclusive-ended Range type.

- change end_bound to return Excluded(start) when exhausted
- add contains to tests
- make into_bounds panic when exhausted
  matches From<legacy::RangeInclusive<T>> for RangeInclusive<T>
- add tests for new Step impls
2026-07-06 18:30:20 -06:00
Jonathan Brouwer
cef63f3327 Rollup merge of #155989 - scottmcm:unsized-transmute-copy, r=Mark-Simulacrum
Update `transmute_copy` to ub_checks and `?Sized`

The `assert!` in `transmute_copy` is from rust-lang/rust#98839.  However, it was controversial at the time because it's possible to write `transmute_copy`s that were UB by the description but didn't pass the documented conditions.  It's also sub-optimal to have possible `panic`s in unsafe code where the panic can actually make things worse by dropping things in the middle of what the programmer expected to be panic-free.  Now that we have the `UbChecks` possibility, though, we can do this better: this PR makes it a *non-unwinding* panic when not meeting the documented condition when UB checks are enabled, but which very clearly emphasizes that said check isn't a documented behaviour of the function.

Also, I was staring at the signature and couldn't figure out why it needs `Src: Sized`.  Since it *always* takes a reference, there seems to be no downside to accepting `Src: ?Sized`.  That would also give it more of a reason to exist even if <https://doc.rust-lang.org/nightly/std/mem/fn.transmute_prefix.html> exists (as `transmute_prefix(x)` existing will no longer need the `transmute_copy(&ManuallyDrop::new(x))` polyfill, cc https://github.com/rust-lang/rfcs/pull/3844).  That definitely needs an FCP, though.

(The change to `assert_unsafe_precondition` here doesn't technically need libs-api assent, but I'd still like to hear your thoughts since it's different from the "promise the assert" that IIRC you were also asked to consider elsewhere.)

A partial replacement for rust-lang/rust#154665
2026-07-05 14:12:02 +02:00
Jacob Pratt
666e69ea0e Rollup merge of #156737 - asder8215:double_ended_iterator_next_chunk_back, r=aapoalas
Implement `DoubleEndedIterator::next_chunk_back`

This PR builds off on @vinDelphini's [PR](https://github.com/rust-lang/rust/pull/151668) on introducing `DoubleEndedIterator::next_chunk_back` (which will be used in a follow up PR to optimize `ArrayChunks::try_rfold` once merged). This was in the works since late Jan and I thought to pick it up and get this over the finish line as vinDelphini has been away from the PR for a couple of months. I've made sure to pull from vinDelphini's branch to keep him authored on the commits he made.

Other things introduced from this PR is specialization like done for `Iterator::next_chunk`, constifying some stuff, making a custom `DoubleEndedIterator::next_chunk_back` for `IntoIter` (since it also has a custom impl of `Iterator::next_chunk`), and a bunch of tests mirroring that of `Iterator::next_chunk`.

There's no tracking issue for this yet, but the ACP for this introduction is [here](https://github.com/rust-lang/libs-team/issues/734). I'll create the tracking issue for this soon.

----

Actually, can we have `DoubleEndedIterator::next_chunk_back` underneath [`Iterator::next_chunk` tracking issue](https://github.com/rust-lang/rust/issues/98326)?
2026-07-01 17:42:23 -04:00
Scott McMurray
a3a8023742 Update transmute_copy to ub_checks and ?Sized 2026-07-01 11:48:06 -07:00
Hanna Kruppe
3d31306f1d Merge and reframe strict_provenance_lints 2026-06-28 10:27:32 +02:00
teor
50c658c0cb Impl TypeInfo for splat 2026-06-26 10:44:15 +02:00
Jacob Pratt
5b9961def4 Rollup merge of #158053 - niklasf:perf/addr-parser, r=workingjubilee
Optimize network address parser

Motivated by working with datasets of IP addresses.

First commit adds more examples for each case in the benchmark suite.

Second commit splits `read_number()` into seperate methods for the the `max_digits` `Some(_)` and `None` cases, which by itself significantly helps code generation.

Hoist reading the first digit which is always required.

The path for unlimited digits then no longer has to count digits at all.

Drive-by "fixes" the 10 digit debug assertion (which would be insufficient in base 16). Not actually used anywhere near the limit.

`./x bench library/coretests --test-args addr_parser` before -> after on AMD Ryzen 9 9950X:

    net::addr_parser::bench_parse_ipaddr_v4           81.73ns/iter  +/- 0.60  ->   62.36ns/iter +/- 0.12
    net::addr_parser::bench_parse_ipaddr_v6_compress 303.70ns/iter  +/- 1.29  ->  212.80ns/iter +/- 1.25
    net::addr_parser::bench_parse_ipaddr_v6_full     453.06ns/iter  +/- 7.89  ->  294.88ns/iter +/- 0.91
    net::addr_parser::bench_parse_ipaddr_v6_v4       301.41ns/iter  +/- 1.52  ->  224.82ns/iter +/- 0.99
    net::addr_parser::bench_parse_ipv4                87.24ns/iter  +/- 0.32  ->   52.94ns/iter +/- 0.33
    net::addr_parser::bench_parse_ipv6_compress      277.92ns/iter  +/- 3.29  ->  195.98ns/iter +/- 1.10
    net::addr_parser::bench_parse_ipv6_full          402.48ns/iter +/- 22.20  ->  276.37ns/iter +/- 4.05
    net::addr_parser::bench_parse_ipv6_v4            276.78ns/iter  +/- 1.18  ->  216.04ns/iter +/- 1.20
    net::addr_parser::bench_parse_socket_v4          105.18ns/iter  +/- 0.79  ->   69.20ns/iter +/- 0.46
    net::addr_parser::bench_parse_socket_v6          378.69ns/iter  +/- 5.25  ->  274.82ns/iter +/- 0.95
    net::addr_parser::bench_parse_socket_v6_scope_id 336.61ns/iter  +/- 2.36  ->  258.56ns/iter +/- 0.89
    net::addr_parser::bench_parse_socketaddr_v4      118.20ns/iter  +/- 0.66  ->   78.86ns/iter +/- 0.22
    net::addr_parser::bench_parse_socketaddr_v6      429.17ns/iter  +/- 5.70  ->  315.69ns/iter +/- 1.48
2026-06-24 00:40:17 -04:00
Jacob Pratt
a214ed1627 Rollup merge of #155739 - Voultapher:add-tmp-scope-to-assert-macros, r=Amanieu
Add temporary scope to assert_eq and assert_ne

This is a follow-up to https://github.com/rust-lang/rust/pull/155431
2026-06-24 00:40:11 -04:00
Jules Bertholet
903bac5a59 Add tests 2026-06-18 23:31:55 -04:00
Niklas Fiekas
d4bea37970 Expand network address parser benchmark suite 2026-06-17 22:22:35 +02:00
Jonathan Brouwer
4d691a0f60 Rollup merge of #157877 - niklasf:nonzero_from_str_radix, r=jhpratt
Stabilize `nonzero_from_str_radix`

Closes rust-lang/rust#152193
2026-06-15 13:33:25 +02:00
Jonathan Brouwer
36c0285e93 Rollup merge of #157029 - ElliottjPierce:stabilize-feature-float_algebraic, r=RalfJung
stabilize feature `float_algebraic`

Closes rust-lang/rust#136469

Thanks to @RalfJung for getting the stabilization process started and asking me to draft the stabilization PR for the `float_algebraic` feature. This will be my first contribution to rust! I've done my best to follow the various guides for stabilization PRs, but this is my first one, so do give it a careful look. The only place left that includes "float_algebraic" is line 8202  of "src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs", but I'm assuming that's fine.
2026-06-15 13:33:24 +02:00
Elliott Pierce
d69bd08f96 stabilize feature float_algebraic
* stabilize feature float_algebraic
* fixed algrebracis for `f16` and `f128`
2026-06-15 00:56:07 +00:00
Niklas Fiekas
0ae5b43c78 Stabilize nonzero_from_str_radix 2026-06-14 00:13:12 +02:00
Mahdi Ali-Raihan
bfd1ba63cc Introduced specialization to DoubleEndedIterator::next_chunk_back, introduced next_chunk_back implementation in IntoIter, updated documentation, and added test cases for DoubleEndedIterator::next_chunk_back 2026-06-13 15:20:34 -04:00
Jacob Pratt
b81d8f83c7 Rollup merge of #149749 - joshtriplett:borrowed-buf-generic, r=joboet
Make `BorrowedBuf` and `BorrowedCursor` generic over the data

Replace uses of `u8` with a generic type. This will allow reusing
`BorrowedBuf` elsewhere in the standard library, for purposes other than
byte buffers.

This currently requires `T: Copy`, to prevent `T: Drop`, which would require additional careful handling. We can consider relaxing that restriction in the future if we make `T: Drop` work (without pessimizing `Copy` types like `u8`).

`ensure_init` currently continues to require `u8`. We could potentially generalize it to `T: Default`, but we'd need to ensure it produced the same or better assembly for `u8`.

-----

As discussed in libs-api; cc @Amanieu.
2026-06-11 23:15:19 -04:00