121 Commits

Author SHA1 Message Date
Jonathan Brouwer 7162558809 Rollup merge of #154248 - lms0806:issue_154034, r=TaKO8Ki
resolve :  mark repr_simd as internal

I changed ```repr_simd``` to ```internal``` and changed the position to ```feature-group-start: internal feature gates```.

close rust-lang/rust#154034
2026-04-20 13:52:07 +02:00
Pavel Grigorenko 6c46776304 Debug for vec::ExtractIf 2026-03-30 13:01:46 +03:00
Jonathan Brouwer 8287d4deb2 Rollup merge of #153632 - Lars-Schumann:issue-153158, r=fee1-dead
Fix Vec::const_make_global for 0 capacity and ZST's

fixes https://github.com/rust-lang/rust/issues/153158
2026-03-29 08:59:35 +02:00
lms0806 ac5e448d23 resolve : issue 154034
resolve :  mark repr_simd as internal

resolve : move repr_simd

resolve : move repr_simd
under linkage

resolve : move repr_simd
under pattern_types

resolve :  mark repr_simd as internal

resolve : move repr_simd

resolve : move repr_simd
under linkage

resolve : move repr_simd
under pattern_types
2026-03-24 15:56:55 +09:00
Stuart Cook 04e7f2f72e Rollup merge of #153677 - ConradIrwin:sanitary-string-panics, r=scottmcm
Remove string content from panics

String content can be useful for debugging panics, particularly when you are working on a small codebase where you can infer more about the path taken through your program based on the content of the string.

In production deployments that upload crashes for centralized debugging, string content poses a risk to user privacy. The string can accidentally contain information that the user is not expecting to share with the development team.

On balance it seems like the risks outweigh the benefits. It is easy to add a `dbg!()` statement to gather more information in development; but comparatively tricky to ensure panics are sanitized by every rust app that monitors their production deployments.

Ref https://internals.rust-lang.org/t/stop-including-string-content-in-index-panics/24067

r? @scottmcm
2026-03-18 18:37:35 +11:00
Stuart Cook c5faf3a23a Rollup merge of #152258 - asder8215:vecdeque_splice_151758, r=joboet
fixed VecDeque::splice() not filling the buffer correctly when resizing the buffer on start = end range

This PR fixes rust-lang/rust#151758. The issue came from `Splice::move_tail`, which as joboet pointed out:
> The issue is in move_tail, which resizes the buffer, but fails to account for the resulting hole.

The problem with reserving more space through `VecDeque`'s `buf.reserve()` is that it doesn't update `VecDeque`'s `head`, which means that this code in `move_tail`:
```rust
deque.wrap_copy(
    deque.to_physical_idx(tail_start),
    deque.to_physical_idx(new_tail_start),
    self.tail_len,
);
```
could move over the section of data that `tail_start..tail_start + self.tail_len` of the buffer is supposed to be held at to the incorrect destination since all `.to_physical_idx()` is doing is a wrapping add on the `VecDeque`'s head with the passed in `idx` value.

To avoid this I decided to use `VecDeque::reserve` to both allocate more space into the `VecDeque` if necessary and update head appropriately. However, `VecDeque::reserve` internally relies on the `VecDeque`'s `len` field. Earlier in `VecDeque::splice`, it modifies the `VecDeque`'s `len` constructing the drain via `Drain::new` (as it does a `mem::replace` on `deque.len` with the start bound of the passed in `range`). The `VecDeque`'s `len` can also be potentially modified in the earlier `Splice::fill()` call if it does any replacement towards elements within the passed in `range` value for `VecDeque::splice()`. I needed to temporarily restore the `VecDeque`'s `len` to its actual len, so that `VecDeque::reserve` can work properly. Afterward, you can bring back the `VecDeque`'s `len` to what its value was before and fill the gap appropriately with the rest of the `replace_with` content.

