470 Commits

Author SHA1 Message Date
Ralf Jung 923311c40b min/max_by tests: also check result 2026-04-08 17:59:14 +02:00
Jonathan Brouwer 6ee4118299 Rollup merge of #154761 - Vastargazing:add-regression-tests-cmp-argument-order, r=jhpratt
coretests: add argument order regression tests for min_by/max_by/minmax_by

PR rust-lang/rust#136307 introduced a regression in min_by, max_by, and minmax_by:
the compare closure received arguments as (v2, v1) instead of (v1, v2),
contrary to the documented contract.
Although this was fixed in rust-lang/rust#139357, no regression tests were added.
This PR adds regression tests for all three functions, verifying that compare
always receives arguments in the documented order (v1, v2).
As a bonus: first coretests coverage for minmax_by.
2026-04-07 17:26:31 +02: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
bors 4e836866b5 Auto merge of #154824 - JonathanBrouwer:rollup-neQUhVI, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#147552 ([Debugger Visualizers] Optimize lookup behavior)
 - rust-lang/rust#154052 (float: Fix panic at max exponential precision)
 - rust-lang/rust#154706 (fix compilation of time/hermit.rs)
 - rust-lang/rust#154707 (Make `substr_range` and `subslice_range` return the new `Range` type)
 - rust-lang/rust#154767 (triagebot: roll library reviewers for `{coretests,alloctests}`)
 - rust-lang/rust#154797 (bootstrap: Include shorthand aliases in x completions)
2026-04-04 21:00:26 +00: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
bors e0e95a7187 Auto merge of #154815 - JonathanBrouwer:rollup-sdqRx2J, r=JonathanBrouwer
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#149868 (rustc: Stop passing `--allow-undefined` on wasm targets)
 - rust-lang/rust#153555 (Clarified docs in std::sync::RwLock + added test to ensure that max reader count is respected)
 - rust-lang/rust#152851 (Fix SGX delayed host lookup via ToSocketAddr)
 - rust-lang/rust#154051 (use libm for acosh and asinh)
 - rust-lang/rust#154581 (More informative `Debug for vec::ExtractIf`)
 - rust-lang/rust#154461 (Edit the docs new_in() and with_capacity_in())
 - rust-lang/rust#154526 (Panic/return false on overflow in no_threads read/try_read impl)
 - rust-lang/rust#154798 (rustdoc-search: match path components on words)
2026-04-04 17:46:11 +00:00
Jonathan Brouwer 69751ec861 Rollup merge of #154051 - malezjaa:approximations-acosh-and-asinh, r=tgross35
use libm for acosh and asinh

Fixes rust-lang/rust#153878

Uses libm for `acosh` and `asinh`
2026-04-04 17:19:10 +02: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
Vastargazing 51c4299433 coretests: add argument order regression tests for min_by/max_by/minmax_by
A recent regression swapped the argument order passed to the compare
closure in min_by, max_by and minmax_by (compare(&v2, &v1) instead of
compare(&v1, &v2)). This was fixed, but no regression test was added.

Add tests that record the arguments the compare closure receives and
assert they match (v1, v2) — the documented contract.
2026-04-04 13:34:45 +03:00
malezjaa a1feab1638 use libm for acosh and asinh 2026-04-04 09:28:39 +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
Peter Jaszkowiak 620e92f016 stabilize new Range type and iterator
stabilizes `core::range::Range`
stabilizes `core::range::RangeIter`
stabilizes `std::range` which was missed in prior PRs

Updates docs to reflect stabilization (removed "experimental")

`RangeIter::remainder` is excluded from stabilization
2026-03-30 22:17:27 -06: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
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
Jonathan Brouwer 1e3d3bdb24 Rollup merge of #153874 - bend-n:constify-const-fn-destruct, r=oli-obk
constify const Fn*: Destruct

makes closures const destruct where their upvars are. i think this makes sense
and is how this should be implemented.

r? @oli-obk
2026-03-24 18:14:15 +01:00
Jacob Pratt 355b4f05ce Rollup merge of #154132 - bjorn3:fix_missing_feature_gate, r=Mark-Simulacrum
Add missing num_internals feature gate to coretests/benches

This will allow getting rid of the patch at https://github.com/rust-lang/rustc_codegen_cranelift/blob/main/patches/0030-sysroot_tests-Add-missing-feature-gate.patch
2026-03-23 23:42:50 -04:00
Jonathan Brouwer 3cad6d130a Rollup merge of #122668 - Jules-Bertholet:titlecase, r=Mark-Simulacrum
Add APIs for dealing with titlecase

ACP: https://github.com/rust-lang/libs-team/issues/354
Tracking issue: https://github.com/rust-lang/rust/issues/153892

r? libs-api

@rustbot label T-libs -T-libs-api A-unicode

~~The last commit has some insta-stable `PartialEq` impls, therefore: @rustbot label -needs-fcp
Alternatively, I could split those out into a follow-up PR.~~ (Edit: will do in follow-up)
2026-03-23 20:18:32 +01:00
Jules Bertholet e1e903c7b7 Exclude slow tests from miri 2026-03-23 08:17:14 -04:00
Jonathan Brouwer 699e1b395e Rollup merge of #153931 - cyrgani:old-consts, r=Mark-Simulacrum
remove usages of to-be-deprecated numeric constants

