Commit Graph

3601 Commits

Author SHA1 Message Date
Jynn Nelson 505d07da28 core and alloc doctests support doctest merging 2026-03-10 11:56:29 +01:00
Josh Stone 78157ddde9 Replace version placeholders with 1.95.0
(cherry picked from commit bad24ccbec)
2026-03-07 10:42:01 -08:00
Jonathan Brouwer 082d0cacd7 Rollup merge of #153399 - bend-n:constify-into-raw-parts, r=Amanieu
constify `Vec::{into, from}_raw_parts{_in|_alloc}`

due to Vec::drop not being const this is kinda necessary to make use of `const_heap`.
2026-03-05 19:41:57 +01:00
bendn 1f1a0bcbb0 constify Vec::{into, from}_raw_parts{_in|_alloc} 2026-03-05 16:01:40 +07:00
Jonathan Brouwer ed9d77216f Rollup merge of #153204 - xtqqczze:must-use-map, r=Amanieu,joboet
Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors

- `new_in`
- `with_capacity_and_hasher`
- `with_capacity_and_hasher_in`
- `with_hasher`
- `with_hasher_in`

See also: https://github.com/rust-lang/rust/issues/89692
2026-03-04 19:30:37 +01:00
Jonathan Brouwer 671dc27f69 Rollup merge of #153273 - DanielEScherzer:patch-2, r=joboet
vec/mod.rs: add missing period in "ie." in docs

"i.e." is short for the Latin "id est" and thus both letters should be followed by periods.
2026-03-02 20:10:36 +01:00
Daniel Scherzer f538526724 vec/mod.rs: add missing period in "ie." in docs
"i.e." is short for the Latin "id est" and thus both letters should be followed
by periods.
2026-03-01 21:47:52 -08:00
Scott McMurray 2c6ec51564 Update __rust_[rd]ealloc to take NonNull<u8> instead of *mut u8
Passing null to it is [already UB](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=8dcd25a549c11de72adc94a668277779) anyway.
2026-02-28 23:49:31 -08:00
xtqqczze dda4f84c56 Add #[must_use] attribute to HashMap and HashSet constructors 2026-02-28 01:22:45 +00:00
bors 6a979b3e32 Auto merge of #153108 - alexcrichton:revert, r=joboet
Revert "Simplify internals of `{Rc,Arc}::default`"

This reverts rust-lang/rust#152591 following a [perf run being done](https://github.com/rust-lang/rust/pull/152591#issuecomment-3960081137). I'm not really positioned at this time to dive in further and understand the performance regressions, so I'll back away from `Rc`/`Arc` and leave them as-is.
2026-02-26 19:51:40 +00:00
Alex Crichton 57d20c1d14 Revert "Simplify internals of {Rc,Arc}::default"
This reverts commit ce4c17f615.
2026-02-25 13:09:14 -08:00
mu001999 ff0f239bb1 Remove redundant self usages 2026-02-25 22:51:53 +08: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 cbdcfca403 Swapped key comparisons to match lower_bound_mut, added FIXME comments on bulk inserting other_keys into self map, and inlined with_next() insertion on conflicts from Cursor* 2026-02-24 02:42:05 -05:00
Mahdi Ali-Raihan 24efac1063 Optimized BTreeMap::merge using CursorMut 2026-02-24 02:40:44 -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
Stuart Cook 51b54598a2 Rollup merge of #152366 - BitSyndicate1:vec-fallible-shrink, r=Mark-Simulacrum
Add try_shrink_to and try_shrink_to_fit to Vec

Adds the functions `try_shrink_to` and `try_shrink_to_fit` to Vec to allow shrinking
in environments without global OOM handling.

The implementation differs from the tracking issue as the fallible methods return
a `TryReserveError` instead of an `AllocError` as `AllocError` is unstable and does
not contain layout information.

Tracking:

- rust-lang/rust#152350
2026-02-23 13:32:00 +11:00
BitSyndicate1 1f076d2f93 Add try_shrink_to and try_shrink_to_fit to Vec
* Add try_shrink_to and try_shrink_to_fit to Vec

