3447 Commits

Author SHA1 Message Date
bors
20f1c045c4 Auto merge of #148721 - Zalathar:rollup-398va3y, r=Zalathar
Rollup of 22 pull requests

Successful merges:

 - rust-lang/rust#128666 (Add `overflow_checks` intrinsic)
 - rust-lang/rust#146305 (Add correct suggestion for multi-references for self type in method)
 - rust-lang/rust#147179 ([DebugInfo] Fix container types failing to find template args)
 - rust-lang/rust#147743 (Show packed field alignment in mir_transform_unaligned_packed_ref)
 - rust-lang/rust#148079 (Rename `downcast_[ref|mut]_unchecked` -> `downcast_unchecked_[ref|mut]`)
 - rust-lang/rust#148084 (Optimize path components iteration on platforms that don't have prefixes)
 - rust-lang/rust#148126 (Fix rust stdlib build failing for VxWorks)
 - rust-lang/rust#148204 (Modify contributor email entries in .mailmap)
 - rust-lang/rust#148279 (rustc_builtin_macros: rename bench parameter to avoid collisions with user-defined function names)
 - rust-lang/rust#148333 (constify result unwrap unchecked)
 - rust-lang/rust#148539 (Add Allocator proxy impls for Box, Rc, and Arc)
 - rust-lang/rust#148601 (`invalid_atomic_ordering`: also lint `update` & `try_update`)
 - rust-lang/rust#148612 (Add note for identifier with attempted hygiene violation)
 - rust-lang/rust#148613 (Switch hexagon targets to rust-lld)
 - rust-lang/rust#148619 (Enable std locking functions on AIX)
 - rust-lang/rust#148644 ([bootstrap] Make `--open` option work with `doc src/tools/error_index_generator`)
 - rust-lang/rust#148649 (don't completely reset `HeadUsages`)
 - rust-lang/rust#148673 (Remove a remnant of `dyn*` from the parser)
 - rust-lang/rust#148675 (Remove eslint-js from npm dependencies)
 - rust-lang/rust#148680 (Recover `[T: N]` as `[T; N]`)
 - rust-lang/rust#148688 (Remove unused argument `features` from `eval_config_entry`)
 - rust-lang/rust#148711 (Use the current lint note id when parsing `cfg!()`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-09 08:27:35 +00:00
Stuart Cook
ebb1777398
Rollup merge of #148539 - cramertj:alloc-arc, r=Amanieu
Add Allocator proxy impls for Box, Rc, and Arc

This adds to the existing proxy impl for &T.

Fixes https://github.com/rust-lang/wg-allocators/issues/54
2025-11-09 13:22:29 +11:00
Gabriel Bjørnager Jensen
fa8e8649ad
Stabilise 'as_array' in '[_]' and '*const [_]'; Stabilise 'as_mut_array' in '[_]' and '*mut [_]'; Update feature gate and tracking issue for 'alloc_slice_into_array' items; 2025-11-07 15:14:41 +01:00
Jacob Pratt
4ad5a39183
Rollup merge of #147808 - hkBst:btree-3, r=joboet
btree: cleanup difference, intersection, is_subset
2025-11-07 00:21:19 -05:00
Jacob Pratt
47eeb00a63
Rollup merge of #145992 - GrigorenkoPV:stabilize/vec_deque_pop_if, r=Amanieu
Stabilize `vec_deque_pop_if`

Tracking issue: rust-lang/rust#135889
Closes rust-lang/rust#135889
Also fixes a typo mentioned in https://github.com/rust-lang/rust/issues/135889#issuecomment-2991213248

FCP: https://github.com/rust-lang/rust/issues/135889#issuecomment-3238777731

`@rustbot` label -T-libs +T-libs-api +needs-fcp +S-waiting-on-fcp

r? t-libs-api
2025-11-07 00:21:17 -05:00
Matthias Krüger
f7f128fd48
Rollup merge of #146861 - antonilol:vec_deque_extend_front, r=joboet
add extend_front to VecDeque with specialization like extend

