Skip to content

Commit 659982c

Browse files
github-actions[bot]oli-obktgross35KobzolRalfJung
authored
Merge subtree update for toolchain nightly-2025-04-04 (#318)
This is an automated PR to merge library subtree updates from 2025-04-01 (rust-lang/rust@0b45675) to 2025-04-04 (rust-lang/rust@00095b3), inclusive. This is a clean merge, no conflicts were detected. **Do not remove or edit the following annotations:** git-subtree-dir: library git-subtree-split: 0cce469 --------- Signed-off-by: Sean Cross <[email protected]> Signed-off-by: Jiahao XU <[email protected]> Signed-off-by: Ayush Singh <[email protected]> Signed-off-by: xizheyin <[email protected]> Co-authored-by: Oli Scherer <[email protected]> Co-authored-by: Trevor Gross <[email protected]> Co-authored-by: Jakub Beránek <[email protected]> Co-authored-by: Ralf Jung <[email protected]> Co-authored-by: Sean Cross <[email protected]> Co-authored-by: Aurelia Molzer <[email protected]> Co-authored-by: Eric Huss <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: Nicole L <[email protected]> Co-authored-by: bjorn3 <[email protected]> Co-authored-by: Matthias Krüger <[email protected]> Co-authored-by: beetrees <[email protected]> Co-authored-by: Josh Stone <[email protected]> Co-authored-by: Thalia Archibald <[email protected]> Co-authored-by: Berrysoft <[email protected]> Co-authored-by: Mara Bos <[email protected]> Co-authored-by: Manish Goregaokar <[email protected]> Co-authored-by: ClearLove <[email protected]> Co-authored-by: Thom Chiovoloni <[email protected]> Co-authored-by: Scott McMurray <[email protected]> Co-authored-by: Jiahao XU <[email protected]> Co-authored-by: Michael Goulet <[email protected]> Co-authored-by: The Miri Cronjob Bot <[email protected]> Co-authored-by: Jacob Pratt <[email protected]> Co-authored-by: Tobias Bucher <[email protected]> Co-authored-by: León Orell Valerian Liehr <[email protected]> Co-authored-by: Yotam Ofek <[email protected]> Co-authored-by: okaneco <[email protected]> Co-authored-by: 许杰友 Jieyou Xu (Joe) <[email protected]> Co-authored-by: Guillaume Gomez <[email protected]> Co-authored-by: Ayush Singh <[email protected]> Co-authored-by: Noratrieb <[email protected]> Co-authored-by: Marijn Schouten <[email protected]> Co-authored-by: Ibraheem Ahmed <[email protected]> Co-authored-by: Chris Denton <[email protected]> Co-authored-by: Taiki Endo <[email protected]> Co-authored-by: bendn <[email protected]> Co-authored-by: Caleb Zulawski <[email protected]> Co-authored-by: Jana Dönszelmann <[email protected]> Co-authored-by: syvb <[email protected]> Co-authored-by: Sebastian Urban <[email protected]> Co-authored-by: Bardi Harborow <[email protected]> Co-authored-by: lcnr <[email protected]> Co-authored-by: moxian <[email protected]> Co-authored-by: Frank King <[email protected]> Co-authored-by: joboet <[email protected]> Co-authored-by: Takayuki Maeda <[email protected]> Co-authored-by: DaniPopes <[email protected]> Co-authored-by: Mads Marquart <[email protected]> Co-authored-by: Christopher Durham <[email protected]> Co-authored-by: Rafael Bachmann <[email protected]> Co-authored-by: xizheyin <[email protected]> Co-authored-by: Benoît du Garreau <[email protected]> Co-authored-by: Daniel Henry-Mantilla <[email protected]> Co-authored-by: mejrs <[email protected]> Co-authored-by: clubby789 <[email protected]> Co-authored-by: Daniel Bloom <[email protected]> Co-authored-by: gitbot <git@bot> Co-authored-by: Michael Tautschnig <[email protected]>
1 parent 9500327 commit 659982c

File tree

12 files changed

+729
-733
lines changed

12 files changed

+729
-733
lines changed

library/Cargo.lock

+18-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

library/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ adler2.debug = 0
3838
gimli.debug = 0
3939
gimli.opt-level = "s"
4040
miniz_oxide.debug = 0
41+
miniz_oxide.opt-level = "s"
42+
# `opt-level = "s"` for `object` led to a size regression when tried previously
4143
object.debug = 0
4244
rustc-demangle.debug = 0
45+
rustc-demangle.opt-level = "s"
4346

4447
[patch.crates-io]
4548
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on

library/core/src/cell.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ impl<T: Copy> Cell<T> {
544544
unsafe { *self.value.get() }
545545
}
546546

547-
/// Updates the contained value using a function and returns the new value.
547+
/// Updates the contained value using a function.
548548
///
549549
/// # Examples
550550
///
@@ -554,21 +554,14 @@ impl<T: Copy> Cell<T> {
554554
/// use std::cell::Cell;
555555
///
556556
/// let c = Cell::new(5);
557-
/// let new = c.update(|x| x + 1);
558-
///
559-
/// assert_eq!(new, 6);
557+
/// c.update(|x| x + 1);
560558
/// assert_eq!(c.get(), 6);
561559
/// ```
562560
#[inline]
563561
#[unstable(feature = "cell_update", issue = "50186")]
564-
pub fn update<F>(&self, f: F) -> T
565-
where
566-
F: FnOnce(T) -> T,
567-
{
562+
pub fn update(&self, f: impl FnOnce(T) -> T) {
568563
let old = self.get();
569-
let new = f(old);
570-
self.set(new);
571-
new
564+
self.set(f(old));
572565
}
573566
}
574567

library/core/src/slice/iter.rs

+25-20
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ unsafe impl<T: Sync> Send for Iter<'_, T> {}
9696

9797
impl<'a, T> Iter<'a, T> {
9898
#[inline]
99-
pub(super) fn new(slice: &'a [T]) -> Self {
99+
pub(super) const fn new(slice: &'a [T]) -> Self {
100100
let len = slice.len();
101-
let ptr: NonNull<T> = NonNull::from(slice).cast();
101+
let ptr: NonNull<T> = NonNull::from_ref(slice).cast();
102102
// SAFETY: Similar to `IterMut::new`.
103103
unsafe {
104104
let end_or_len =
@@ -270,9 +270,9 @@ unsafe impl<T: Send> Send for IterMut<'_, T> {}
270270

271271
impl<'a, T> IterMut<'a, T> {
272272
#[inline]
273-
pub(super) fn new(slice: &'a mut [T]) -> Self {
273+
pub(super) const fn new(slice: &'a mut [T]) -> Self {
274274
let len = slice.len();
275-
let ptr: NonNull<T> = NonNull::from(slice).cast();
275+
let ptr: NonNull<T> = NonNull::from_mut(slice).cast();
276276
// SAFETY: There are several things here:
277277
//
278278
// `ptr` has been obtained by `slice.as_ptr()` where `slice` is a valid
@@ -1387,7 +1387,7 @@ pub struct Windows<'a, T: 'a> {
13871387

13881388
impl<'a, T: 'a> Windows<'a, T> {
13891389
#[inline]
1390-
pub(super) fn new(slice: &'a [T], size: NonZero<usize>) -> Self {
1390+
pub(super) const fn new(slice: &'a [T], size: NonZero<usize>) -> Self {
13911391
Self { v: slice, size }
13921392
}
13931393
}
@@ -1539,7 +1539,7 @@ pub struct Chunks<'a, T: 'a> {
15391539

15401540
impl<'a, T: 'a> Chunks<'a, T> {
15411541
#[inline]
1542-
pub(super) fn new(slice: &'a [T], size: usize) -> Self {
1542+
pub(super) const fn new(slice: &'a [T], size: usize) -> Self {
15431543
Self { v: slice, chunk_size: size }
15441544
}
15451545
}
@@ -1729,7 +1729,7 @@ pub struct ChunksMut<'a, T: 'a> {
17291729

17301730
impl<'a, T: 'a> ChunksMut<'a, T> {
17311731
#[inline]
1732-
pub(super) fn new(slice: &'a mut [T], size: usize) -> Self {
1732+
pub(super) const fn new(slice: &'a mut [T], size: usize) -> Self {
17331733
Self { v: slice, chunk_size: size, _marker: PhantomData }
17341734
}
17351735
}
@@ -1915,7 +1915,7 @@ pub struct ChunksExact<'a, T: 'a> {
19151915

19161916
impl<'a, T> ChunksExact<'a, T> {
19171917
#[inline]
1918-
pub(super) fn new(slice: &'a [T], chunk_size: usize) -> Self {
1918+
pub(super) const fn new(slice: &'a [T], chunk_size: usize) -> Self {
19191919
let rem = slice.len() % chunk_size;
19201920
let fst_len = slice.len() - rem;
19211921
// SAFETY: 0 <= fst_len <= slice.len() by construction above
@@ -2095,7 +2095,7 @@ pub struct ChunksExactMut<'a, T: 'a> {
20952095

20962096
impl<'a, T> ChunksExactMut<'a, T> {
20972097
#[inline]
2098-
pub(super) fn new(slice: &'a mut [T], chunk_size: usize) -> Self {
2098+
pub(super) const fn new(slice: &'a mut [T], chunk_size: usize) -> Self {
20992099
let rem = slice.len() % chunk_size;
21002100
let fst_len = slice.len() - rem;
21012101
// SAFETY: 0 <= fst_len <= slice.len() by construction above
@@ -2262,7 +2262,7 @@ pub struct ArrayWindows<'a, T: 'a, const N: usize> {
22622262

22632263
impl<'a, T: 'a, const N: usize> ArrayWindows<'a, T, N> {
22642264
#[inline]
2265-
pub(super) fn new(slice: &'a [T]) -> Self {
2265+
pub(super) const fn new(slice: &'a [T]) -> Self {
22662266
let num_windows = slice.len().saturating_sub(N - 1);
22672267
Self { slice_head: slice.as_ptr(), num: num_windows, marker: PhantomData }
22682268
}
@@ -2386,8 +2386,10 @@ pub struct ArrayChunks<'a, T: 'a, const N: usize> {
23862386
}
23872387

23882388
impl<'a, T, const N: usize> ArrayChunks<'a, T, N> {
2389+
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
2390+
// #[rustc_const_unstable(feature = "slice_as_chunks", issue = "74985")]
23892391
#[inline]
2390-
pub(super) fn new(slice: &'a [T]) -> Self {
2392+
pub(super) const fn new(slice: &'a [T]) -> Self {
23912393
let (array_slice, rem) = slice.as_chunks();
23922394
Self { iter: array_slice.iter(), rem }
23932395
}
@@ -2512,8 +2514,9 @@ pub struct ArrayChunksMut<'a, T: 'a, const N: usize> {
25122514
}
25132515

25142516
impl<'a, T, const N: usize> ArrayChunksMut<'a, T, N> {
2517+
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
25152518
#[inline]
2516-
pub(super) fn new(slice: &'a mut [T]) -> Self {
2519+
pub(super) const fn new(slice: &'a mut [T]) -> Self {
25172520
let (array_slice, rem) = slice.as_chunks_mut();
25182521
Self { iter: array_slice.iter_mut(), rem }
25192522
}
@@ -2631,7 +2634,7 @@ pub struct RChunks<'a, T: 'a> {
26312634

26322635
impl<'a, T: 'a> RChunks<'a, T> {
26332636
#[inline]
2634-
pub(super) fn new(slice: &'a [T], size: usize) -> Self {
2637+
pub(super) const fn new(slice: &'a [T], size: usize) -> Self {
26352638
Self { v: slice, chunk_size: size }
26362639
}
26372640
}
@@ -2811,7 +2814,7 @@ pub struct RChunksMut<'a, T: 'a> {
28112814

28122815
impl<'a, T: 'a> RChunksMut<'a, T> {
28132816
#[inline]
2814-
pub(super) fn new(slice: &'a mut [T], size: usize) -> Self {
2817+
pub(super) const fn new(slice: &'a mut [T], size: usize) -> Self {
28152818
Self { v: slice, chunk_size: size, _marker: PhantomData }
28162819
}
28172820
}
@@ -3002,7 +3005,7 @@ pub struct RChunksExact<'a, T: 'a> {
30023005

30033006
impl<'a, T> RChunksExact<'a, T> {
30043007
#[inline]
3005-
pub(super) fn new(slice: &'a [T], chunk_size: usize) -> Self {
3008+
pub(super) const fn new(slice: &'a [T], chunk_size: usize) -> Self {
30063009
let rem = slice.len() % chunk_size;
30073010
// SAFETY: 0 <= rem <= slice.len() by construction above
30083011
let (fst, snd) = unsafe { slice.split_at_unchecked(rem) };
@@ -3028,7 +3031,8 @@ impl<'a, T> RChunksExact<'a, T> {
30283031
/// ```
30293032
#[must_use]
30303033
#[stable(feature = "rchunks", since = "1.31.0")]
3031-
pub fn remainder(&self) -> &'a [T] {
3034+
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
3035+
pub const fn remainder(&self) -> &'a [T] {
30323036
self.rem
30333037
}
30343038
}
@@ -3184,7 +3188,7 @@ pub struct RChunksExactMut<'a, T: 'a> {
31843188

31853189
impl<'a, T> RChunksExactMut<'a, T> {
31863190
#[inline]
3187-
pub(super) fn new(slice: &'a mut [T], chunk_size: usize) -> Self {
3191+
pub(super) const fn new(slice: &'a mut [T], chunk_size: usize) -> Self {
31883192
let rem = slice.len() % chunk_size;
31893193
// SAFETY: 0 <= rem <= slice.len() by construction above
31903194
let (fst, snd) = unsafe { slice.split_at_mut_unchecked(rem) };
@@ -3196,7 +3200,8 @@ impl<'a, T> RChunksExactMut<'a, T> {
31963200
/// elements.
31973201
#[must_use = "`self` will be dropped if the result is not used"]
31983202
#[stable(feature = "rchunks", since = "1.31.0")]
3199-
pub fn into_remainder(self) -> &'a mut [T] {
3203+
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
3204+
pub const fn into_remainder(self) -> &'a mut [T] {
32003205
self.rem
32013206
}
32023207
}
@@ -3360,7 +3365,7 @@ pub struct ChunkBy<'a, T: 'a, P> {
33603365

33613366
#[stable(feature = "slice_group_by", since = "1.77.0")]
33623367
impl<'a, T: 'a, P> ChunkBy<'a, T, P> {
3363-
pub(super) fn new(slice: &'a [T], predicate: P) -> Self {
3368+
pub(super) const fn new(slice: &'a [T], predicate: P) -> Self {
33643369
ChunkBy { slice, predicate }
33653370
}
33663371
}
@@ -3447,7 +3452,7 @@ pub struct ChunkByMut<'a, T: 'a, P> {
34473452

34483453
#[stable(feature = "slice_group_by", since = "1.77.0")]
34493454
impl<'a, T: 'a, P> ChunkByMut<'a, T, P> {
3450-
pub(super) fn new(slice: &'a mut [T], predicate: P) -> Self {
3455+
pub(super) const fn new(slice: &'a mut [T], predicate: P) -> Self {
34513456
ChunkByMut { slice, predicate }
34523457
}
34533458
}

0 commit comments

Comments
 (0)