Both functions are required to support shrinking a vector in
environments without global OOM handling.
* Format the try_shrink functions
* Remove excess "```" from doc
* Remove `cfg(not(no_global_oom_handling))` from rawvecinner::shrink
* Fix import cmp even if no_global_oom_handling is defined
2026-02-23 01:20:41 +00:00
Jonathan Brouwer 00d849a1b9 Rollup merge of #152591 - alexcrichton:simplify-rc-arc-default, r=joboet
Simplify internals of `{Rc,Arc}::default`

This commit simplifies the internal implementation of `Default` for these two pointer types to have the same performance characteristics as before (a side effect of changes in rust-lang/rust#131460) while avoid use of internal private APIs of Rc/Arc. To preserve the same codegen as before some non-generic functions needed to be tagged as `#[inline]` as well, but otherwise the same IR is produced before/after this change.

The motivation of this commit is I was studying up on the state of initialization of `Arc` and `Rc` and figured it'd be nicer to reduce the use of internal APIs and instead use public stable APIs where possible, even in the implementation itself.
2026-02-22 11:31:13 +01:00
bors d8b2222b11 Auto merge of #152737 - scottmcm:box_new_uninit_layout, r=RalfJung
Just pass `Layout` directly to `box_new_uninit`

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152737)*

We have a constant for it already (used in `RawVec` for basically the same polymorphization) so let's use it.

This is a simple follow-up to rust-lang/rust#148190 from one of the comments.
2026-02-22 01:21:56 +00:00
cyrgani 83ef5059d6 make rustc_allow_const_fn_unstable an actual rustc_attrs attribute 2026-02-17 20:16:29 +00:00
Scott McMurray 4b03b97226 What if we discourage mir-inlining of box_new_uninit? 2026-02-17 09:09:48 -08:00
Scott McMurray 1b767bf623 Just pass Layout directly to box_new_uninit
We have a constant for it already (used in `RawVec` for basically the same polymorphization) so let's use it.

Conveniently, it can even be safe that way!
2026-02-17 09:09:35 -08:00
Ralf Jung e5ed8643b6 adjust clippy to fix some of the issues 2026-02-16 17:27:40 +01:00
Ralf Jung 5e65109f21 add write_box_via_move intrinsic and use it for vec!
This allows us to get rid of box_new entirely
2026-02-16 17:27:40 +01:00
Ralf Jung 93d45480aa replace box_new in Box::new with write_via_move
requires lowering write_via_move during MIR building to make it just like an assignment
2026-02-16 08:44:56 +01:00
bors 2219766af6 Auto merge of #152605 - scottmcm:box-drop-alignment, r=Mark-Simulacrum
Pass alignments through the shim as `Alignment` (not `usize`)

We're using `Layout` on both sides, so might as well skip the transmutes back and forth to `usize`.

The mir-opt test shows that doing so allows simplifying the boxed-slice drop slightly, for example.
2026-02-15 13:38:45 +00:00
Jonathan Brouwer 96066cb5b5 Rollup merge of #143575 - GrigorenkoPV:unused_lifetimes, r=Mark-Simulacrum
Remove named lifetimes in some `PartialOrd` & `PartialEq` `impl`s