Split out from rust-lang/rust#146882.
2026-03-23 12:14:55 +01:00
Jonathan Brouwer cd3e866c7a Rollup merge of #153880 - asder8215:intersperse_nonfused, r=Mark-Simulacrum
Lifted intersperse and intersperse_with Fused transformation and updated documentation + tests

This PR once again builds on top of rust-lang/rust#152855. From the discussion in rust-lang/rust#152855, libs team came to the conclusion that `intersperse`/`intersperse_with` shouldn't transform the given iterator to a fused iterator always and a separator should be emitted between `Some(_)` items for non fused iterators (particularly just right before the subsequent `Some(_)`).

On top of the change Zakarumych added in the PR, I lifted the `FusedIterator` trait and transformation of the inner `iter` for `Intersperse`/`IntersperseWith`, so that we can display this behavior. I've adjusted the documentation and tests accordingly to reflect this change as well.

r? @jhpratt
2026-03-23 12:14:54 +01:00
Jules Bertholet 0a49163be7 Don't fuse in MapWindows 2026-03-21 18:16:51 -04:00
Jules Bertholet 8d072616a5 Add APIs for dealing with titlecase
- `char::is_cased`
- `char::is_titlecase`
- `char::case`
- `char::to_titlecase`
2026-03-21 14:30:38 -04:00
Jonathan Brouwer c82d8db4a8 Rollup merge of #154103 - tgross35:float-test-mod, r=folkertdev
coretests: Expand ieee754 parsing and printing tests to f16

Use `float_test!` to cover all types, with a note about f128 missing the traits. Also includes some minor reorganization.
2026-03-20 13:24:21 +01:00
bjorn3 5ef93c12b6 Add missing num_internals feature gate to coretests/benches 2026-03-20 12:21:24 +01:00
Trevor Gross 16f89853f7 coretests: Expand ieee754 parsing and printing tests to f16
Use `float_test!` to cover all types, with a note about f128 missing the
traits.
2026-03-19 17:04:17 +00:00
Trevor Gross 4211234269 coretests: Give ieee754.rs a more accurate name 2026-03-19 16:21:40 +00:00
Trevor Gross f9c0284206 coretests: Move the float module under num
This is just a single file, so move it under `num` which already has
some float-related tests. This also closer mirrors source in `core`.
2026-03-19 15:42:55 +00:00
Jonathan Brouwer 7c6fc44b7c Rollup merge of #151905 - tgross35:dec2flt-traits, r=Mark-Simulacrum
Split the `dec2flt::RawFloat` trait for easier reuse

`RawFloat` is an internal trait with quite a few useful float properties. It currently resides in the `dec2flt` module but is also used in parsing, and would be nice to reuse other places. Unfortunately it cannot be implemented on `f128` because of limitations with how the parsing API is implemented (mantissa must fit into a u64).

To make the trait easier to work with, split it into the following:

* `Float`: Anything that is reasonably applicable to all floating point types.
* `FloatExt`: Items that should be part of `Float` but don't work for all float types. This will eventually be merged back into `Float` once it can be implemented on f128.
* `Lemire`: Items that are specific to the Lemire dec2flt algorithm.

These traits are then moved to places that make sense.

Builds on top of https://github.com/rust-lang/rust/pull/151900
2026-03-19 13:42:32 +01:00
bendn b90abe64c1 constify const Fn*: Destruct 2026-03-17 23:47:42 +07:00
cyrgani a893257cea remove usages of to-be-deprecated numeric constants 2026-03-15 22:14:11 +00:00
Ralf Jung c7220f423b rename min/maxnum intrinsics to min/maximum_number and fix their LLVM lowering 2026-03-15 14:53:00 +01:00
Mahdi Ali-Raihan 800d9ea8e8 Lifted intersperse and intersperse_with Fused restrictions and updated documentation + tests 2026-03-14 13:57:10 -04:00
Trevor Gross bec94a33d5 dec2flt: Move internal traits to better locations
`Float` and `FloatExt` are already used by both parsing and printing, so
move them out of `dec2flt` to a new module in `num::imp`. `Int` `Cast`
have the potential to be used more places in the future, so move them
there as well. `Lemire` is the only remaining trait; since it is small,
move it into the `dec2flt` root.

The `fmt::LowerExp` bound is removed from `Float` here since the trait
is moving into a module without `#[cfg(not(no_fp_fmt_parse))]` and it
isn't implemented with that config (it's not easily possible to add
`cfg` attributes to a single supertrait, unfortunately). This isn't a
problem since it isn't actually being used.
2026-03-14 04:34:52 -05:00
Trevor Gross b07c0439a4 dec2flt: Split up the RawFloat trait
`RawFloat` is currently used specifically for the implementation of the
lemire algorithm, but it is useful for more than that. Split it into
three different traits:

* `Float`: Anything that is reasonably applicable to all floating point
  types.
* `FloatExt`: Items that should be part of `Float` but don't work for
  all float types. This will eventually be merged back into `Float`.
