Commit graph

396 commits

Author SHA1 Message Date
ltdk
28feae0c87 Move bigint helper tracking issues 2026-02-02 18:45:26 -05:00
Jacob Pratt
4e21b69e5a
Rollup merge of #151812 - scottmcm:slice-shift, r=jhpratt
Add `shift_{left,right}` on slices

ACP approval: https://github.com/rust-lang/libs-team/issues/717#issuecomment-3807205664
cc tracking issue rust-lang/rust#151772
2026-01-30 22:52:21 -05:00
Deadbeef
6147a3fc88 constify Iterator 2026-01-30 15:52:40 +00:00
Scott McMurray
4264da6869 Add shift_{left,right} on slices
cc tracking issue 151772
2026-01-29 11:12:54 -08:00
theiz
a1893d3187 Add support for trait object types in type_info reflection 2026-01-27 19:49:09 -04:00
Stuart Cook
1c892e829c
Rollup merge of #147436 - okaneco:eq_ignore_ascii_autovec, r=scottmcm
slice/ascii: Optimize `eq_ignore_ascii_case` with auto-vectorization

- Refactor the current functionality into a helper function
- Use `as_chunks` to encourage auto-vectorization in the optimized chunk processing function
- Add a codegen test checking for vectorization and no panicking
- Add benches for `eq_ignore_ascii_case`

---

The optimized function is initially only enabled for x86_64 which has `sse2` as part of its baseline, but none of the code is platform specific. Other platforms with SIMD instructions may also benefit from this implementation.

Performance improvements only manifest for slices of 16 bytes or longer, so the optimized path is gated behind a length check for greater than or equal to 16.

Benchmarks - Cases below 16 bytes are unaffected, cases above all show sizeable improvements.
```
before:
    str::eq_ignore_ascii_case::bench_large_str_eq         4942.30ns/iter +/- 48.20
    str::eq_ignore_ascii_case::bench_medium_str_eq         632.01ns/iter +/- 16.87
    str::eq_ignore_ascii_case::bench_str_17_bytes_eq        16.28ns/iter  +/- 0.45
    str::eq_ignore_ascii_case::bench_str_31_bytes_eq        35.23ns/iter  +/- 2.28
    str::eq_ignore_ascii_case::bench_str_of_8_bytes_eq       7.56ns/iter  +/- 0.22
    str::eq_ignore_ascii_case::bench_str_under_8_bytes_eq    2.64ns/iter  +/- 0.06
after:
    str::eq_ignore_ascii_case::bench_large_str_eq         611.63ns/iter +/- 28.29
    str::eq_ignore_ascii_case::bench_medium_str_eq         77.10ns/iter +/- 19.76
    str::eq_ignore_ascii_case::bench_str_17_bytes_eq        3.49ns/iter  +/- 0.39
    str::eq_ignore_ascii_case::bench_str_31_bytes_eq        3.50ns/iter  +/- 0.27
    str::eq_ignore_ascii_case::bench_str_of_8_bytes_eq      7.27ns/iter  +/- 0.09
    str::eq_ignore_ascii_case::bench_str_under_8_bytes_eq   2.60ns/iter  +/- 0.05
```
2026-01-27 17:36:35 +11:00
Juho Kahala
29596f87be rename uN::{gather,scatter}_bits to uN::{extract,deposit}_bits 2026-01-26 06:28:42 +02:00
Jonathan Brouwer
474c9fe9a4
Rollup merge of #151489 - bend-n:constify-all-boolean-methods-under-feature-gate-const-bool, r=jhpratt
constify boolean methods

```rs
// core::bool

impl bool {
    pub const fn then_some<T: [const] Destruct>(self, t: T) -> Option<T>;
    pub const fn then<T, F: [const] FnOnce() -> T + [const] Destruct>(self, f: F) -> Option<T>;
    pub const fn ok_or<E: [const] Destruct>(self, err: E) -> Result<(), E>;
    pub const fn ok_or_else<E, F: [const] FnOnce() -> E + [const] Destruct>;
}
```

