36 Commits

Author SHA1 Message Date
Guillaume Gomez
7e23144dc6 Add test for int_format_into feature 2025-07-03 18:57:16 +02:00
Trevor Gross
52758b7329
Rollup merge of #142668 - hkBst:less-static-mut, r=tgross35
vec_deque/fmt/vec tests: remove static mut

More rust-lang/rust#125035.

r? ```@tgross35```
2025-06-20 02:50:39 -04:00
bors
5b74275f89 Auto merge of #142294 - GuillaumeGomez:specialize-tostring-on-128-integers, r=tgross35
Use a distinct `ToString` implementation for `u128` and `i128`

Part of https://github.com/rust-lang/rust/issues/135543.

Follow-up of rust-lang/rust#136264.

When working on https://github.com/rust-lang/rust/pull/142098, I realized that `i128` and `u128` could also benefit from a distinct `ToString` implementation so here it.

The last commit is just me realizing that I forgot to add the format tests for `usize` and `isize`.

Here is the bench comparison:

| bench name | last nightly | with this PR | diff |
|-|-|-|-|
| bench_i128 | 29.25 ns/iter (+/- 0.66) | 17.52 ns/iter (+/- 0.7) | -40.1% |
| bench_u128 | 34.06 ns/iter (+/- 0.21) | 16.1 ns/iter (+/- 0.6) | -52.7% |

I used this code to test:

```rust
#![feature(test)]

extern crate test;

use test::{Bencher, black_box};

#[inline(always)]
fn convert_to_string<T: ToString>(n: T) -> String {
    n.to_string()
}

macro_rules! decl_benches {
    ($($name:ident: $ty:ident,)+) => {
        $(
	    #[bench]
            fn $name(c: &mut Bencher) {
                c.iter(|| convert_to_string(black_box({ let nb: $ty = 20; nb })));
            }
	)+
    }
}

decl_benches! {
    bench_u128: u128,
    bench_i128: i128,
}
```
2025-06-20 02:55:43 +00:00
Marijn Schouten
456c9da45a vec_deque alloctests: remove static mut 2025-06-19 11:51:47 +00:00
Marijn Schouten
ecdf220dbc vec tests: remove static mut 2025-06-19 11:39:21 +00:00
Marijn Schouten
2c434edf24 remove duplicate crash test 2025-06-18 14:04:02 +00:00
Marijn Schouten
021bcb9b4c fmt tests: remove static mut 2025-06-18 12:29:22 +00:00
Marijn Schouten
5bd918fcd8 vec_deque tests: remove static mut 2025-06-18 11:51:40 +00:00
Guillaume Gomez
9b09948897 Extend num tests on usize and isize as well 2025-06-16 11:54:15 +02:00
Jubilee
b38ee5e689
Rollup merge of #142046 - Qelxiros:122742-vec_peek_mut, r=cuviper
add Vec::peek_mut

Tracking issue: rust-lang/rust#122742
2025-06-13 20:59:16 -07:00
Matthias Krüger
315b76fcd3
Rollup merge of #138016 - nwoods-cimpress:slice_chunkby_clone, r=dtolnay
Added `Clone` implementation for `ChunkBy`

Added `Clone` implementation for `ChunkBy`

Closes rust-lang/rust#137969.
2025-06-12 20:03:34 +02:00
Jeremy Smart
9d19cbe29b
update docs, test 2025-06-11 22:57:57 -04:00
Ralf Jung
3164ca8bb4 stabilize nonnull_provenance 2025-06-09 12:36:24 +02:00
Jeremy Smart
cc80429021
fix tests 2025-06-06 19:22:15 -04:00
Jeremy Smart
188c40126d
add Vec::peek_mut 2025-06-04 18:15:12 -04:00
Josh Stone
c87b072952 Remove more library bootstrap 2025-06-02 14:46:19 -07:00
Sidney Cammeresi
1ae96fcd79 Update tests with Range parameter to BTreeMap::extract_if etc. 2025-05-27 08:31:56 -07:00
Pietro Albini
2ce08ca5d6
update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
Vladimir Krivopalov
cdf4143eb8 Implement VecDeque::truncate_front()
Tracking issue: #140667

Signed-off-by: Vladimir Krivopalov <vladimir.krivopalov@gmail.com>
2025-05-05 11:13:26 -04:00
bendn
c8c074288a
Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etc 2025-04-24 13:14:36 +07:00
Tamir Duberstein
9058bab9a9
Move <CStr as Debug> test to coretests 2025-04-18 10:31:55 -04:00
lincot
ff248de852
Add missing black_box in String benchmarks 2025-04-09 13:06:10 +03:00
bors
25a615bf82 Auto merge of #138951 - jwnrt:alloc-raw-vec-strict-prov, r=Noratrieb
Replace last `usize` -> `ptr` transmute in `alloc` with strict provenance API

This replaces the `usize -> ptr` transmute in `RawVecInner::new_in` with a strict provenance API (`NonNull::without_provenance`).

The API is changed to take an `Alignment` which encodes the non-null constraint needed for `Unique` and allows us to do the construction safely.

Two internal-only APIs were added to let us avoid UB-checking in this hot code: `Layout::alignment` to get the `Alignment` type directly rather than as a `usize`, and `Unique::from_non_null` to create `Unique` in const context without a transmute.
2025-04-06 23:07:48 +00:00
Stuart Cook
338b8787b9
Rollup merge of #138546 - GuillaumeGomez:integer-to-string-tests, r=Amanieu
Add integer to string formatting tests

As discussed in https://github.com/rust-lang/rust/pull/136264, there doesn't seem to have tests to ensure that int to string conversion is performed correctly, only sporadic tests here and there. Now we have some basic tests. :)

r? `````@Mark-Simulacrum`````
2025-04-05 13:18:14 +11:00
Frank King
5004e10ceb Add a test for Weak created from UniqueArc::downgrade 2025-03-29 12:13:38 +08:00
James Wainwright
aadfd810f6 Swap usize -> ptr transmute for strict_pov API
Removes some unsafety and reduces the number of `usize` -> `ptr`
transmutes which might be helpful for CHERI-like targets in the future.
2025-03-26 21:41:11 +00:00
James Wainwright
78e9621390 Pass Alignment for RawVecInner::new_in
Encodes the safety constraint that `Unique`'s pointer must be non-zero
into the API.
2025-03-26 21:41:11 +00:00
Guillaume Gomez
25900c2768 Tweak integer to string conversion test a bit to be future-proof 2025-03-23 22:34:05 +01:00
Frank King
5016467a23 Implement UniqueArc 2025-03-22 15:14:49 +08:00
Guillaume Gomez
bacd57a583 Add integer to string formatting tests 2025-03-16 14:45:19 +01:00
Nathaniel Woods
8bbc080cc7 Added Clone implementation for ChunkBy 2025-03-10 11:12:26 -04:00
bjorn3
22d0440993 Add comments 2025-03-07 19:11:13 +00:00
bjorn3
ae5687e4b0 Fully test the alloc crate through alloctests
For the tests that make use of internal implementation details, we
include the module to test using #[path] in alloctests now.
2025-03-07 19:11:13 +00:00
bjorn3
701bedc323 Move last remaining Rc test to alloctests 2025-03-07 19:11:13 +00:00
bjorn3
be1e0b786d Move most Rc tests to alloctests 2025-03-07 19:11:13 +00:00
bjorn3
fb04372dc5 Move all alloc integration tests to a new alloctests crate 2025-03-07 19:11:11 +00:00