r? @joboet
2026-03-13 14:14:11 +11:00
Ralf Jung bc4dfa5e33 miri-test-libstd: use --tests and update some comments 2026-03-11 15:17:23 +01:00
Conrad Irwin 05ac9d4da2 Remove string content from panics
String content can be useful for debugging panics, particularly when you
are working on a small codebase where you can infer more about the path
taken through your program based on the content of the string.

In production deployments that upload crashes for centralized debugging,
string content poses a risk to user privacy. The string can accidentally
contain information that the user is not expecting to share with the
development team.

On balance it seems like the risks outweigh the benefits. It is easy to
add a `dbg!()` statement to gather more information in development; but
comparatively tricky to ensure panics are sanitized by every rust app
that monitors their production deployments.

Ref https://internals.rust-lang.org/t/stop-including-string-content-in-index-panics/24067
2026-03-10 19:35:47 -06:00
Jonathan Brouwer 4c6755ca61 Rollup merge of #153143 - ferrocene:jh/bootstrap-test-targets, r=Mark-Simulacrum,kobzol
Allow `./x test` to run tests without doc tests and without benchmarks

# Problem

For Ferrocene we would like to run only the `coretests` and `alloctests` test suites when measuring code coverage. Running `corebenches` and `allocbenches` would alter the numbers, which is not compliant with the certification.

This is currently not possible in bootstrap. By default `./x test` runs unit, integration and doc tests. `./x test --doc` only runs doc tests. So far, so good.

The problem is that while `./x test --no-doc` stops bootstrap from executing doc tests, it surprisingly starts executing benchmarks (next to examples and bins as well). It basically behaves like `cargo test --all-targets`.

# Solution

This PR renames the existing `--no-doc` flag to `--all-targets` and keeps the same behaviour as before. Unfortunately it is not possible to internally switch from `cargo --bins --examples --tests --benches` to `cargo --all-targets` because it will fail e.g. `./x test library/alloc --all-targets` with an error like "use of unstable library feature `test`".

Additionally, this PR add a `./x test --tests` flag (equivalent to `cargo test --tests`) that only executes unit and integration tests.

Both changes we are doing in https://github.com/ferrocene/ferrocene anyways, but believe that they may be useful for other people as well and therefore would like to contribute them.

Note that this PR does _not_ change the behaviour of either `./x test` or `./x test --doc`.

## Note on `test = true`

While this change enables bootstrap to run tests without doc tests and without benchmarks, executing `./x test library/core library/alloc --tests` will still build and execute `corebenches` and `allocbenches`.

What?! 😱 Why all of this effort to enable it then?