will make tracking issue if pr liked
2026-01-24 08:18:07 +01:00
bendn
207dcbbe7c
constify boolean methods 2026-01-23 15:12:47 +07:00
bendn
081c4c6abb
reenable tests 2026-01-23 14:26:26 +07:00
Trevor Gross
490b307740 cleanup: Start splitting FIXME(f16_f128) into f16, f128, or f16,f128
Make it easier to identify which FIXMEs are blocking stabilization of
which type.
2026-01-22 23:41:57 -06:00
Trevor Gross
8840409f7a f16,f128: Resolve cfg-releated instances of FIXME(f16_f128)
There are a number of instances of `FIXME(f16_f128)` related to target
configuration; either these could use `target_has_reliable_f128`, or the
FIXME is describing such a cfg and is thus redundant (since any
`cfg(target_has_reliable_f*)` needs to be removed before stabilization
anyway).

Switch to using `target_has_reliable_*` where applicable and remove the
redundant FIXMEs.
2026-01-22 23:41:57 -06:00
BD103
a509588fa9 feat: support slices in reflection type info 2026-01-21 16:03:00 -06:00
BD103
976cea3a18 feat: support pointers in type info 2026-01-19 09:42:55 -06:00
Jacob Pratt
80db7158af
Rollup merge of #151235 - type-info-rename-bits, r=oli-obk
Change field `bit_width: usize` to `bits: u32` in type info

Follow-up https://github.com/rust-lang/rust/pull/151123#discussion_r2698418929. Quotes:

@Skgland:
> > I'm not sure whether we should use `usize` or `u64` here to represent the bit width.
>
> My expectation would be `u32` matching the associated `{u,i}N::BITS`[^1][^2][^3] constant that already exists on the integer types.
>
> [^1]: https://doc.rust-lang.org/std/primitive.i8.html#associatedconstant.BITS
> [^2]: https://doc.rust-lang.org/std/primitive.i128.html#associatedconstant.BITS
> [^3]: https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.BITS

