about summary refs log tree commit diff
path: root/library/coretests
AgeCommit message (Collapse)AuthorLines
2025-09-13Rollup merge of #146481 - ferrocene:pvdrz/improve-hash-coverage, r=jhprattJana Dönszelmann-0/+13
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-13Rollup merge of #146477 - ferrocene:pvdrz/improve-char-coverage, r=NoratriebJana Dönszelmann-0/+44
Improve `core::char` coverage This PR improves the `core::char` coverage by adding new tests to `coretests` r? ``@workingjubilee``
2025-09-13Rollup merge of #146452 - ferrocene:pvdrz/improve-alloc-coverage, r=tgross35Jana Dönszelmann-0/+24
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-12Improve `core::hash` coverageChristian Poveda-0/+13
2025-09-12Improve `core::char` coverageChristian Poveda-0/+44
2025-09-12Improve `core::alloc` coverageChristian Poveda-0/+24
2025-09-12Constify Eq, Ord, PartialOrdEvgenii Zheltonozhskii-4/+3
2025-09-11Rollup merge of #146425 - ferrocene:pvdrz/improve-array-coverage, ↵Stuart Cook-0/+7
r=workingjubilee Improve `core::array` coverage This PR improves the `core::array` coverage by adding new tests to `coretests`
2025-09-11Rollup merge of #146424 - ferrocene:pvdrz/improve-ops-coverage, r=workingjubileeStuart Cook-1/+75
Improve `core::ops` coverage This PR improves the `core::ops` coverage by adding new tests to `coretests`
2025-09-11Rollup merge of #146380 - rperier:unify_and_dedup_bits_conv_float_tests, ↵Stuart Cook-110/+63
r=tgross35 Unify and deduplicate bits conv float tests cc rust-lang/rust#141726 This is a proposal to unify and deduplicate the bits conv tests for f16, f32, f64 and f128
2025-09-10Improve `core::array` coverageChristian Poveda-0/+7
2025-09-10Update library/coretests/tests/ops.rsChristian Poveda Ruiz-1/+2
Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-09-10Improve `core::ops` coverageChristian Poveda-1/+74
2025-09-10Unify and deduplicate bits conv float testsRomain Perier-110/+63
2025-09-08const-eval: disable pointer fragment supportRalf Jung-4/+5
2025-09-06Rollup merge of #145940 - pascaldekloe:int-exp-tune, r=tgross35Trevor Gross-0/+24
single buffer for exponent fmt of integers No need for fragmented buffers when formatting. ``` orig.txt: fmt::write_i128_exp 143.39ns/iter +/- 0.32 orig.txt: fmt::write_i64_exp 68.72ns/iter +/- 0.03 new.txt: fmt::write_i128_exp 138.29ns/iter +/- 0.50 new.txt: fmt::write_i64_exp 58.93ns/iter +/- 4.62 ``` This patch fully eliminates unsafe pointer use (after rust-lang/rust#135265 and rust-lang/rust#136594). r? libs
2025-09-05Rollup merge of #146152 - rperier:unify_and_dedup_algebraic_float_tests, ↵Trevor Gross-83/+44
r=tgross35 Unify and deduplicate algebraic float tests cc rust-lang/rust#141726 This is a proposal to unify and deduplicate the algebraic tests for f16, f32, f64 and f128
2025-09-04Rollup merge of #145690 - sayantn:integer-funnel-shift, r=tgross35Jacob Pratt-0/+37
Implement Integer funnel shifts Tracking issue: rust-lang/rust#145686 ACP: https://github.com/rust-lang/libs-team/issues/642 This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else Thanks `@folkertdev` for the fixes and tests cc `@rust-lang/libs-api`
2025-09-04Rollup merge of #143725 - kennytm:peekable_next_if_map, r=jhprattStuart Cook-0/+87
core: add Peekable::next_if_map Implementation for rust-lang/rust#143702
2025-09-03Rollup merge of #145279 - clarfonthey:const-convert-initial, r=tgross35Stuart Cook-2/+1
Constify conversion traits (part 1) This is the first part of rust-lang/rust#144289 being split into smaller pieces. It adds/moves constness of several traits under the `const_convert` feature: * `From` * `Into` * `TryFrom` * `TryInto` * `FromStr` * `AsRef` * `AsMut` * `Borrow` * `BorrowMut` * `Deref` * `DerefMut` There are a few methods that are intrinsically tied to these traits which I've included in the feature. Particularly, those which are wrappers over `AsRef`: * `ByteStr::new` (unstable under `bstr` feature) * `OsStr::new` * `Path::new` Those which directly use `Into`: * `Result::into_ok` * `Result::into_err` And those which use `Deref` and `DerefMut`: * `Pin::as_ref` * `Pin::as_mut` * `Pin::as_deref_mut` * `Option::as_deref` * `Option::as_deref_mut` * `Result::as_deref` * `Result::as_deref_mut` (note: the `Option` and `Result` methods were suggested by ``@npmccallum`` initially as rust-lang/rust#146101) The parts which are missing from this PR are: * Anything that involves heap-allocated types * Making any method const than the ones listed above * Anything that could rely on the above, *or* could rely on system-specific code for `OsStr` or `Path` (note: this mostly makes these methods useless since `str` doesn't implement `AsRef<OsStr>` yet, but it's better to track the method for now and add impls later, IMHO) r? ``@tgross35`` (who mostly already reviewed this)
2025-09-03Unify and deduplicate algebraic float testsRomain Perier-83/+44
2025-09-03Add `funnel_sh{l,r}` functions and intrinsicssayantn-0/+37
- Add a fallback implementation for the intrinsics - Add LLVM backend support for funnel shifts Co-Authored-By: folkertdev <folkert@folkertdev.nl>
2025-09-01Constify conversion traitsltdk-2/+1
2025-09-01Rollup merge of #145468 - karolzwolak:float-tests-dedup, r=tgross35Stuart Cook-243/+105
dedup recip, powi, to_degrees, and to_radians float tests Deduplicates recip, powi, to_degrees, and to_radians float tests. I had to fiddle and slightly increase the tolerances for a few comparisons, so maybe not all of the tests are worth deduplicating. Part of rust-lang/rust#141726. Best reviewed commit-by-commit. r? `@tgross35`
2025-08-31dedup to_radians float testKarol Zwolak-68/+26
2025-08-31dedup to_degrees float testKarol Zwolak-59/+29
2025-08-31dedup powi float testKarol Zwolak-66/+28
2025-08-31Rollup merge of #145174 - 197g:issue-145148-select-unpredictable-drop, r=joboetMatthias Krüger-0/+36
Ensure consistent drop for panicking drop in hint::select_unpredictable There are a few alternatives to the implementation. The principal problem is that the selected value must be owned (in the sense of having a drop flag of sorts) when the unselected value is dropped, such that panic unwind goes through the drop of both. This ownership must then be passed on in return when the drop went smoothly. The basic way of achieving this is by extracting the selected value first, at the cost of relying on the optimizer a little more for detecting the copy as constructing the return value despite having a place in the body. Unfortunately, that causes LLVM to discard the !unpredictable annotation (for some reason that is beyond my comprehension of LLVM). <details> <summary>Extract from the build log showing an unannotated select being used</summary> ``` 2025-08-09T16:51:06.8790764Z 39: define noundef i64 `@test_int2(i1` noundef zeroext %p, i64 noundef %a, i64 noundef %b) unnamed_addr #0 personality ptr `@rust_eh_personality` { 2025-08-09T16:51:06.8791368Z check:47'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found 2025-08-09T16:51:06.8791700Z 40: start: 2025-08-09T16:51:06.8791858Z check:47'0 ~~~~~~~ 2025-08-09T16:51:06.8792043Z 41: %ret.i = select i1 %p, i64 %a, i64 %b 2025-08-09T16:51:06.8792293Z check:47'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2025-08-09T16:51:06.8792686Z check:47'1 ? possible intended match 2025-08-09T16:51:06.8792946Z 42: ret i64 %ret.i 2025-08-09T16:51:06.8793127Z check:47'0 ~~~~~~~~~~~~~~~~ ``` </details> So instead, this PR includes a guard to drop the selected `MaybeUnit<T>` which is active only for the section where the unselected value is dropped. That leaves the code for selecting the result intact leading to the expected ir. That complicates the 'unselection' process a little bit since we require _both_ values as a result of that intrinsic call. Since the arguments alias, this portion as well as the drop guard uses raw pointers. Closes: rust-lang/rust#145148 Prior: rust-lang/rust#139977
2025-08-30dedup recip float testKarol Zwolak-50/+22
I left the additional asserts on {f16, f128}::MAX.recip() in a new test_max_recip tests.
2025-08-30Clarify panic-drop test for select_unpredictableAurelia Molzer-4/+3
2025-08-30Rollup merge of #145969 - actuallylost:duration-from-nanos-128, r=tgross35Stuart Cook-0/+20
Add Duration::from_nanos_u128 Feature Gate: `#![feature(duration_from_nanos_u128)]` ACP: https://github.com/rust-lang/libs-team/issues/567 Tracking issue: https://github.com/rust-lang/rust/issues/139201 Recreated from https://github.com/rust-lang/rust/pull/139243
2025-08-29Rollup merge of #145467 - Kivooeo:stabilize-strict_provenance_atomic_ptr, ↵Trevor Gross-1/+0
r=scottmcm Stabilize `strict_provenance_atomic_ptr` feature This closes [tracking issue](https://github.com/rust-lang/rust/issues/99108) and stabilises `AtomicPtr::{fetch_ptr_add, fetch_ptr_sub, fetch_byte_add, fetch_byte_sub, fetch_or, fetch_and, fetch_xor}` --- EDIT: FCP completed at https://github.com/rust-lang/rust/issues/99108#issuecomment-3168260347
2025-08-30Add `Duration::from_nanos_u128`actuallylost-0/+20
Tracking issue: RUST-139201 Co-authored-by: omanirudh <omanirudh2014@gmail.com>
2025-08-29Rollup merge of #144275 - Qelxiros:saturating-arithmetic, r=tgross35Stuart Cook-0/+36
implement Sum and Product for Saturating(u*) ACP: rust-lang/libs-team#604 `@rustbot` label +needs-fcp
2025-08-28implement Sum and Product for Saturating(u*)Jeremy Smart-0/+36
2025-08-27Rollup merge of #144274 - Qelxiros:option-reduce, r=tgross35Matthias Krüger-0/+1
add Option::reduce Tracking issue: rust-lang/rust#144273
2025-08-27Rollup merge of #145335 - clarfonthey:wtf8-core-alloc, r=Mark-SimulacrumMatthias Krüger-0/+2
Move WTF-8 code from std into core and alloc This is basically a small portion of rust-lang/rust#129411 with a smaller scope. It *does not*\* affect any public APIs; this code is still internal to the standard library. It just moves the WTF-8 code into `core` and `alloc` so it can be accessed by `no_std` crates like `backtrace`. > \* The only public API this affects is by adding a `Debug` implementation to `std::os::windows::ffi::EncodeWide`, which was not present before. This is due to the fact that `core` requires `Debug` implementations for all types, but `std` does not (yet) require this. Even though this was ultimately changed to be a wrapper over the original type, not a re-export, I decided to keep the `Debug` implementation so it remains useful. Like we do with ordinary strings, the tests are still located entirely in `alloc`, rather than splitting them into `core` and `alloc`. ---- Reviewer note: for ease of review, this is split into three commits: 1. Moving the original files into their new "locations" 2. Actually modifying the code to compile. 3. Removing aesthetic changes that were made so that the diff for commit 2 was readable. You can review commits 1 and 3 to verify these claims, but commit 2 contains the majority of the changes you should care about. ---- API changes: `impl Debug for std::os::windows::ffi::EncodeWide`
2025-08-22Rollup merge of #132087 - ijchen:issue-131770-fix, r=dtolnayJacob Pratt-1/+9
Fix overly restrictive lifetime in `core::panic::Location::file` return type Fixes #131770 by relaxing the lifetime to match what's stored in the struct. See that issue for more details and discussion. Since this is a breaking change, I think a crater run is in order. Since this change should only have an effect at compile-time, I think just a check run is sufficient.
2025-08-22benchmarks for exponent fmt of integersPascal S. de Kloe-0/+24
2025-08-21Consolidate panicking functions in `slice/index.rs`Karl Meakin-5/+5
Consolidate all the panicking functions in `slice/index.rs` to use a single `slice_index_fail` function, similar to how it is done in `str/traits.rs`.
2025-08-20Move WTF-8 code from std to core/allocltdk-0/+2
2025-08-20Rollup merge of #145381 - Gnurou:int_lowest_highest_one, r=jhprattJacob Pratt-0/+183
Implement feature `int_lowest_highest_one` for integer and NonZero types Tracking issue: rust-lang/rust#145203 Implement the accepted ACP rust-lang/rust#145203 for methods that find the index of the least significant (lowest) and most significant (highest) set bit in an integer for signed, unsigned, and NonZero types. Also add unit tests for all these types.
2025-08-19Rollup merge of #143730 - pascaldekloe:fmt-radix-trim, r=tgross35许杰友 Jieyou Xu (Joe)-0/+180
fmt of non-decimal radix untangled Have the implementation match its decimal counterpart. * Digit table instead of conversion functions * Correct buffer size per radix * Elimination of dead code for negative * No trait abstraction for integers #### Original Performance ``` fmt::write_10ints_bin 393.03ns/iter +/- 1.41 fmt::write_10ints_hex 316.84ns/iter +/- 1.49 fmt::write_10ints_oct 327.16ns/iter +/- 0.46 ``` #### Patched Performance ``` fmt::write_10ints_bin 392.31ns/iter +/- 3.05 fmt::write_10ints_hex 302.41ns/iter +/- 5.48 fmt::write_10ints_oct 322.01ns/iter +/- 3.82 ``` r? tgross35
2025-08-19Rollup merge of #141744 - GrigorenkoPV:ip_from, r=AmanieuStuart Cook-1/+0
Stabilize `ip_from` Tracking issue: rust-lang/rust#131360 Stabilizes and const-stabilizes the following APIs: ```rust // core::net impl Ipv4Addr { pub const fn from_octets(octets: [u8; 4]) -> Ipv4Addr; } impl Ipv6Addr { pub const fn from_octets(octets: [u8; 16]) -> Ipv6Addr; pub const fn from_segments(segments: [u16; 8]) -> Ipv6Addr; } ``` Closes rust-lang/rust#131360 ```@rustbot``` label +needs-fcp
2025-08-18Implement feature `int_lowest_highest_one` for integer and NonZero typesAlexandre Courbot-0/+183
Implement the accepted ACP for methods that find the index of the least significant (lowest) and most significant (highest) set bit in an integer for signed, unsigned, and NonZero types. Also add unit tests for all these types.
2025-08-17Auto merge of #144081 - RalfJung:const-ptr-fragments, r=oli-obkbors-8/+4
const-eval: full support for pointer fragments This fixes https://github.com/rust-lang/const-eval/issues/72 and makes `swap_nonoverlapping` fully work in const-eval by enhancing per-byte provenance tracking with tracking of *which* of the bytes of the pointer this one is. Later, if we see all the same bytes in the exact same order, we can treat it like a whole pointer again without ever risking a leak of the data bytes (that encode the offset into the allocation). This lifts the limitation that was discussed quite a bit in https://github.com/rust-lang/rust/pull/137280. For a concrete piece of code that used to fail and now works properly consider this example doing a byte-for-byte memcpy in const without using intrinsics: ```rust use std::{mem::{self, MaybeUninit}, ptr}; type Byte = MaybeUninit<u8>; const unsafe fn memcpy(dst: *mut Byte, src: *const Byte, n: usize) { let mut i = 0; while i < n { *dst.add(i) = *src.add(i); i += 1; } } const _MEMCPY: () = unsafe { let ptr = &42; let mut ptr2 = ptr::null::<i32>(); // Copy from ptr to ptr2. memcpy(&mut ptr2 as *mut _ as *mut _, &ptr as *const _ as *const _, mem::size_of::<&i32>()); assert!(*ptr2 == 42); }; ``` What makes this code tricky is that pointers are "opaque blobs" in const-eval, we cannot just let people look at the individual bytes since *we don't know what those bytes look like* -- that depends on the absolute address the pointed-to object will be placed at. The code above "breaks apart" a pointer into individual bytes, and then puts them back together in the same order elsewhere. This PR implements the logic to properly track how those individual bytes relate to the original pointer, and to recognize when they are in the right order again. We still reject constants where the final value contains a not-fully-put-together pointer: I have no idea how one could construct an LLVM global where one byte is defined as "the 3rd byte of a pointer to that other global over there" -- and even if LLVM supports this somehow, we can leave implementing that to a future PR. It seems unlikely to me anyone would even want this, but who knows.^^ This also changes the behavior of Miri, by tracking the order of bytes with provenance and only considering a pointer to have valid provenance if all bytes are in the original order again. This is related to https://github.com/rust-lang/unsafe-code-guidelines/issues/558. It means one cannot implement XOR linked lists with strict provenance any more, which is however only of theoretical interest. Practically I am curious if anyone will show up with any code that Miri now complains about - that would be interesting data. Cc `@rust-lang/opsem`
2025-08-15Rollup merge of #144963 - rossmacarthur-forks:stabilize-core-iter-chain, ↵Jacob Pratt-1/+0
r=jhpratt Stabilize `core::iter::chain` Closes rust-lang/rust#125964
2025-08-15stabilize strict provenance atomic ptrKivooeo-1/+0
2025-08-14Rollup merge of #142741 - a1phyr:fix_unsoundness, r=Mark-SimulacrumGuillaume Gomez-2/+2
Fix unsoundness in some tests These tests were marked uninit bytes as initilized, which is unsound. Use initialized `MaybeUninit` instead.
2025-08-10Remove unnecessary parentheses in `assert!`sEsteban Küber-1/+1