Commit Graph

321 Commits

Author SHA1 Message Date
bendn 68abe69f13 iter::ArrayChunks::into_remainder ought not return option 2025-11-20 15:27:57 +07:00
Matthias Krüger 48fa9138c3 Rollup merge of #148798 - tamird:esc-single-quote, r=Amanieu
Match <OsString as Debug>::fmt to that of str

Fixes rust-lang/rust#114583.
2025-11-19 09:48:10 +01:00
Matthias Krüger 8b7479003b Rollup merge of #148797 - sorairolake:feature/non-zero-uint-bit-width, r=scottmcm
feat: Add `bit_width` for unsigned `NonZero<T>`

- Tracking issue: rust-lang/rust#142326

This pull request adds a method to the unsigned `NonZero<T>` that return the minimum number of bits required to represent a value.

This can be achieved by using the `get` method and the methods added in rust-lang/rust#142328, but I think adding the `NonZero::bit_width` method is useful because it accomplishes the same thing a little more succinctly.
2025-11-19 09:48:09 +01:00
Shun Sakai a25950dec6 feat: Change return type of NonZero::bit_width
Return `NonZero<u32>` instead of `u32`.
2025-11-19 03:17:38 +09:00
Tamir Duberstein 1cfd0b7c55 Match <OsString as Debug>::fmt to that of str
819247f1 changed <str as Debug>::fmt such that it does not escape single
quotes, but neglected to apply the same choice to OsString. This commit
does that.
2025-11-17 16:05:00 -05:00
Matthias Krüger 5dd82e8ed9 Rollup merge of #145610 - GrigorenkoPV:char_max_len, r=Amanieu
Stabilize `char_max_len`

Tracking issue: rust-lang/rust#121714

r? t-libs-api

`@rustbot` label +needs-fcp -T-libs +T-libs-api

Closes rust-lang/rust#121714
2025-11-17 18:07:31 +01:00
Ralf Jung 907fd85e16 const-eval: fix and re-enable pointer fragment support 2025-11-15 10:09:42 +01:00
Pavel Grigorenko f9dcc6b21c Stabilize char_max_len 2025-11-14 18:23:19 +03:00
bors af5c5b74c8 Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Simulacrum,oli-obk
stabilize duration_from_nanos_u128

libs-api FCP passed in https://github.com/rust-lang/rust/issues/139201.
Closes https://github.com/rust-lang/rust/issues/139201.

`@oli-obk` would you prefer if we did a const-hack to avoid allowing `const_trait_impl` here?
2025-11-13 14:48:17 +00:00
Stuart Cook 044c079b15 Rollup merge of #147771 - nxsaken:div_shlr_exact, r=dtolnay
Rename `*exact_{div,shr,shl}` to `*{div,shr,shl}_exact`

Related to rust-lang/rust#144336 and rust-lang/rust#139911, see https://github.com/rust-lang/rust/issues/139911#issuecomment-3406807537. I haven't touched the `exact_div`, `exact_udiv` and `exact_sdiv` intrinsics. Let me know if I should.
2025-11-11 21:09:34 +11:00
Shun Sakai f4efc370e6 feat: Add bit_width for unsigned NonZero<T> 2025-11-11 01:14:38 +09:00
Guillaume Gomez 6e14beae2a Allow function_casts_as_integer in coretest test 2025-11-10 16:38:28 +01:00
Ralf Jung b032fac34e stabilize duration_from_nanos_u128 2025-11-06 18:08:29 +01:00
Jieyou Xu 4aeb297064 Revert "unicode_data refactors RUST-147622"
This PR reverts RUST-147622 for several reasons:

1. The RUST-147622 PR would format the generated core library code using
   an arbitrary `rustfmt` picked up from `PATH`, which will cause
   hard-to-debug failures when the `rustfmt` used to format the
   generated unicode data code versus the `rustfmt` used to format the
   in-tree library code.
2. Previously, the `unicode-table-generator` tests were not run under CI
   as part of `coretests`, and since for `x86_64-gnu-aux` job we run
   library `coretests` with `miri`, the generated tests unfortunately
   caused an unacceptably large Merge CI time regression from ~2 hours
   to ~3.5 hours, making it the slowest Merge CI job (and thus the new
   bottleneck).
3. This PR also has an unintended effect of causing a diagnostic
   regression (RUST-148387), though that's mostly an edge case not
   properly handled by `rustc` diagnostics.

Given that these are three distinct causes with non-trivial fixes, I'm
proposing to revert this PR to return us to baseline. This is not
prejudice against relanding the changes with these issues addressed, but
to alleviate time pressure to address these non-trivial issues.
2025-11-03 19:53:11 +08:00
Matthias Krüger 01ab3e369b Rollup merge of #146260 - Qelxiros:146179-sliceindex-wrappers, r=jhpratt
add SliceIndex wrapper types Last and Clamp<Idx>

