Skip to content

Commit 1eb9a53

Browse files
github-actions[bot]thaliaarchiChrisDentonThe Miri Cronjob Botbjoernager
authored
Merge subtree update for toolchain nightly-2025-05-20 (#361)
This is an automated PR to merge library subtree updates from 2025-05-06 (rust-lang/rust@2e6882a) to 2025-05-20 (rust-lang/rust@60dabef) (inclusive) into main. `git merge` resulted in conflicts, which require manual resolution. Files were commited with merge conflict markers. **Do not remove or edit the following annotations:** git-subtree-dir: library git-subtree-split: cc38593 --------- Signed-off-by: Jiahao XU <[email protected]> Signed-off-by: Ayush Singh <[email protected]> Signed-off-by: Sean Cross <[email protected]> Signed-off-by: Vladimir Krivopalov <[email protected]> Signed-off-by: xizheyin <[email protected]> Co-authored-by: Thalia Archibald <[email protected]> Co-authored-by: Chris Denton <[email protected]> Co-authored-by: The Miri Cronjob Bot <[email protected]> Co-authored-by: Gabriel Bjørnager Jensen <[email protected]> Co-authored-by: Artur Roos <[email protected]> Co-authored-by: Ralf Jung <[email protected]> Co-authored-by: Jiahao XU <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: 王宇逸 <[email protected]> Co-authored-by: Nicholas Nethercote <[email protected]> Co-authored-by: Hegui Dai <[email protected]> Co-authored-by: Urgau <[email protected]> Co-authored-by: Matthias Krüger <[email protected]> Co-authored-by: bendn <[email protected]> Co-authored-by: Trevor Gross <[email protected]> Co-authored-by: ismailarilik <[email protected]> Co-authored-by: Tobias <[email protected]> Co-authored-by: Ethan Wu <[email protected]> Co-authored-by: Ayush Singh <[email protected]> Co-authored-by: Jake Goulding <[email protected]> Co-authored-by: Michael Howell <[email protected]> Co-authored-by: Christopher Durham <[email protected]> Co-authored-by: Pavel Grigorenko <[email protected]> Co-authored-by: LemonJ <[email protected]> Co-authored-by: SabrinaJewson <[email protected]> Co-authored-by: joboet <[email protected]> Co-authored-by: Andrew Zhogin <[email protected]> Co-authored-by: DaniPopes <[email protected]> Co-authored-by: Lieselotte <[email protected]> Co-authored-by: Sean Cross <[email protected]> Co-authored-by: Trevor Gross <[email protected]> Co-authored-by: Jon Bauman <[email protected]> Co-authored-by: binarycat <[email protected]> Co-authored-by: Mara Bos <[email protected]> Co-authored-by: Mathis B <[email protected]> Co-authored-by: Zachary S <[email protected]> Co-authored-by: Amanieu d'Antras <[email protected]> Co-authored-by: sayantn <[email protected]> Co-authored-by: Eyal Kalderon <[email protected]> Co-authored-by: Guillaume Gomez <[email protected]> Co-authored-by: Lynnesbian <[email protected]> Co-authored-by: Christopher Berner <[email protected]> Co-authored-by: Stuart Cook <[email protected]> Co-authored-by: Paolo Barbolini <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: The 8472 <[email protected]> Co-authored-by: Nick Kocharhook <[email protected]> Co-authored-by: Vladimir Krivopalov <[email protected]> Co-authored-by: Vilim Lendvaj <[email protected]> Co-authored-by: David Tolnay <[email protected]> Co-authored-by: Marijn Schouten <[email protected]> Co-authored-by: Jacob Pratt <[email protected]> Co-authored-by: ivmarkov <[email protected]> Co-authored-by: Martin Kröning <[email protected]> Co-authored-by: Daniel Paoliello <[email protected]> Co-authored-by: Luca Versari <[email protected]> Co-authored-by: xizheyin <[email protected]> Co-authored-by: Ben Kimock <[email protected]> Co-authored-by: Dietrich Daroch <[email protected]> Co-authored-by: León Orell Valerian Liehr <[email protected]> Co-authored-by: Pietro Albini <[email protected]> Co-authored-by: Julian Knodt <[email protected]> Co-authored-by: Michael Goulet <[email protected]> Co-authored-by: Michał Łowicki <[email protected]> Co-authored-by: Samuel Tardieu <[email protected]> Co-authored-by: B I Mohammed Abbas <[email protected]> Co-authored-by: Federico Terzi <[email protected]> Co-authored-by: sam skeoch <[email protected]> Co-authored-by: est31 <[email protected]> Co-authored-by: Speedy_Lex <[email protected]> Co-authored-by: Mario Pastorelli <[email protected]> Co-authored-by: gitbot <git@bot> Co-authored-by: Michael Tautschnig <[email protected]>
1 parent 9b57573 commit 1eb9a53

File tree

157 files changed

+7481
-5615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+7481
-5615
lines changed

library/Cargo.lock

Lines changed: 8 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

library/alloc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bench = false
1717
[dependencies]
1818
core = { path = "../core", public = true }
1919
safety = { path = "../contracts/safety" }
20-
compiler_builtins = { version = "=0.1.156", features = ['rustc-dep-of-std'] }
20+
compiler_builtins = { version = "=0.1.159", features = ['rustc-dep-of-std'] }
2121

2222
[features]
2323
compiler-builtins-mem = ['compiler_builtins/mem']

library/alloc/src/collections/btree/map.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,14 +1917,13 @@ pub struct ExtractIf<
19171917
V,
19181918
F,
19191919
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global,
1920-
> where
1921-
F: 'a + FnMut(&K, &mut V) -> bool,
1922-
{
1920+
> {
19231921
pred: F,
19241922
inner: ExtractIfInner<'a, K, V>,
19251923
/// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`.
19261924
alloc: A,
19271925
}
1926+
19281927
/// Most of the implementation of ExtractIf are generic over the type
19291928
/// of the predicate, thus also serving for BTreeSet::ExtractIf.
19301929
pub(super) struct ExtractIfInner<'a, K, V> {
@@ -1940,14 +1939,14 @@ pub(super) struct ExtractIfInner<'a, K, V> {
19401939
}
19411940

19421941
#[unstable(feature = "btree_extract_if", issue = "70530")]
1943-
impl<K, V, F> fmt::Debug for ExtractIf<'_, K, V, F>
1942+
impl<K, V, F, A> fmt::Debug for ExtractIf<'_, K, V, F, A>
19441943
where
19451944
K: fmt::Debug,
19461945
V: fmt::Debug,
1947-
F: FnMut(&K, &mut V) -> bool,
1946+
A: Allocator + Clone,
19481947
{
19491948
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1950-
f.debug_tuple("ExtractIf").field(&self.inner.peek()).finish()
1949+
f.debug_struct("ExtractIf").field("peek", &self.inner.peek()).finish_non_exhaustive()
19511950
}
19521951
}
19531952