Good question! The reason they are still executed is, that they are marked with `test = true` in their respective `Cargo.toml` ([corebenches](https://github.com/rust-lang/rust/blob/3f9853562c73af38a5e6af8b0da1b2734a327e19/library/coretests/Cargo.toml#L24), [allocbenches](https://github.com/rust-lang/rust/blob/3f9853562c73af38a5e6af8b0da1b2734a327e19/library/alloctests/Cargo.toml#L32)).

@bjorn3 mentioned that it is important for upstream that those benchmarks are executed by default, even if no `./x --all-targets` is passed. This is perfectly possible with this PR. Benchmarks marked with `test = true` will be executed when calling either of `./x test`, `./x test --tests` or `./x --all-targets`. Therefore this PR does not include a commit to change that. We will just do this change in https://github.com/ferrocene/ferrocene.

## Open questions

### Error message

I added one commit that adds an error message if a user passes `--no-doc` and points them to `--all-targets` and `--tests`. I think it might be nice to have, but if you think it is not necessary, I can remove it.

# How to test this change

You can see the change in action by running `./x test library/alloc --tests` and `./x test library/alloc --all-targets`. The first will execute `alloctests` and `allocbenches` (which is marked with `test = true`), while the second will additionally run `benches/vec_deque_append.rs` (which is _not_ marked with `test = true`).
2026-03-10 22:44:03 +01:00
Urhengulas 2a2cafa722 Reflect removal of --no-doc in documentation
- `./x run generate-completions`
- Search and replace `--no-doc` with `--all-targets`
  This is to keep the behaviour the same.
- Document `./x test --tests` in `rustc-dev-guide`
- Add change info
2026-03-10 12:20:17 +01:00
Lars Schumann 98be8f7659 Fix Vec::const_make_global for 0 capacity and ZST's 2026-03-09 23:26:14 +00:00
Josh Stone eb093cfd5d Reformat with the new stage0 2026-03-07 10:42:02 -08:00
mu001999 7ffaa41662 Remove unused features in library tests 2026-03-04 08:06:44 +08:00
Mahdi Ali-Raihan d0a33abd4d fixed VecDeque::splice() not filling the buffer correctly when resizing the buffer on start = end range 2026-02-28 22:28:35 -05:00
Jacob Pratt 5c47d0bef9 Rollup merge of #152418 - asder8215:btreemap_merge_optimized, r=Mark-Simulacrum
`BTreeMap::merge` optimized

This is an optimized version of https://github.com/rust-lang/rust/pull/151981. See [ACP](https://github.com/rust-lang/libs-team/issues/739#issuecomment-3873487320) for more information on `BTreeMap::merge` does.

CC @programmerjake. Let me know what you think of how I'm using `CursorMut` and `IntoIter` here and whether the unsafe code here looks good. I decided to use `ptr::read()` and `ptr::write()` to grab the value from `CursorMut` as `V` than `&mut V`, use it within the `conflict` function, and overwrite the content of conflicting key afterward.

I know this needs some polishing, especially with refactoring some redundant looking code in a nicer way, some of which could probably just be public API methods for `CursorMut`. It does pass all the tests that I currently have for `BTreeMap::merge` (inspired from `BTreeMap::append`) though, so that's good.
2026-02-24 22:51:38 -05:00
Mahdi Ali-Raihan 1b50859d36 feat: BTreeMap::merge implemented with into iterators only (similar to BTreeMap::append) 2026-02-24 02:38:15 -05:00
Jonathan Brouwer 9f0a410096 Revert "Stabilize str_as_str" 2026-02-22 10:10:42 +01:00
Matthias Krüger a919df8b1b Rollup merge of #151603 - GrigorenkoPV:stabilize/str_as_str, r=jhpratt
Stabilize `str_as_str`

- Tracking issue: rust-lang/rust#130366
- Needs FCP
- `ByteStr` methods remain gated behind `bstr` feature gate (rust-lang/rust#134915)

Closes rust-lang/rust#130366
2026-02-21 13:03:28 +01:00
Jonathan Brouwer 6d625cc074 Rollup merge of #145024 - Kmeakin:km/optimize-slice-index/v3, r=Mark-Simulacrum
Optimize indexing slices and strs with inclusive ranges

Instead of separately checking for `end == usize::MAX` and `end + 1 > slice.len()`, we can check for `end >= slice.len()`. Also consolidate all the str indexing related panic functions into a single function which reports the correct error depending on the arguments, as the slice indexing code already does.

The downside of all this is that the panic message is slightly less specific when trying to index with `[..=usize::MAX]`: instead of saying "attempted to index str up to maximum usize" it just says "end byte index {end} out of bounds". But this is a rare enough case that I think it is acceptable
2026-02-14 22:11:52 +01:00
mu001999 73c42c1800 Remove or allow unused features in library doc and tests 2026-02-13 09:27:16 +08:00
Lukas Bergdoll 2f3b952349 Stabilize assert_matches 2026-02-11 14:13:44 +01:00
Karl Meakin 94ff542ff5 Make panic message less confusing
The panic message when slicing a string with a negative length range (eg
`"abcdef"[4..3]`) is confusing: it gives the condition that failed to hold,
whilst all the other panic messages give the condition that did hold.

Before:
begin <= end (4 <= 3) when slicing `abcdef`

After:
begin > end (4 > 3) when slicing `abcdef`
2026-02-10 23:19:01 +00:00
Karl Meakin 262cd76333 Optimize SliceIndex<str> for RangeInclusive
Replace `self.end() == usize::MAX` and `self.end() + 1 > slice.len()`
with `self.end() >= slice.len()`. Same reasoning as previous commit.

Also consolidate the str panicking functions into function.
2026-02-10 23:19:01 +00:00
Stuart Cook a57663ea65 Rollup merge of #151756 - Voultapher:fix-box-retag-in-sort, r=Mark-Simulacrum
Avoid miri error in `slice::sort` under Stacked Borrows

See comment in code.

Fixes: https://github.com/rust-lang/rust/issues/151728
2026-02-02 10:28:29 +11:00
Max Heller bae7a199f1 Address review comments and fix tests 2026-01-30 09:55:53 -05:00
Max Heller 9928723bff Implement BinaryHeap::pop_if() 2026-01-29 10:20:34 -05:00
Lukas Bergdoll ce03e7b33a Avoid miri error in slice::sort under Stacked Borrows
See comment in code.

Fixes: https://github.com/rust-lang/rust/pull/131065
2026-01-28 14:55:29 +01:00
Jeremy Smart b0d96492d0 fix undefined behavior in VecDeque::splice 2026-01-27 19:30:37 -05:00
Stuart Cook 956ebbde20 Rollup merge of #151383 - cyrgani:no-internal-deprecation, r=scottmcm
remove `#[deprecated]` from unstable & internal `SipHasher13` and `24` types

These types are unstable and `doc(hidden)` (under the internal feature `hashmap_internals`). Deprecating them only adds noise (`#[allow(deprecated)]`) to all places where they are used, so this PR removes the deprecation attributes from them.

It also includes a few other small cleanups in separate commits, including one I overlooked in rust-lang/rust#151228.
2026-01-27 12:50:52 +11:00
Pavel Grigorenko 06398554bf Stabilize str_as_str 2026-01-24 21:32:31 +03:00
Lukas Bergdoll 58be5d6620 Move assert_matches to planned stable path 2026-01-21 23:17:24 +01:00
cyrgani 0adf24ac20 remove #[deprecated] from unstable & internal SipHasher13&24 2026-01-19 21:24:36 +00:00
Jacob Pratt 99b29620ca Rollup merge of #148769 - stabilize/alloc_layout_extra, r=scottmcm
Stabilize `alloc_layout_extra`

Tracking issue: rust-lang/rust#55724
FCP completed in https://github.com/rust-lang/rust/issues/55724#issuecomment-3447699364
Closes rust-lang/rust#55724

----

As per https://github.com/rust-lang/rust/issues/55724#issuecomment-3403555985,
- `repeat_packed` and `extend_packed` are unchanged
- `repeat` now excludes trailing padding on the last element from the total array size
- `dangling` renamed to `dangling_ptr`
- `padding_needed_for` not stabilized, changed to accept `Alignment` instead of `usize` and moved to the `ptr_aligment_type` feature flag (tracking issue: rust-lang/rust#102070)
2026-01-18 03:16:44 -05:00
Lukas Bergdoll 506762f3ff Explicitly export core and std macros
Currently all core and std macros are automatically added to the prelude
via #[macro_use]. However a situation arose where we want to add a new macro
`assert_matches` but don't want to pull it into the standard prelude for
compatibility reasons. By explicitly exporting the macros found in the core and
std crates we get to decide on a per macro basis and can later add them via
the rust_20xx preludes.
2026-01-13 08:47:48 +01:00
Pavel Grigorenko e212560317 Stabilize alloc_layout_extra 2026-01-11 16:39:18 +03:00
Matthias Krüger 57da460fc7 Rollup merge of #150781 - pr/cleanup-rand-usages, r=Mark-Simulacrum
Use `rand` crate more idiomatically

Small cleanup, found while working on something else.
We were using `rand` un-idiomatically in a couple of places, and it was bugging me...
2026-01-11 09:56:40 +01:00
Zalathar 50813939e4 Don't run the longer partial-sort tests under Miri 2026-01-11 12:04:46 +11:00
Urgau 65c0847f2d Rollup merge of #149318 - slice_partial_sort_unstable, r=tgross35
Implement partial_sort_unstable for slice

This refers to https://github.com/rust-lang/rust/issues/149046.
2026-01-09 23:28:15 +01:00
tison 45e0fbf7c5 Implement partial_sort_unstable for slice
Signed-off-by: tison <wander4096@gmail.com>
Co-Authored-By: Orson Peters <orsonpeters@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
2026-01-09 09:58:08 +08:00
Yotam Ofek f82dd820a5 Use rand crate more idiomatically 2026-01-07 22:31:33 +02:00
bors 74fd7516da Auto merge of #147893 - fee1-dead-contrib:constheapheapheap, r=oli-obk
`Vec::push` in consts MVP

Example:

```rust
const X: &'static [u32] = {
    let mut v = Vec::with_capacity(6);
    let mut x = 1;
    while x < 42 {
        v.push(x);
        x *= 2;
    }
    assert!(v.len() == 6);
    v.const_make_global()
};

assert_eq!([1, 2, 4, 8, 16, 32], X);
```

Oh this is fun...

* We split out the implementation of `Global` such that it calls `intrinsics::const_allocate` and `intrinsics::const_deallocate` during compile time. This is achieved using `const_eval_select`
* This allows us to `impl const Allocator for Global`
* We then constify everything necessary for `Vec::with_capacity` and `Vec::push`.
* Added `Vec::const_make_global` to leak and intern the final value via `intrinsics::const_make_global`. If we see any pointer in the final value of a `const` that did not call `const_make_global`, we error as implemented in rust-lang/rust#143595.

r? `@rust-lang/wg-const-eval`

To-do for me:
* [x] Assess the rustdoc impact of additional bounds in the method
* [x] ~~Increase test coverage~~ I think this is enough for an unstable feature.
2026-01-06 11:39:17 +00:00
Antoni Spaanderman 7e425b8985 Add specialization for deque1.prepend(deque2.drain(range))
This is used when moving elements between `VecDeque`s
This pattern is also used in examples of `VecDeque::prepend`. (see its docs)
2026-01-02 16:05:42 +01:00
Deadbeef 47864e80cb address review comments; fix CI 2026-01-01 19:17:11 -05:00
Deadbeef 3982d3e706 Vec::push in consts MVP 2026-01-01 19:17:11 -05:00
bors 0e89999425 Auto merge of #147247 - Qelxiros:vecdeque_splice, r=Mark-Simulacrum
add VecDeque::splice

Tracking issue: rust-lang/rust#146975
2025-12-30 19:18:37 +00:00
Jonathan Brouwer 596e1e3f88 Rollup merge of #150344 - hkBst:cleanup-linked-list, r=jhpratt
Cleanup linked list

 - Replaces some checked_sub().unwrap_or(0) with saturating_sub().
 - Replaces NonNull::from(Box::leak(node)) with Box::into_non_null(node)
2025-12-30 10:42:28 +01:00
Marijn Schouten eea3d794ff LinkedList: use Box::into_non_null_with_allocator 2025-12-29 19:08:34 +00:00
Jeremy Smart 0763954226 add VecDeque::splice 2025-12-29 13:25:56 -05:00
Jonathan Brouwer 3c7ffa5dd1 Rollup merge of #149447 - theemathas:string-replace_range, r=Mark-Simulacrum
Rewrite `String::replace_range`

This simplifies the code, provides better panic messages, and avoids an integer overflow.
2025-12-28 18:16:09 +01:00
Chris Denton 735c45eda4 Rollup merge of #149272 - DrAsu33:fix-vec-iter-zst-alignment-148682, r=Mark-Simulacrum
Fix vec iter zst alignment

Closes rust-lang/rust#148682
2025-12-14 09:18:28 +00:00