Tracking issue: rust-lang/rust#146179
2025-11-03 06:54:35 +01:00
nxsaken b76267672f Rename {i,u}N::*exact_div to *div_exact 2025-11-02 16:34:36 +04:00
bors 73e6c9ebd9 Auto merge of #147784 - nxsaken:div_exact_return_option, r=dtolnay
Return `Option` from `exact_div` and inherit overflow checks

According to https://github.com/rust-lang/rust/issues/139911#issuecomment-3404056127, `exact_div` should return `Option::None` if `self % rhs != 0`, panic if `rhs == 0`, and handle overflow conditionally (panic in debug, wrap in release).

rust-lang/rust#147771 should rename `exact_div` to `div_exact`.
2025-11-02 08:05:11 +00:00
Matthias Krüger 75fbbd32f0 Rollup merge of #147622 - Kmeakin:km/unicode-data/refactors, r=joboet
`unicode_data` refactors

Minor refactors to `unicode_data` that occured to me while trying to reduce the size of the tables. Splitting into a separate PR. NFC
2025-10-31 18:41:48 +01:00
Karl Meakin 0e6131c9aa refactor: make unicode_data tests normal tests
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!
2025-10-31 14:12:17 +00:00
ltdk 6f649e4e1a const select_unpredictable 2025-10-26 21:33:00 -04:00
Romain Perier 70876ee42b Unify and deduplicate max recip float tests 2025-10-25 17:57:06 +02:00
Matthias Krüger 8c40b9c6d7 Rollup merge of #147788 - clarfonthey:const-cell, r=oli-obk
const Cell methods

Tracking: rust-lang/rust#147787

r? `@oli-obk`
2025-10-22 07:12:11 +02:00
ltdk 31a2c565bd Move const_drop_in_place test from ptr to manually_drop module 2025-10-19 14:43:45 -04:00
Matthias Krüger cb3c6edc9b Rollup merge of #147258 - hkBst:panic-last-repeat, r=scottmcm
iter repeat: panic on last

https://github.com/rust-lang/rust/issues/146660#issuecomment-3356842371
2025-10-18 08:08:36 +02:00
ltdk 97b7170eef const Cell methods 2025-10-16 16:09:31 -04:00
nxsaken 298d825cbb Return Option from exact_div and inherit overflow checks 2025-10-16 22:03:50 +04:00
Matthias Krüger 252974a717 Rollup merge of #146187 - clarfonthey:const-drop-in-place, r=oli-obk
Unstably constify `ptr::drop_in_place` and related methods

Tracking: rust-lang/rust#109342
Supercedes: rust-lang/rust#145725

Makes methods const:

* `core::ptr::drop_in_place`
* `core::mem::ManuallyDrop::drop`
* `core::mem::MaybeUninit::assume_init_drop`
* `<[core::mem::MaybeUninit<_>]>::assume_init_drop`
* `<*mut _>::drop_in_place`
* `core::ptr::NonNull::drop_in_place`
2025-10-14 19:47:28 +02:00
Matthias Krüger 817720c9a9 Rollup merge of #138799 - joboet:extend-tuple, r=Mark-Simulacrum
core: simplify `Extend` for tuples

This is an alternative to https://github.com/rust-lang/rust/pull/137400. The current macro is incredibly complicated and introduces subtle bugs like calling the `extend_one` of the individual collections in backwards order. This PR drastically simplifies the macro by removing recursion and moving the specialization out of the macro. It also fixes the ordering issue described above (I've stolen the test of the new behaviour from https://github.com/rust-lang/rust/pull/137400). Additionally, the 1-tuple is now special-cased to allow taking advantage of the well-optimized `Extend` implementations of the individual collection.
2025-10-12 10:13:12 +02:00
Marijn Schouten d52744e9fc iter repeat: panic on last 2025-10-07 16:43:48 +00:00
Marijn Schouten 50398e2e75 iter repeat: add tests for new count and last behavior 2025-09-30 17:56:18 +00:00
bors 40ace17fc3 Auto merge of #145882 - m-ou-se:format-args-extend-1-arg, r=petrochenkov
Extended temporary argument to format_args!() in all cases

Fixes https://github.com/rust-lang/rust/issues/145880 by removing the special case.
2025-09-26 04:34:09 +00:00
Stuart Cook cec668fefc Rollup merge of #146737 - RalfJung:f16-f128-miri, r=tgross35
f16_f128: enable some more tests in Miri

For some reason, a bunch of tests were disabled in Miri that don't use any fancy intrinsics. Let's enable them.