* `Lemire`: Items that are specific to the Lemire algorithm.
2026-03-14 04:34:52 -05:00
Ralf Jung bc4dfa5e33 miri-test-libstd: use --tests and update some comments 2026-03-11 15:17:23 +01:00
Benoît du Garreau d88f08e645 Rename BorrowedCursor::advance_unchecked to advance
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2026-03-10 18:03:22 +01:00
Benoît du Garreau df42b19088 core: Make BorrowedBuf::init a boolean
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2026-03-10 18:03:15 +01:00
bors 0c68443b0a Auto merge of #153642 - matthiaskrgr:rollup-IHw8KqK, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#148562 (In `Option::get_or_insert_with()`, forget the `None` instead of dropping it.)
 - rust-lang/rust#153325 (tests/ui/cfg: add annotations for reference rules)
 - rust-lang/rust#153621 (Remove `TyCtxt::node_span_lint` method)
 - rust-lang/rust#153627 (rustdoc-json: Improve docs for `ItemEnum::item_kind`)
2026-03-10 10:31:56 +00:00
Matthias Krüger ce972294a5 Rollup merge of #148562 - kpreid:get-init-drop, r=oli-obk
In `Option::get_or_insert_with()`, forget the `None` instead of dropping it.

Per https://github.com/rust-lang/rust/pull/148486#issuecomment-3493665688

In `Option::get_or_insert_with()`, after replacing the `None` with `Some`, forget the `None` instead of dropping it.

This allows eliminating the `T: [const] Destruct` bounds, making the functions more flexible in (unstable) const contexts, and avoids generating an implicit `drop_in_place::<Option<T>>()` that will never do anything (and which might even persist after optimization).
2026-03-10 07:21:58 +01:00
bors 3bc6ea5673 Auto merge of #152954 - Kmeakin:km/unicode-data/case-mapping, r=Mark-Simulacrum
Unicode data: reduce size of to_lower/to_upper tables

Reduces the combined size of to_lower and to_upper from 25,364 bytes to 3,110 bytes. Explained in detail in the doc comments
2026-03-10 06:20:10 +00:00
bors 98e7077b90 Auto merge of #153025 - joboet:bytestr_precision_display, r=Mark-Simulacrum
core: respect precision in `ByteStr` `Display`

Fixes rust-lang/rust#153022.

`ByteStr`'s `Display` implementation didn't respect the precision parameter. Just like `Formatter::pad`, this is fixed by counting off the characters in the string and truncating after the requested length – with the added complication that the `ByteStr` needs to be divided into chunks first. By including a fast path that avoids counting the characters when no parameters were specified this should also fix the performance regressions caused by rust-lang/rust#152865.
2026-03-09 04:13:35 +00:00
Karl Meakin 95365cc5bf Make unicode_data tests normal
Instead of generating a standalone executable to test `unicode_data`,
generate normal tests in `coretests`. This ensures tests are always
generated, and will be run as part of the normal testsuite.

Also change the generated tests to loop over lookup tables, rather than
generating a separate `assert_eq!()` statement for every codepoint. The
old approach produced a massive (20,000 lines plus) file which took
minutes to compile!
2026-03-08 22:38:31 +00:00
Jonathan Brouwer 83e6dbf9e1 Rollup merge of #151900 - tgross35:num-internal-imp, r=Mark-Simulacrum
num: Separate public API from internal implementations

Currently we have a single `core::num` module that contains both thin wrapper API and higher-complexity numeric routines. Restructure this by moving implementation details to a new `imp` module.

This results in a more clean separation of what is actually user-facing compared to items that have a stability attribute because they are public for testing.

The first commit does the actual change then the second moves a portion back.
2026-03-08 22:51:52 +01:00
Ralf Jung 0fd3ac4c97 libcore float tests: replace macro shadowing by const-compatible macro 2026-03-06 12:07:25 +01:00
Jonathan Brouwer 1c44dbd580 Rollup merge of #152164 - mu001999-contrib:lint/unused_features, r=JonathanBrouwer
Lint unused features

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152164)*

Fixes rust-lang/rust#44232
Fixes rust-lang/rust#151752

---

This PR records used features through query side effect, then reports unsued features finally.
2026-03-04 19:30:36 +01:00
Stuart Cook 54bb7b8212 Rollup merge of #153358 - eggyal:duration-flop-boundary-tests, r=tgross35
Boundary tests for various Duration-float operations

As requested in https://github.com/rust-lang/rust/pull/150933#discussion_r2875490030

r? tgross35
2026-03-04 11:54:09 +11:00
mu001999 7ffaa41662 Remove unused features in library tests 2026-03-04 08:06:44 +08:00
Alan Egerton d96ec37d7e Boundary tests for various Duration-float operations 2026-03-03 19:01:53 +00:00
Jonathan Brouwer f4810cb4a3 Rollup merge of #152911 - nxsaken:stable_control_flow_ok, r=dtolnay
Stabilize `control_flow_ok`

Feature: `control_flow_ok`
Tracking issue: rust-lang/rust#140266

r? @dtolnay
2026-03-03 19:11:49 +01:00