ACP: https://github.com/rust-lang/libs-team/issues/658
Tracking issue: rust-lang/rust#146975

_Text below was written before opening the ACP_

Feature was requested in rust-lang/rust#69939, I recently also needed it so decided to implement it as my first contribution to the Rust standard library. I plan on doing more but wanted to start with a small change.

Some questions I had (both on implementation and design) with answers:
- Q: `extend` allows iterators that yield `&T` where `T` is `Clone`, should extend_front do too?
  A: No, users can use [`copied`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.copied) and/or [`cloned`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.cloned).
- Q: Does this need a whole new trait like Extend or only a method on `VecDeque`?
  A: No, see ACP.
- Q: How do I deal with all the code duplication? Most code is similar to that of `extend`, maybe there is a nice way to factor out the code around `push_unchecked`/`push_front_unchecked`.
  Will come back to this later.
- Q: Why are certain things behind feature gates, `cfg(not(test))` like `vec::IntoIter` here and `cfg(not(no_global_oom_handling))` like `Vec::extend_from_within`? (I am also looking at implementing `VecDeque::extend_from_within`)
  A: See https://github.com/rust-lang/rust/pull/146861#pullrequestreview-3250163369
- Q: Should `extend_front` act like repeated pushes to the front of the queue? This reverses the order of the elements. Doing it different might incur an extra move if the iterator length is not known up front (where do you start placing elements in the buffer?).
  A: `extend_front` acts like repeated pushes, `prepend` preserves the element order, see ACP or tracking issue.
2025-11-06 12:29:57 +01:00
Matthias Krüger
05f3a3d7f5
Rollup merge of #148534 - WaffleLapkin:push_within_capacity_now_with_50_percent_more_mut, r=Amanieu
Merge `Vec::push{,_mut}_within_capacity`

Implements https://github.com/rust-lang/libs-team/issues/689.

cc https://github.com/rust-lang/rust/issues/135974, https://github.com/rust-lang/rust/issues/100486

r? libs-api
2025-11-05 21:28:31 +01:00
Taylor Cramer
5943d07fb3 Add Allocator proxy impls for Box, Rc, and Arc
This adds to the existing proxy impl for &T.
2025-11-05 10:19:49 -08:00
Waffle Lapkin
32c93ccc89
Merge Vec::push{,_mut}_within_capacity 2025-11-05 17:03:25 +01:00
Marijn Schouten
acd0294845 btree: cleanup difference, intersection, is_subset 2025-11-04 15:37:54 +00:00
Stuart Cook
22e4575672
Rollup merge of #145915 - coolreader18:stabilize-fmt_from_fn, r=dtolnay
Stabilize `fmt::from_fn`

Resolves rust-lang/rust#146705, pending its FCP.

As discussed in that tracking issue and rust-lang/rust#117729, this splits `fmt::from_fn` out from the `debug_closure_helpers` feature.
2025-11-04 13:44:47 +11:00
Antoni Spaanderman
5b96677adb
add specialization for extend_front and prepend with copied slice iterator 2025-11-03 12:35:30 +01:00
Antoni Spaanderman
e23c1551a7
implement VecDeque extend_front and prepend, add tests 2025-11-01 18:30:01 +01:00
bors
d85276b256 Auto merge of #148337 - matthiaskrgr:rollup-vojwz0m, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#139310 (add first HelenOS compilation targets)
 - rust-lang/rust#147161 (implement VecDeque extend_from_within and prepend_from_within)
 - rust-lang/rust#147622 (`unicode_data` refactors)
 - rust-lang/rust#147780 (Implement VecDeque::extract_if)
 - rust-lang/rust#147942 (Enable regression labeling aliases)
 - rust-lang/rust#147986 (Use fstatat() in DirEntry::metadata on Apple platforms)
 - rust-lang/rust#148103 (cg_llvm: Pass `debuginfo_compression` through FFI as an enum)
 - rust-lang/rust#148319 (docs: Fix argument names for `carrying_mul_add`)
 - rust-lang/rust#148322 (Enable file locking support in illumos)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-01 07:12:00 +00:00