Makes [the docs](https://doc.rust-lang.org/1.88.0/std/cmp/trait.PartialOrd.html#impl-PartialOrd%3CPathBuf%3E-for-Cow%3C'a,+Path%3E) way easier to look at, gets rid of a few `#[allow(unused_lifetimes)]`, and AFAICT is completely equivalent.
2026-02-14 22:11:54 +01:00
Alex Crichton ce4c17f615 Simplify internals of {Rc,Arc}::default
This commit simplifies the internal implementation of `Default` for
these two pointer types to have the same performance characteristics as
before (a side effect of changes in 131460) while avoid use of internal
private APIs of Rc/Arc. To preserve the same codegen as before some
non-generic functions needed to be tagged as `#[inline]` as well, but
otherwise the same IR is produced before/after this change.

The motivation of this commit is I was studying up on the state of
initialization of `Arc` and `Rc` and figured it'd be nicer to reduce the
use of internal APIs and instead use public stable APIs where possible,
even in the implementation itself.
2026-02-14 10:56:42 -08:00
Scott McMurray 774268afc1 Pass alignments through the shim as Alignment (not usize)
We're using `Layout` on both sides, so might as well skip the transmutes back and forth to `usize`.

The mir-opt test shows that doing so allows simplifying the boxed-slice drop slightly, for example.
2026-02-14 01:39:16 -08:00
Pavel Grigorenko cd314dead1 Remove named lifetimes in some PartialOrd & PartialEq impls 2026-02-14 00:13:46 +03:00
Jonathan Brouwer 65d982abd8 Rollup merge of #152469 - mu001999-contrib:cleanup/unused-features, r=nadrieril,jdonszelmann
Remove unused features

Detected by https://github.com/rust-lang/rust/pull/152164.

~~Only allow `unused_features` if there are complex platform-specific features enabled.~~
2026-02-13 13:34:58 +01:00
mu001999 0dc1556968 Remove unused features in library 2026-02-13 09:25:50 +08:00
bors 7ad4e69ad5 Auto merge of #152517 - jhpratt:rollup-fGRcId6, r=jhpratt
Rollup of 17 pull requests

Successful merges:

 - rust-lang/rust#142415 (Add note when inherent impl for a alias type defined outside of the crate)
 - rust-lang/rust#142680 (Fix passing/returning structs with the 64-bit SPARC ABI)
 - rust-lang/rust#150768 (Don't compute FnAbi for LLVM intrinsics in backends)
 - rust-lang/rust#151152 (Add FCW for derive helper attributes that will conflict with built-in attributes)
 - rust-lang/rust#151814 (layout: handle rigid aliases without params)
 - rust-lang/rust#151863 (Borrowck: simplify diagnostics for placeholders)
 - rust-lang/rust#152159 (Add note for `?Sized` params in int-ptr casts diag)
 - rust-lang/rust#152434 (Clarify names of `QueryVTable` functions for "executing" a query)
 - rust-lang/rust#152478 (Remove tm_factory field from CodegenContext)
 - rust-lang/rust#152498 (Partially revert "resolve: Update `NameBindingData::vis` in place")
 - rust-lang/rust#152316 (fix: add continue)
 - rust-lang/rust#152394 (Correctly check if a macro call is actually a macro call in rustdoc highlighter)
 - rust-lang/rust#152425 (Port #![test_runner] to the attribute parser)
 - rust-lang/rust#152481 (Use cg_ssa's produce_final_output_artifacts in cg_clif)
 - rust-lang/rust#152485 (fix issue#152482)
 - rust-lang/rust#152495 (Clean up some subdiagnostics)
 - rust-lang/rust#152502 (Implement `BinaryHeap::from_raw_vec`)
2026-02-12 06:57:59 +00:00
Dan54 9383138801 add BinaryHeap::from_raw_vec 2026-02-11 21:18:07 +00:00
Lukas Bergdoll 2f3b952349 Stabilize assert_matches 2026-02-11 14:13:44 +01:00
Jana Dönszelmann 9d6e120939 remove from impl block in std 2026-02-08 22:22:58 +01:00
Jonathan Brouwer 7b8be37c1f Rollup merge of #152292 - GrigorenkoPV:sigma, r=Noratrieb
Minor change for readability

Everyone praise inline const blocks!
2026-02-07 19:34:51 +01:00
Pavel Grigorenko da421f5585 const { 'Σ'.len_utf8() } 2026-02-07 17:20:39 +03:00
Jonathan Brouwer 6fe0999ad6 Rollup merge of #148590 - GrigorenkoPV:atomic_try_update, r=jhpratt
Stabilize `atomic_try_update`and deprecate `fetch_update` starting 1.99.0

Tracking issue: rust-lang/rust#135894
FCP completed: https://github.com/rust-lang/rust/issues/135894#issuecomment-3685449783

~1.96.0 was chosen because I don't think the remaining month until 1.93.0 becomes beta is enough for the FCP to finish and this to get merged, so 1.94.0 + a couple of versions of leeway: https://github.com/rust-lang/rust/issues/135894#issuecomment-3491707614~

1.99 suggested in https://github.com/rust-lang/rust/pull/148590#discussion_r2730000452

Closes rust-lang/rust#135894
2026-02-07 13:06:33 +01: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
Stuart Cook 70e5959e48 Rollup merge of #151785 - zachs18:stabilize-push_mut, r=jhpratt
Stabilize feature(push_mut)

Stabilizes `feature(push_mut)`, consisting of `Vec::push_mut`, `Vec::insert_mut`, `VecDeque::push_front_mut`, `VecDeque::push_back_mut`, `VecDeque::insert_mut`, `LinkedList::push_front_mut`, and `LinkedList::push_back_mut`.

Tracking issue: https://github.com/rust-lang/rust/issues/135974

FCP completed: https://github.com/rust-lang/rust/issues/135974#issuecomment-3763973089

Release notes: https://github.com/rust-lang/rust/issues/151252
2026-01-29 19:03:32 +11:00
Jonathan Brouwer 3ffbf6e692 Rollup merge of #151769 - Qelxiros:vecdeque_splice_fix, r=joboet
fix undefined behavior in VecDeque::splice

closes rust-lang/rust#151758
2026-01-28 21:10:53 +01:00
Jonathan Brouwer 3f23c0997a Rollup merge of #150968 - tgross35:remove-no-f16-f128, r=Amanieu
compiler-builtins: Remove the no-f16-f128 feature

This option was used to gate `f16` and `f128` when support across backends and targets was inconsistent. We now have the rustc builtin cfg `target_has_reliable{f16,f128}` which has taken over this usecase. Remove no-f16-f128 since it is now unused and redundant.
2026-01-28 21:10:50 +01:00
Zachary S 890e50de69 Stabilize feature(push_mut) 2026-01-28 10:02:49 -06:00
Stuart Cook a9118046f4 Rollup merge of #151013 - ehuss:fmt-clarification, r=joboet
Add some clarifications and fixes for fmt syntax

This tries to clarify a few things regarding fmt syntax:

- The comment on `Parser::word` seems to be wrong, as that underscore-prefixed words are just fine. This was changed in https://github.com/rust-lang/rust/pull/66847.
- I struggled to follow the description of the width argument. It referred to a "second argument", but I don't know what second argument it is referring to (which is the first?). Either way, I rewrote the paragraph to try to be a little more explicit, and to use shorter sentences.
- The description of the precision argument wasn't really clear about the distinction of an Nth argument and a named argument. I added a sentence to try to emphasize the difference.
- `IDENTIFIER_OR_KEYWORD` was changed recently in https://github.com/rust-lang/reference/pull/2049 to include bare `_`. But fmt named arguments are not allowed to be a bare `_`.
2026-01-28 19:03:51 +11:00
Jeremy Smart b0d96492d0 fix undefined behavior in VecDeque::splice 2026-01-27 19:30:37 -05:00
Pavel Grigorenko 3a48b9fe1a Stabilize atomic_try_update
and deprecate fetch_update starting 1.99.0
2026-01-27 21:15:27 +03:00
bors 873d4682c7 Auto merge of #151337 - the8472:bail-before-memcpy2, r=Mark-Simulacrum
optimize `vec.extend(slice.to_vec())`, take 2

Redoing https://github.com/rust-lang/rust/pull/130998
It was reverted in https://github.com/rust-lang/rust/pull/151150 due to flakiness. I have traced this to layout randomization perturbing the test (the failure reproduces locally with layout randomization), which is now excluded.
2026-01-25 19:45:35 +00:00