library/alloc/src/collections/btree/set.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,24 +1556,23 @@ pub struct ExtractIf<
15561556
T,
15571557
F,
15581558
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global,
1559-
> where
1560-
T: 'a,
1561-
F: 'a + FnMut(&T) -> bool,
1562-
{
1559+
> {
15631560
pred: F,
15641561
inner: super::map::ExtractIfInner<'a, T, SetValZST>,
15651562
/// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`.
15661563
alloc: A,
15671564
}
15681565

15691566
#[unstable(feature = "btree_extract_if", issue = "70530")]
1570-
impl<T, F, A: Allocator + Clone> fmt::Debug for ExtractIf<'_, T, F, A>
1567+
impl<T, F, A> fmt::Debug for ExtractIf<'_, T, F, A>
15711568
where
15721569
T: fmt::Debug,
1573-
F: FnMut(&T) -> bool,
1570+
A: Allocator + Clone,
15741571
{
15751572
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1576-
f.debug_tuple("ExtractIf").field(&self.inner.peek().map(|(k, _)| k)).finish()
1573+
f.debug_struct("ExtractIf")
1574+
.field("peek", &self.inner.peek().map(|(k, _)| k))
1575+
.finish_non_exhaustive()
15771576
}
15781577
}
15791578

library/alloc/src/collections/linked_list.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,9 +1976,14 @@ where
19761976
}
19771977

19781978
#[stable(feature = "extract_if", since = "1.87.0")]
1979-
impl<T: fmt::Debug, F> fmt::Debug for ExtractIf<'_, T, F> {
1979+
impl<T, F, A> fmt::Debug for ExtractIf<'_, T, F, A>
1980+
where
1981+
T: fmt::Debug,
1982+
A: Allocator,
1983+
{
19801984
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1981-
f.debug_tuple("ExtractIf").field(&self.list).finish()
1985+
let peek = self.it.map(|node| unsafe { &node.as_ref().element });
1986+
f.debug_struct("ExtractIf").field("peek", &peek).finish_non_exhaustive()
19821987
}
19831988
}
19841989

library/alloc/src/collections/vec_deque/mod.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,73 @@ impl<T, A: Allocator> VecDeque<T, A> {
11911191
}
11921192
}
11931193

