Commit Graph

450 Commits

Author SHA1 Message Date
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 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
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
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
Jonathan Brouwer c4384629c0 Rollup merge of #153265 - asder8215:intersperse_changes, r=jhpratt
Clarified doc comments + added tests confirming current behavior for intersperse/intersperse_with

This PR builds on top of rust-lang/rust#152855. I just added clarifying comments to `intersperse`/`intersperse_with` about its guarantees for fused iterators (and how behavior for non-fused iterators are subject to change). I also added in tests for non-fused iterators demonstrating its current behavior; fused iterators are already tested for in existing tests for `intersperse`/`intersperse_with`.
2026-03-03 07:14:12 +01:00
Mahdi Ali-Raihan c8d343e5c8 Added guarantee and non-guarantee comments + tests for intersperse/intersperse_with regarding fused/non-fused iterators 2026-03-02 19:44:15 -05:00
mu001999 ff0f239bb1 Remove redundant self usages 2026-02-25 22:51:53 +08:00
Jonathan Brouwer 1d6e7ec8d4 Rollup merge of #152003 - 9SonSteroids:trait_info_of, r=oli-obk
Reflection TypeId::trait_info_of

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

This is for https://github.com/rust-lang/rust/issues/146922.

As https://github.com/rust-lang/rust/pull/151236 was requested to be remade by someone I implemented the functionality as `TypeId::trait_info_of` which additionally allows getting the vtable pointer to build `dyn` Objects in recursive reflection.

It allows checking if a TypeId implements a trait. Since this is my first PR feel free to tell me if there are any formal issues.
2026-02-23 20:46:11 +01:00
joboet fa99d5b72b core: respect precision in ByteStr Display 2026-02-23 18:49:55 +01:00
Folkert de Vries 14d29f9ae2 Stabilize cfg_select 2026-02-22 19:59:25 +01:00
nxsaken e9bf9291a7 Stabilize control_flow_ok 2026-02-20 18:18:34 +04:00
jasper3108 7857058a6b nix vtable_for intrinsic 2026-02-20 10:16:36 +01:00
jasper3108 01627b7441 Support getting TypeId's Trait and vtable 2026-02-20 10:16:36 +01:00
Jonathan Brouwer 5d6c830832 Rollup merge of #152173 - 9SonSteroids:fn_ptr_type_info, r=oli-obk
Reflection TypeKind::FnPtr

This is for https://github.com/rust-lang/rust/issues/146922.

Const-eval currently lacks full support for function pointer (fn) types. We should implement handling of FnPtr TypeKind, covering safe and unsafe functions, Rust and custom ABIs, input and output types, higher-ranked lifetimes, and variadic functions.
2026-02-18 22:19:49 +01:00
jasper3108 7287be9006 Implement reflection support for function pointer types and add tests
- Implement handling of FnPtr TypeKind in const-eval, including:
  - Unsafety flag (safe vs unsafe fn)
  - ABI variants (Rust, Named(C), Named(custom))
  - Input and output types
  - Variadic function pointers
- Add const-eval tests covering:
  - Basic Rust fn() pointers
  - Unsafe fn() pointers
  - Extern C and custom ABI pointers
  - Functions with multiple inputs and output types
  - Variadic functions
- Use const TypeId checks to verify correctness of inputs, outputs, and payloads
2026-02-18 17:18:16 +01:00
okaneco 67799c9739 core: Implement feature float_exact_integer_constants
Implement accepted ACP for `MAX_EXACT_INTEGER` and `MIN_EXACT_INTEGER`
on `f16`, `f32`, `f64`, and `f128`
Add tests to `coretests/tests/floats/mod.rs`
Disable doc tests for i586 since float<->int casts return incorrect
results
2026-02-16 16:29:31 -05:00
xonx 2c1d605f21 unify and deduplicate floats 2026-02-15 18:00:41 +00:00
Folkert de Vries b935f379b4 implement carryless_mul 2026-02-14 21:23:30 +01:00
mu001999 73c42c1800 Remove or allow unused features in library doc and tests 2026-02-13 09:27:16 +08:00
Trevor Gross 23e44f65aa 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.
2026-02-11 17:10:33 -06:00
Asuna a575fe168f Erase type lifetime before writing type ID 2026-02-10 14:08:11 +01:00
Asuna 98e0c34f7f Support unions in type info reflection 2026-02-10 13:53:27 +01:00
Asuna e9037882c1 Support enums in type info reflection 2026-02-10 13:53:26 +01:00
Asuna 870fd9070b Add generics info for structs in type info 2026-02-10 13:45:09 +01:00