Commit Graph

48 Commits

Author SHA1 Message Date
Matthias Krüger
f104ae4252 Rollup merge of #145113 - petrochenkov:lessfinalize, r=lcnr
resolve: Do not finalize shadowed bindings

I.e. do not mark them as used, or non-speculatively loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like https://github.com/rust-lang/rust/pull/144793#issuecomment-3168108005.
2025-09-26 18:11:08 +02:00
Vadim Petrochenkov
f89660e4aa resolve: Do not finalize shadowed bindings
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like https://github.com/rust-lang/rust/pull/144793#issuecomment-3168108005.
2025-09-25 20:36:14 +03:00
BenjaminBrienen
56734495e2 feature: Implement vec_try_remove
Vec::try_remove is a non-panicking version of Vec::remove
2025-09-24 15:29:09 +02:00
Sidney Cammeresi
934ee043fe Plumb Allocator generic into std::vec::PeekMut 2025-09-18 17:29:23 -07:00
Sidney Cammeresi
ce859d7713 Switch std::vec::PeekMut::pop from self to this parameter.
Since PeekMut implements Deref, it shouldn't have any methods of its
own.

See also: `std::collections::binary_heap::PeekMut::pop`
2025-09-14 08:16:05 -07:00
Jacob Pratt
5b37a1e4ae Rollup merge of #145471 - rs-sac:extr, r=the8472
Stabilize BTree{Map,Set}::extract_if

Tracking issue: rust-lang/rust#70530
FCP completed: https://github.com/rust-lang/rust/issues/70530#issuecomment-3191454465
Closes: rust-lang/rust#70530
2025-09-13 03:26:02 -04:00
Stuart Cook
f4b946a147 Rollup merge of #145279 - clarfonthey:const-convert-initial, r=tgross35
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-03 23:08:06 +10:00
ltdk
1c64d3e6d1 Constify conversion traits 2025-09-01 21:38:26 -04:00
Trevor Gross
751a9ad2e2 Rollup merge of #145756 - okaneco:stabilize_char_boundary, r=scottmcm
str: Stabilize `round_char_boundary` feature

Closes https://github.com/rust-lang/rust/issues/93743
FCP completed https://github.com/rust-lang/rust/issues/93743#issuecomment-3168382171
2025-08-29 19:33:03 -05:00
Sidney Cammeresi
f8a7f82bda Stabilize BTree{Map,Set}::extract_if 2025-08-27 11:34:31 -07:00
okaneco
e42c1b1296 Stabilize round_char_boundary feature 2025-08-22 13:42:38 -04:00
ltdk
2914291e09 Move WTF-8 code from std to core/alloc 2025-08-20 20:31:33 -04:00
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