1194+
/// Shortens the deque, keeping the last `len` elements and dropping
1195+
/// the rest.
1196+
///
1197+
/// If `len` is greater or equal to the deque's current length, this has
1198+
/// no effect.
1199+
///
1200+
/// # Examples
1201+
///
1202+
/// ```
1203+
/// # #![feature(vec_deque_truncate_front)]
1204+
/// use std::collections::VecDeque;
1205+
///
1206+
/// let mut buf = VecDeque::new();
1207+
/// buf.push_front(5);
1208+
/// buf.push_front(10);
1209+
/// buf.push_front(15);
1210+
/// assert_eq!(buf, [15, 10, 5]);
1211+
/// assert_eq!(buf.as_slices(), (&[15, 10, 5][..], &[][..]));
1212+
/// buf.truncate_front(1);
1213+
/// assert_eq!(buf.as_slices(), (&[5][..], &[][..]));
1214+
/// ```
1215+
#[unstable(feature = "vec_deque_truncate_front", issue = "140667")]
1216+
pub fn truncate_front(&mut self, len: usize) {
1217+
/// Runs the destructor for all items in the slice when it gets dropped (normally or
1218+
/// during unwinding).
1219+
struct Dropper<'a, T>(&'a mut [T]);
1220+
1221+
impl<'a, T> Drop for Dropper<'a, T> {
1222+
fn drop(&mut self) {
1223+
unsafe {
1224+
ptr::drop_in_place(self.0);
1225+
}
1226+
}
1227+
}
1228+
1229+
unsafe {
1230+
if len >= self.len {
1231+
// No action is taken
1232+
return;
1233+
}
1234+
1235+
let (front, back) = self.as_mut_slices();
1236+
if len > back.len() {
1237+
// The 'back' slice remains unchanged.
1238+
// front.len() + back.len() == self.len, so 'end' is non-negative
1239+
// and end < front.len()
1240+
let end = front.len() - (len - back.len());
1241+
let drop_front = front.get_unchecked_mut(..end) as *mut _;
1242+
self.head += end;
1243+
self.len = len;
1244+
ptr::drop_in_place(drop_front);
1245+
} else {
1246+
let drop_front = front as *mut _;
1247+
// 'end' is non-negative by the condition above
1248+
let end = back.len() - len;
1249+
let drop_back = back.get_unchecked_mut(..end) as *mut _;
1250+
self.head = self.to_physical_idx(self.len - len);
1251+
self.len = len;
1252+
1253+
// Make sure the second half is dropped even when a destructor
1254+
// in the first one panics.
1255+
let _back_dropper = Dropper(&mut *drop_back);
1256+
ptr::drop_in_place(drop_front);
1257+
}
1258+
}
1259+
}
1260+
11941261
/// Returns a reference to the underlying allocator.
11951262
#[unstable(feature = "allocator_api", issue = "32838")]
11961263
#[inline]

library/alloc/src/ffi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ pub use self::c_str::CString;
8787
#[stable(feature = "alloc_c_string", since = "1.64.0")]
8888
pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError};
8989

90-
#[stable(feature = "c_str_module", since = "CURRENT_RUSTC_VERSION")]
90+
#[stable(feature = "c_str_module", since = "1.88.0")]
9191
pub mod c_str;

library/alloc/src/raw_vec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl<T, A: Allocator> RawVec<T, A> {
287287
}
288288

289289
#[inline]
290-
pub(crate) fn non_null(&self) -> NonNull<T> {
290+
pub(crate) const fn non_null(&self) -> NonNull<T> {
291291
self.inner.non_null()
292292
}
293293

library/alloc/src/rc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,11 +3536,11 @@ impl<T> Default for Weak<T> {
35363536
}
35373537
}
35383538

3539-
// NOTE: We checked_add here to deal with mem::forget safely. In particular
3540-
// if you mem::forget Rcs (or Weaks), the ref-count can overflow, and then
3541-
// you can free the allocation while outstanding Rcs (or Weaks) exist.
3542-
// We abort because this is such a degenerate scenario that we don't care about
3543-
// what happens -- no real program should ever experience this.
3539+
// NOTE: If you mem::forget Rcs (or Weaks), drop is skipped and the ref-count
3540+
// is not decremented, meaning the ref-count can overflow, and then you can
3541+
// free the allocation while outstanding Rcs (or Weaks) exist, which would be
3542+
// unsound. We abort because this is such a degenerate scenario that we don't
3543+
// care about what happens -- no real program should ever experience this.
35443544
//
35453545
// This should have negligible overhead since you don't actually need to
35463546
// clone these much in Rust thanks to ownership and move-semantics.

0 commit comments

Comments
 (0)