@SpriteOvO:
> I found some [previous discussions](https://github.com/rust-lang/rust/pull/76492#issuecomment-700516940) regarding the type of `::BITS` constant. And during the stabilization of `::BITS`, the choice of `u32` affected some ecosystem crates (#81654), but soon after, these crates all accepted the `u32` type.
>
> So I think it makes sense to keep the type consistent with `::BITS` here. Then I'd also like to change the name from `bit_width` to `bits`, also for consistency.

r? @oli-obk
2026-01-18 03:16:46 -05:00
Jacob Pratt
99b29620ca
Rollup merge of #148769 - stabilize/alloc_layout_extra, r=scottmcm
Stabilize `alloc_layout_extra`

Tracking issue: rust-lang/rust#55724
FCP completed in https://github.com/rust-lang/rust/issues/55724#issuecomment-3447699364
Closes rust-lang/rust#55724

----

As per https://github.com/rust-lang/rust/issues/55724#issuecomment-3403555985,
- `repeat_packed` and `extend_packed` are unchanged
- `repeat` now excludes trailing padding on the last element from the total array size
- `dangling` renamed to `dangling_ptr`
- `padding_needed_for` not stabilized, changed to accept `Alignment` instead of `usize` and moved to the `ptr_aligment_type` feature flag (tracking issue: rust-lang/rust#102070)
2026-01-18 03:16:44 -05:00
Asuna
27b0279660 Change field bit_width: usize to bits: u32 in type info 2026-01-17 01:53:08 +01:00
Jamie Hill-Daniel
c7031e93c5 feat: Support references in reflection type info 2026-01-17 00:25:29 +00:00
Matthias Krüger
225ba69ee2
Rollup merge of #151123 - type-info-primitives, r=oli-obk
Support primitives in type info reflection

Tracking issue: rust-lang/rust#146922 `#![feature(type_info)]`

This PR supports {`bool`,`char`,`int`,`uint`,`float`,`str`} primitive types for feature `type_info` reflection.

r? @oli-obk
2026-01-16 13:57:46 +01:00
Jacob Pratt
0cef925c52
Rollup merge of #150611 - from-bool-float-test, r=tgross35
Unify and deduplicate From<T> float tests

cc rust-lang/rust#141726

Unify the From<bool> tests from f16.rs and f128.rs into a single float_test! in mod.rs.
2026-01-15 19:35:46 -05:00
Asuna
b2a7b18ec4 Merge type info variant Uint into Int 2026-01-15 23:04:40 +01:00
Asuna
79ec275e2d Support primitives in type info reflection
Support {bool,char,int,uint,float,str} primitive types for feature
`type_info` reflection.
2026-01-14 19:15:39 +01:00
BD103
71f8ea99fe refactor: move tuples type info ui test to coretest 2026-01-13 12:19:37 -05:00
BD103
e027ecdbb5 feat: support arrays in type reflection 2026-01-13 12:18:57 -05:00
Augusto César Perin
1123177498 Unify and deduplicate From<T> float tests
Co-authored-by: ericinB <ericbncer@gmail.com>
2026-01-12 23:49:20 -03:00
Matthias Krüger
807a5cefd2
Rollup merge of #147938 - const-clone-slice, r=tgross35
Add const cloning of slices and tests

As discussed in https://github.com/rust-lang/rust/pull/143628#discussion_r2390170336, splitting off slice cloning as a separate PR.
r? @tgross35
2026-01-12 00:02:52 +01:00
Pavel Grigorenko
e212560317 Stabilize alloc_layout_extra 2026-01-11 16:39:18 +03:00
Matthias Krüger
57da460fc7
Rollup merge of #150781 - pr/cleanup-rand-usages, r=Mark-Simulacrum
Use `rand` crate more idiomatically

Small cleanup, found while working on something else.
We were using `rand` un-idiomatically in a couple of places, and it was bugging me...
2026-01-11 09:56:40 +01:00
Matthias Krüger
30f9939a0c
Rollup merge of #148941 - stabilize-map-if, r=jhpratt
stabilize `Peekable::next_if_map` (`#![feature(peekable_next_if_map)]`)

# Stabilization report

## Summary

`#![feature(peekable_next_if_map)]` is a variation  of `next_if` on peekable iterators that can transform the peeked item. This creates a way to take ownership of the next item in an iterator when some condition holds, but put the item back when the condition doesn't hold. This pattern would otherwise have needed unwraps in many cases.

[Tracking issue](https://github.com/rust-lang/rust/issues/143702)

### What is stabilized

```rust
impl<I: Iterator> Peekable<I> {
    pub fn next_if_map<R>(
        &mut self,
        f: impl FnOnce(I::Item) -> Result<R, I::Item>,
    ) -> Option<R> {
        ..
    }
    pub fn next_if_map_mut<R>(
        &mut self,
        f: impl FnOnce(&mut I::Item) -> Option<R>,
    ) -> Option<R> {
        ..
    }
}
```

Example usage adapted from the ACP:

```rust
let mut it = Peekable::new("123".chars());

while let Some(digit) = it.next_if_map(|c| c.to_digit(10).ok_or(c)) {
    codepoint = codepoint * 10 + digit;
}
```

or with `next_if_map_mut`:

```rust
let mut it = Peekable::new("123".chars());

while let Some(digit) = iter.next_if_map_mut(|c| c.to_digit(10)) {
    line_num = line_num * 10 + digit;
}
```

Note that the major difference here is that `next_if_map_mut` does not get owned items from the iterator, but mutable references. With that api, the closure can return an `Option` which avoids an `ok_or`. This may require cloning or copying the iterator elements, so if that is expensive, the owned version, `next_if_map`, may be preferable.

### Nightly use

At the moment, this feature is barely used in nightly, though I've found multiple good uses for it in my own projects, hence my pushing for stabilization. It makes the kind of patterns used in recursive descent parsing super concise and maybe with its stabilization it will find more use.

### Test coverage

Besides a quite comprehensive doctest, this feature is tested (including panicking in the closure) here:

c880acdd31/library/coretests/tests/iter/adapters/peekable.rs (L275-L359)

## History

- ACP: https://github.com/rust-lang/libs-team/issues/613 accepted with https://github.com/rust-lang/libs-team/issues/613#issuecomment-3049844223
- implementation: https://github.com/rust-lang/rust/pull/143725 with tests, and no issues reported since july.

## Acknowledgments

ACP, implementation and tracking issue for this feature all by @kennytm <3
2026-01-11 09:56:37 +01:00
Yotam Ofek
f82dd820a5 Use rand crate more idiomatically 2026-01-07 22:31:33 +02:00
Jonathan Brouwer
2c0daa2301
Rollup merge of #147499 - josh-kaplan:master, r=Mark-Simulacrum
Implement round-ties-to-even for Duration Debug for consistency with f64

## Summary

This PR proposes a fix for rust-lang/rust#103747 implementing IEEE-754 S4.3 roundTiesToEven for Duration Debug implementation.

## Testing

Added new test in `time.rs` for  validating roundTiesToEven behavior in Duration formatting. Reran all debug formatting tests in `time.rs` with `./x test library/coretests --test-args time::debug_formatting`.
2025-12-28 18:16:09 +01:00
Jacob Pratt
1c2dbcf33b
Rollup merge of #150016 - usamoi:stabilize-lazy-get, r=jhpratt
stabilize `lazy_get`

closes https://github.com/rust-lang/rust/issues/129333
FCP is finished in https://github.com/rust-lang/rust/issues/129333#issuecomment-3477510482

```@rustbot``` modify labels: +T-libs-api
2025-12-24 02:52:58 -05:00
Deadbeef
54062cff4c move a ui test to coretests unit test
It only tests the usage and formatting of `fmt::Pointer`.
2025-12-22 21:37:18 -05:00
Josh Kaplan
f5aec79668
Implement round-ties-to-even for Duration Debug for consistency with f64 2025-12-22 08:59:20 -05:00
Matthias Krüger
502bf807bd
Rollup merge of #150082 - Enselic:hrtb-fn-pointer, r=fee1-dead
tests/ui/traits/fmt-pointer-trait.rs: Add HRTB fn pointer case

Closes https://github.com/rust-lang/rust/issues/50280 which just **E-needs-test**.  See https://github.com/rust-lang/rust/issues/50280#issuecomment-3664511295 for a bisect of the fix.

The issue description is quite vague, so in the test I am linking directly to the most descriptive comment https://github.com/rust-lang/rust/issues/50280#issuecomment-626035934.
2025-12-21 18:50:43 +01:00
Martin Nordholts
8825e1fe5d library/coretests/tests/fmt/mod.rs: Add HRTB fn pointer case 2025-12-20 20:49:02 +01:00
Amanieu d'Antras
4b07875505 Revert #148937 (Remove initialized-bytes tracking from BorrowedBuf and BorrowedCursor)
This caused several performance regressions because of existing code
which uses `Read::read` and therefore requires full buffer
initialization. This is particularly a problem when the same buffer is
re-used for multiple read calls since this means it needs to be fully
re-initialized each time.

There is still some benefit to landing the API changes, but we will have
to add private APIs so that the existing infrastructure can
track and avoid redundant initialization.
2025-12-17 14:34:56 +00:00
Jana Dönszelmann
dc3786eb3c
stabilize map_next_if 2025-12-17 14:14:17 +01:00
Ivar Flakstad
d5bf1a4c9a Introduce vtable_for intrinsic and use it to implement try_as_dyn and try_as_dyn_mut for fallible coercion from &T / &mut T to &dyn Trait. 2025-12-16 06:39:58 -04:00
usamoi
141342c34f stabilize lazy_get 2025-12-15 18:57:33 +08:00
Matthias Krüger
18fa9ddd77
Rollup merge of #149744 - lemire:main, r=Mark-Simulacrum
test: update duplicate many_digits test to use f64 instead of f32

Replace the f32 test case with an f64 equivalent to improve coverage for parsing large digit counts in double-precision floating-point conversion. Specifically, this PR updates the `many_digits` test in `library/coretests/tests/num/dec2flt/parse.rs` to test f64 (double-precision) parsing instead of f32 (single-precision).

The test verifies that decimal strings with an excessive number of digits (beyond `Decimal::MAX_DIGITS`) are parsed correctly, ensuring proper truncation of insignificant digits. Previously, the same test was repeated twice (see comment https://github.com/rust-lang/rust/pull/86761#issuecomment-3623334228 by `@Viatorus).`

## Changes

- Replaced the duplicated f32 test case with an equivalent f64 test case.
- Updated the expected bit pattern and input string to a very long decimal with many trailing zeros, testing the limits of f64 precision.
2025-12-15 08:08:01 +01:00
Chris Denton
01e40d6755
Rollup merge of #148755 - nxsaken:const_drop_guard, r=dtolnay
Constify `DropGuard::dismiss` and trait impls

Feature: `drop_guard` (rust-lang/rust#144426), `const_convert` (rust-lang/rust#143773), `const_drop_guard` (no tracking issue yet)

Constifies `DropGuard::dismiss` and trait impls.
I reused `const_convert` (rust-lang/rust#143773) for the `Deref*` impls.
2025-12-14 09:18:26 +00:00
nxsaken
0ecf91a701 Use an explicit receiver in DropGuard::dismiss 2025-12-13 14:00:44 +04:00
Evgenii Zheltonozhskii
c1472c573a Add const cloning of slices and tests 2025-12-12 06:31:00 +02:00
Matthias Krüger
26ae47502a
Rollup merge of #148052 - tgross35:stabilize-const_mul_add, r=RalfJung
Stabilize `const_mul_add`

Newly stable API:

```rust
impl {f32, f64} {
    pub const fn mul_add(self, a: Self, b: Self) -> Self;
}
```

This includes making the intrinsics `fmaf{16,32,64,128}` const stable for indirect use, matching similar intrinsics.

Closes: https://github.com/rust-lang/rust/issues/146724
2025-12-10 17:16:46 +01:00
Daniel Lemire
bb549da8f6 test: update duplicate many_digits test to use f64 instead of f32
Replace the f32 test case with an f64 equivalent to improve coverage
for parsing large digit counts in double-precision floating-point
conversion.
2025-12-07 16:51:27 -05:00
Matthias Krüger
8a6f82efac
Rollup merge of #148814 - bend-n:stabilize_array_windows, r=scottmcm
stabilize `array_windows`

Tracking issue: rust-lang/rust#75027
Closes: rust-lang/rust#75027
FCP completed: https://github.com/rust-lang/rust/issues/75027#issuecomment-3477510526
2025-12-06 09:57:59 +01:00
bors
29e035e172 Auto merge of #149632 - matthiaskrgr:rollup-c5iqgtn, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#149521 (Improve `io::Error::downcast`)
 - rust-lang/rust#149544 (Only apply `no_mangle_const_items`'s suggestion to plain const items)
 - rust-lang/rust#149545 (fix the check for which expressions read never type)
 - rust-lang/rust#149570 (rename cortex-ar references to unified aarch32)
 - rust-lang/rust#149574 (Batched compiletest Config fixups)
 - rust-lang/rust#149579 (Motor OS: fix compile error)
 - rust-lang/rust#149595 (Tidying up `tests/ui/issues` tests [2/N])
 - rust-lang/rust#149597 (Revert "implement and test `Iterator::{exactly_one, collect_array}`")
 - rust-lang/rust#149608 (Allow PowerPC spe_acc as clobber-only register)
 - rust-lang/rust#149610 (Implement benchmarks for uN::{gather,scatter}_bits)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-04 14:38:19 +00:00
Matthias Krüger
ac607e0d91
Rollup merge of #149610 - quaternic:gather-scatter-bits-bench, r=Mark-Simulacrum
Implement benchmarks for uN::{gather,scatter}_bits

Feature gate: #![feature(uint_gather_scatter_bits)]
Tracking issue: https://github.com/rust-lang/rust/issues/149069
Accepted ACP: https://github.com/rust-lang/libs-team/issues/695#issuecomment-3549284861

For each method, there are three benchmarks, which differ in that the mask (second) argument is one of:
 - constant at compile time
 - runtime value but invariant for the measured loop
 - different for each call

Sample output
```text
    num::int_bits::u32::constant::gather_bits      555.82ns/iter   +/- 22.41
    num::int_bits::u32::constant::scatter_bits     545.45ns/iter  +/- 124.26
    num::int_bits::u32::invariant::gather_bits    8178.86ns/iter  +/- 217.37
    num::int_bits::u32::invariant::scatter_bits   7135.95ns/iter  +/- 214.51
    num::int_bits::u32::variable::gather_bits    10539.29ns/iter  +/- 198.90
    num::int_bits::u32::variable::scatter_bits    9671.26ns/iter  +/- 254.88
```
(and similarly for the other `uN` types)
2025-12-04 09:22:16 +01:00
Matthias Krüger
8fe12253f7
Rollup merge of #149539 - quaternic:gather-scatter-bits, r=Mark-Simulacrum
Additional test for uN::{gather,scatter}_bits

Feature gate: #![feature(uint_gather_scatter_bits)]
Tracking issue: https://github.com/rust-lang/rust/issues/149069
Accepted ACP: https://github.com/rust-lang/libs-team/issues/695#issuecomment-3549284861

Adds an additional runtime test for `uN::gather_bits` and `uN::scatter_bits` in coretests. They are each other's inverses in a sense, so a shared test can test both with relative ease.

I plan to follow up with optimized implementations for these functions.
2025-12-04 08:46:22 +01:00