I verified this with `./x miri library/core --no-doc -- float`.

r? `@tgross35`
2025-09-25 20:31:55 +10:00
Stuart Cook 8e62f95376 Rollup merge of #146735 - Qelxiros:const_mul_add, r=tgross35,RalfJung
unstably constify float mul_add methods

Tracking issue: rust-lang/rust#146724
r? `@tgross35`
2025-09-25 20:31:54 +10:00
Jeremy Smart a00f24116e unstably constify float mul_add methods
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-09-24 15:21:31 -04:00
Ralf Jung f509dff56d f16_f128: enable some more tests in Miri 2025-09-24 16:47:13 +02:00
Nathaniel McCallum 5dde557fc4 constify {float}::total_cmp() 2025-09-22 10:24:39 -04:00
Matthias Krüger c0f5eefa27 Rollup merge of #146486 - ferrocene:pvdrz/improve-atomic-coverage, r=ibraheemdev
Improve `core::sync::atomic` coverage

This PR improves the `core::sync::atomic` coverage by adding new tests to `coretests`.

r? libs
2025-09-21 22:20:26 +02:00
Matthias Krüger fd852f4bee Rollup merge of #146487 - ferrocene:pvdrz/improve-num-coverage, r=joboet
Improve `core::num` coverage

This PR improves the `core::num` coverage by adding a new test to `coretests`.

r? libs
2025-09-18 17:20:57 +02:00
Matthias Krüger f4a522d1f8 Rollup merge of #146474 - ferrocene:pvdrz/improve-ascii-coverage, r=Noratrieb
Improve `core::ascii` coverage

This PR improves the `core::ascii` coverage by adding a new test to `coretests`

r? `@workingjubilee`
2025-09-16 20:42:22 +02:00
Christian Poveda 94d3a8cb91 Improve core::sync::atomic coverage 2025-09-16 10:26:52 -05:00
Christian Poveda e652f97c6b Improve core::ascii coverage 2025-09-16 10:05:40 -05:00
Jeremy Smart 78d8ce7301 add SliceIndex wrapper types Last and Clamp<Idx> 2025-09-15 15:25:12 -04:00
Matthias Krüger 32c045ecd1 Rollup merge of #146488 - ferrocene:pvdrz/improve-ptr-coverage, r=Mark-Simulacrum
Improve `core::ptr` coverage

This PR improves the `core::ptr` coverage by adding a new test to `coretests` for the `<*const T>::is_aligned_to` method.

r? libs
2025-09-15 06:03:48 +02:00
Matthias Krüger 9070e95dda Rollup merge of #146478 - ferrocene:pvdrz/improve-fmt-coverage, r=Mark-Simulacrum
Improve `core::fmt` coverage

This PR improves the `core::fmt` coverage by adding new tests to `coretests`
2025-09-15 06:03:46 +02:00
Matthias Krüger fa63dbf301 Rollup merge of #146284 - Kivooeo:blazing-fast-division-bignum, r=Mark-Simulacrum
Remove `div_rem` from `core::num::bignum`

This fixes very old fixme that sounds like this

```
Stupid slow base-2 long division taken from
https://en.wikipedia.org/wiki/Division_algorithm
FIXME use a greater base ($ty) for the long division.
```

By deleting this method since it was never used
2025-09-15 06:03:45 +02:00
Jana Dönszelmann ec0f3bd2ed Rollup merge of #146481 - ferrocene:pvdrz/improve-hash-coverage, r=jhpratt
Improve `core::hash` coverage

This PR improves the `core::hash` coverage by adding a new test to `coretests` and extending one of the existing tests to use 128-bit integers

r? libs
2025-09-13 02:40:46 +02:00
Jana Dönszelmann 7928be014c Rollup merge of #146477 - ferrocene:pvdrz/improve-char-coverage, r=Noratrieb
Improve `core::char` coverage

This PR improves the `core::char` coverage by adding new tests to `coretests`

r? ``@workingjubilee``
2025-09-13 02:40:45 +02:00
Jana Dönszelmann e4dbbbd322 Rollup merge of #146452 - ferrocene:pvdrz/improve-alloc-coverage, r=tgross35
Improve `alloc::Layout` coverage

This PR improves the `core::alloc` coverage by adding a new test to `coretests` that cover the `Layout` methods when they error.

Tracking issue: https://github.com/rust-lang/rust/issues/55724
2025-09-13 02:40:45 +02:00
Christian Poveda 87ae4dbf5c Improve core::ptr coverage 2025-09-12 14:41:26 -05:00
Christian Poveda afe8f81c73 Improve core::num coverage 2025-09-12 14:35:20 -05:00