Matthias Krüger
c42f8eb2ad
Rollup merge of #147780 - tisonkun:vec-deque-extract-if, r=joboet
Implement VecDeque::extract_if

This refers to https://github.com/rust-lang/rust/issues/147750.
2025-10-31 18:41:49 +01:00
Matthias Krüger
53c52a2ae4
Rollup merge of #147161 - antonilol:vec-deque-extend-from-within, r=joboet
implement VecDeque extend_from_within and prepend_from_within

Tracking issue: rust-lang/rust#146975
2025-10-31 18:41:48 +01:00
bors
82ae0ee648 Auto merge of #144420 - Qelxiros:smart_pointer_try_map, r=joboet
smart pointer (try_)map

Tracking issue: rust-lang/rust#144419
2025-10-31 17:09:47 +00:00
Jeremy Smart
9c5be677d0
add {Box, (Unique){Rc, Arc}}::(try_)map 2025-10-31 10:13:51 -04:00
tison
06a2e72109
Implement VecDeque::extract_if
Signed-off-by: tison <wander4096@gmail.com>
2025-10-31 21:37:36 +08:00
Jacob Pratt
f1a0dfd145
Rollup merge of #138217 - theemathas:cow_is_owned_borrowed_associated, r=dtolnay
Turn `Cow::is_borrowed,is_owned` into associated functions.

This is done because `Cow` implements `Deref`. Therefore, to avoid conflicts with an inner type having a method of the same name, we use an associated method, like `Box::into_raw`.

Tracking issue: #65143
2025-10-30 02:43:41 -04:00
Josh Stone
f25ca45fd1 Update CURRENT_RUSTC_VERSION post-bump
(cherry picked from commit 813072186c1c305ea62c7270f1514dfab5166af2)
2025-10-28 13:22:00 -07:00
bors
a8664a1534 Auto merge of #145665 - GrigorenkoPV:144707, r=tgross35
Don't require `T: RefUnwindSafe` for `vec::IntoIter<T>: UnwindSafe`

Closes rust-lang/rust#144707

r? t-libs-api
2025-10-26 06:35:34 +00:00
Pavel Grigorenko
2f4813fa0a Stabilize vec_deque_pop_if 2025-10-23 23:43:59 +03:00
ltdk
ebd5bea84f Revert inference failure from Deref/Borrow constification 2025-10-23 08:51:27 -04:00
Antoni Spaanderman
63bb238e5d
implement VecDeque extend_from_within and prepend_from_within, add tests 2025-10-23 13:52:55 +02:00
Jacob Pratt
5d55418a7d
Rollup merge of #148011 - clarfonthey:const-convert-revert, r=oli-obk
Revert constification of `AsRef for Cow` due to inference failure

Reported issue: rust-lang/rust#147964
Original PR: rust-lang/rust#145279
`const AsRef` tracking issue: rust-lang/rust#143773

Should have additional crater run to verify this fixes the issue.
2025-10-23 01:22:06 -04:00
Jacob Pratt
4491efbc82
Rollup merge of #134316 - zachs18:string_replace_in_place_rebase, r=joshtriplett
Add `String::replace_first` and `String::replace_last`

Rebase of #97977 (cc `@WilliamVenner)`

> Convenience methods that use `match_indices` and `replace_range` to efficiently replace a substring in a string without reallocating, if capacity (and the implementation of `Vec::splice`) allows.

The intra-doc link to `str::replacen` is a direct url-based link to `str::replacen` in `std`'s docs to work around #98941. This means that when building only `alloc`'s docs (and not `std`'s), it will be a broken link. There is precedent for this e.g. in [`core::hint::spin_loop`](https://doc.rust-lang.org/nightly/src/core/hint.rs.html#214) which links to `std:🧵:yield_now` using a [url-based link](https://github.com/rust-lang/rust/blob/master/library/core/src/hint.rs#L265) and thus is a dead link when only building `core`'s docs.

ACP: https://github.com/rust-lang/libs-team/issues/506
2025-10-23 01:22:05 -04:00
ltdk
cb7fb35ad1 Revert inference failure from AsRef constification 2025-10-22 20:31:43 -04:00
bors
4d94478977 Auto merge of #147826 - Muscraft:update-typos, r=Noratrieb
Update typos

I saw that `typos` was a few versions out of date and figured it would be a good idea to update it. Upgrading to `1.38.1` adds the [July](https://github.com/crate-ci/typos/issues/1331), [August](https://github.com/crate-ci/typos/issues/1345), and [September](https://github.com/crate-ci/typos/issues/1370) dictionary updates. As part of this change, I also sorted the configuration file.
2025-10-22 13:11:47 +00:00
Matthias Krüger
664e3b0741
Rollup merge of #141445 - yotamofek:pr/library/from-iter-char-string, r=the8472,joshtriplett
Add `FromIterator` impls for `ascii::Char`s to `String`s

Wanted to `collect` ascii chars into a `String` while working on #141369 , and was surprised these impls don't exist. Seems to me to be simply oversight.

BTW, I only added `impl FromIterator<ascii::Char> for Cow<'_, str>`, without a corresponding `FromIterator<&Char>` impl, because there's no existing impl for `FromIterator<&char>`, but that might be oversight too.

cc #110998
2025-10-22 07:12:08 +02:00
William Venner
8ed7fca74c Add String::replace_first and String::replace_last
Rebased and modified by zachs18.

Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
2025-10-21 16:11:55 -05:00
Pavel Grigorenko
144707a4b1 Don't require T: RefUnwindSafe for vec::IntoIter<T>: UnwindSafe 2025-10-21 21:18:09 +03:00
Scott Schafer
12f6b9697f
chore: Update typos to 1.38.1 2025-10-20 12:20:15 -06:00
Matthias Krüger
003feb45d2
Rollup merge of #147814 - hkBst:btree-4, r=joboet
btree: some cleanup with less unsafe
2025-10-20 18:21:34 +02:00
bors
33cab8c4c7 Auto merge of #147847 - WaffleLapkin:hide_box_new, r=joboet
hide `alloc::alloc::box_new` in docs

It's an internal function which isn't supposed to be used outside standard library / `vec!`.
2025-10-19 06:41:36 +00:00
Waffle Lapkin
d17dbc7e36
hide alloc::alloc::box_new in docs
It's an internal function which isn't supposed to be used outside
standard library / `vec!`.
2025-10-18 17:08:49 +02:00
Matthias Krüger
b46db5c6b7
Rollup merge of #140153 - thaliaarchi:encode-wide-debug, r=ChrisDenton
Implement `Debug` for `EncodeWide`

Since `std::os::windows::ffi::EncodeWide` was reexported from `std::sys_common::wtf8::EncodeWide`, which has `#![allow(missing_debug_implementations)]` in the parent module, it did not implement `Debug`. When it was moved to `core`, a placeholder impl was added; fill it in.

This becomes insta-stable.

r? libs-api
2025-10-18 08:08:35 +02:00
Marijn Schouten
7c95768dbd btree: some cleanup with less unsafe 2025-10-17 16:43:01 +00:00
h3nryc0ding
1de9b49f24 remove duplicate inline macro 2025-10-15 18:48:25 +02:00
Matthias Krüger
f8b65f7bc7
Rollup merge of #147526 - bjorn3:alloc_shim_weak_shape, r=petrochenkov,RalfJung
Move computation of allocator shim contents to cg_ssa

In the future this should make it easier to use weak symbols for the allocator shim on platforms that properly support weak symbols. And it would allow reusing the allocator shim code for handling default implementations of the upcoming externally implementable items feature on platforms that don't properly support weak symbols.

In addition to make this possible, the alloc error handler is now handled in a way such that it is possible to avoid using the allocator shim when liballoc is compiled without `no_global_oom_handling` if you use `#[alloc_error_handler]`. Previously this was only possible if you avoided liballoc entirely or compiled it with `no_global_oom_handling`. You still need to avoid libstd and to define the symbol that indicates that avoiding the allocator shim is unstable.
2025-10-14 19:47:29 +02:00
Matthias Krüger
b96bd11c54
Rollup merge of #147246 - Kivooeo:btree-map-split-off-doc, r=Mark-Simulacrum
Explain not existed key in BTreeMap::split_off

Fixes https://github.com/rust-lang/rust/issues/147174

r? libs
2025-10-12 10:13:15 +02:00
bors
be0ade2b60 Auto merge of #147124 - a1phyr:improve_finish_grow, r=Mark-Simulacrum
Move more code to `RawVec::finish_grow`

This move a branch and more code into the cold method `finish_grow`, which means that less code is inlined at each `try_reserve` site. Additionally, this reduces the amount of parameters, so they can all be passed by registers.
2025-10-11 19:40:52 +00:00
bjorn3
116f4ae171 Support #[alloc_error_handler] without the allocator shim
Currently it is possible to avoid linking the allocator shim when
__rust_no_alloc_shim_is_unstable_v2 is defined when linking rlibs
directly as some build systems need. However this requires liballoc to
be compiled with --cfg no_global_oom_handling, which places huge
restrictions on what functions you can call and makes it impossible to
use libstd. Or alternatively you have to define
__rust_alloc_error_handler and (when using libstd)
__rust_alloc_error_handler_should_panic
using #[rustc_std_internal_symbol]. With this commit you can either use
libstd and define __rust_alloc_error_handler_should_panic or not use
libstd and use #[alloc_error_handler] instead. Both options are still
unstable though.

Eventually the alloc_error_handler may either be removed entirely
(though the PR for that has been stale for years now) or we may start
using weak symbols for it instead. For the latter case this commit is a
prerequisite anyway.
2025-10-10 13:04:53 +00:00
Matthias Krüger
47bd38c2f1
Rollup merge of #145685 - Qelxiros:cell_get_cloned, r=programmerjake,tgross35
add CloneFromCell and Cell::get_cloned

Tracking issue: rust-lang/rust#145329
2025-10-04 17:11:08 +02:00
Jeremy Smart
08b4641f50
add CloneFromCell and Cell::get_cloned 2025-10-01 18:47:09 -04:00
Kivooeo
8fcb7e18c1 extended doc comment 2025-10-01 21:22:53 +00:00
edwloef
8dfea22c97
implement Box::take 2025-10-01 17:21:12 +02:00
Matthias Krüger
f7c7e34ae4
Rollup merge of #146886 - taiki-e:rc-inner-align, r=Mark-Simulacrum
Add repr(align(2)) to RcInner and ArcInner

`Rc` currently assumes that `RcInner` has at least 2-byte alignment, but on AVR, `usize` has 1-byte alignment (this is because the AVR has 1-byte register sizes, so having 2-byte alignment is generally useless), breaking this assumption.

9f32ccf35f/library/alloc/src/rc.rs (L3005-L3008)

This PR adds `repr(align(2))` to force `RcInner` to always have at least 2-byte alignment.

Note that `ArcInner` doesn't need `repr(align(2))` because atomic types have the alignment same as its size. This PR adds a comment about this.
2025-09-30 20:46:45 +02:00
Taiki Endo
9e79fac035 Add repr(align(2)) to RcInner and ArcInner 2025-09-30 22:39:10 +09:00
Yotam Ofek
68a7c25078 Use Iterator::eq and (dogfood) eq_by in compiler and library 2025-09-29 08:08:05 +03:00