Skip to content

Commit 8d1668c

Browse files
author
gitbot
committed
Merge from b6f0945 with conflicts
2 parents 3bb48f0 + 7e44c2b commit 8d1668c

File tree

357 files changed

+10563
-16120
lines changed

Some content is hidden

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

357 files changed

+10563
-16120
lines changed

library/Cargo.lock

Lines changed: 12 additions & 13 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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ safety = { path = "../contracts/safety" }
2323
compiler-builtins-mem = ['compiler_builtins/mem']
2424
compiler-builtins-c = ["compiler_builtins/c"]
2525
compiler-builtins-no-f16-f128 = ["compiler_builtins/no-f16-f128"]
26-
# Make panics and failed asserts immediately abort without formatting any message
27-
panic_immediate_abort = ["core/panic_immediate_abort"]
2826
# Choose algorithms that are optimized for binary size instead of runtime performance
2927
optimize_for_size = ["core/optimize_for_size"]
3028

library/alloc/src/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,12 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
408408
}
409409
}
410410

411-
#[cfg(not(feature = "panic_immediate_abort"))]
411+
#[cfg(not(panic = "immediate-abort"))]
412412
{
413413
core::intrinsics::const_eval_select((layout,), ct_error, rt_error)
414414
}
415415

416-
#[cfg(feature = "panic_immediate_abort")]
416+
#[cfg(panic = "immediate-abort")]
417417
ct_error(layout)
418418
}
419419

library/alloc/src/boxed.rs

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,6 @@ impl<T> Box<T> {
290290
/// # Examples
291291
///
292292
/// ```
293-
/// #![feature(new_zeroed_alloc)]
294-
///
295293
/// let zero = Box::<u32>::new_zeroed();
296294
/// let zero = unsafe { zero.assume_init() };
297295
///
@@ -301,7 +299,7 @@ impl<T> Box<T> {
301299
/// [zeroed]: mem::MaybeUninit::zeroed
302300
#[cfg(not(no_global_oom_handling))]
303301
#[inline]
304-
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
302+
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
305303
#[must_use]
306304
pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
307305
Self::new_zeroed_in(Global)
@@ -358,7 +356,6 @@ impl<T> Box<T> {
358356
/// # Ok::<(), std::alloc::AllocError>(())
359357
/// ```
360358
#[unstable(feature = "allocator_api", issue = "32838")]
361-
// #[unstable(feature = "new_uninit", issue = "63291")]
362359
#[inline]
363360
pub fn try_new_uninit() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
364361
Box::try_new_uninit_in(Global)
@@ -384,7 +381,6 @@ impl<T> Box<T> {
384381
///
385382
/// [zeroed]: mem::MaybeUninit::zeroed
386383
#[unstable(feature = "allocator_api", issue = "32838")]
387-
// #[unstable(feature = "new_uninit", issue = "63291")]
388384
#[inline]
389385
pub fn try_new_zeroed() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
390386
Box::try_new_zeroed_in(Global)
@@ -463,7 +459,6 @@ impl<T, A: Allocator> Box<T, A> {
463459
#[unstable(feature = "allocator_api", issue = "32838")]
464460
#[cfg(not(no_global_oom_handling))]
465461
#[must_use]
466-
// #[unstable(feature = "new_uninit", issue = "63291")]
467462
pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
468463
where
469464
A: Allocator,
@@ -496,7 +491,6 @@ impl<T, A: Allocator> Box<T, A> {
496491
/// # Ok::<(), std::alloc::AllocError>(())
497492
/// ```
498493
#[unstable(feature = "allocator_api", issue = "32838")]
499-
// #[unstable(feature = "new_uninit", issue = "63291")]
500494
pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
501495
where
502496
A: Allocator,
@@ -532,7 +526,6 @@ impl<T, A: Allocator> Box<T, A> {
532526
/// [zeroed]: mem::MaybeUninit::zeroed
533527
#[unstable(feature = "allocator_api", issue = "32838")]
534528
#[cfg(not(no_global_oom_handling))]
535-
// #[unstable(feature = "new_uninit", issue = "63291")]
536529
#[must_use]
537530
pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
538531
where
@@ -570,7 +563,6 @@ impl<T, A: Allocator> Box<T, A> {
570563
///
571564
/// [zeroed]: mem::MaybeUninit::zeroed
572565
#[unstable(feature = "allocator_api", issue = "32838")]
573-
// #[unstable(feature = "new_uninit", issue = "63291")]
574566
pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
575567
where
576568
A: Allocator,
@@ -627,6 +619,37 @@ impl<T, A: Allocator> Box<T, A> {
627619
pub fn into_inner(boxed: Self) -> T {
628620
*boxed
629621
}
622+
623+
/// Consumes the `Box` without consuming its allocation, returning the wrapped value and a `Box`
624+
/// to the uninitialized memory where the wrapped value used to live.
625+
///
626+
/// This can be used together with [`write`](Box::write) to reuse the allocation for multiple
627+
/// boxed values.
628+
///
629+
/// # Examples
630+
///
631+
/// ```
632+
/// #![feature(box_take)]
633+
///
634+
/// let c = Box::new(5);
635+
///
636+
/// // take the value out of the box
637+
/// let (value, uninit) = Box::take(c);
638+
/// assert_eq!(value, 5);
639+
///
640+
/// // reuse the box for a second value
641+
/// let c = Box::write(uninit, 6);
642+
/// assert_eq!(*c, 6);
643+
/// ```
644+
#[unstable(feature = "box_take", issue = "147212")]
645+
pub fn take(boxed: Self) -> (T, Box<mem::MaybeUninit<T>, A>) {
646+
unsafe {
647+
let (raw, alloc) = Box::into_raw_with_allocator(boxed);
648+
let value = raw.read();
649+
let uninit = Box::from_raw_in(raw.cast::<mem::MaybeUninit<T>>(), alloc);
650+
(value, uninit)
651+
}
652+
}
630653
}
631654

632655
impl<T> Box<[T]> {
@@ -640,7 +663,7 @@ impl<T> Box<[T]> {
640663
/// values[0].write(1);
641664
/// values[1].write(2);
642665
/// values[2].write(3);
643-
/// let values = unsafe {values.assume_init() };
666+
/// let values = unsafe { values.assume_init() };
644667
///
645668
/// assert_eq!(*values, [1, 2, 3])
646669
/// ```
@@ -660,8 +683,6 @@ impl<T> Box<[T]> {
660683
/// # Examples
661684
///
662685
/// ```
663-
/// #![feature(new_zeroed_alloc)]
664-
///
665686
/// let values = Box::<[u32]>::new_zeroed_slice(3);
666687
/// let values = unsafe { values.assume_init() };
667688
///
@@ -670,7 +691,7 @@ impl<T> Box<[T]> {
670691
///
671692
/// [zeroed]: mem::MaybeUninit::zeroed
672693
#[cfg(not(no_global_oom_handling))]
673-
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
694+
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
674695
#[must_use]
675696
pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
676697
unsafe { RawVec::with_capacity_zeroed(len).into_box(len) }
@@ -785,7 +806,6 @@ impl<T, A: Allocator> Box<[T], A> {
785806
/// ```
786807
#[cfg(not(no_global_oom_handling))]
787808
#[unstable(feature = "allocator_api", issue = "32838")]
788-
// #[unstable(feature = "new_uninit", issue = "63291")]
789809
#[must_use]
790810
pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
791811
unsafe { RawVec::with_capacity_in(len, alloc).into_box(len) }
@@ -813,7 +833,6 @@ impl<T, A: Allocator> Box<[T], A> {
813833
/// [zeroed]: mem::MaybeUninit::zeroed
814834
#[cfg(not(no_global_oom_handling))]
815835
#[unstable(feature = "allocator_api", issue = "32838")]
816-
// #[unstable(feature = "new_uninit", issue = "63291")]
817836
#[must_use]
818837
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
819838
unsafe { RawVec::with_capacity_zeroed_in(len, alloc).into_box(len) }
@@ -1718,7 +1737,7 @@ impl Default for Box<str> {
17181737
}
17191738

17201739
#[cfg(not(no_global_oom_handling))]
1721-
#[stable(feature = "pin_default_impls", since = "CURRENT_RUSTC_VERSION")]
1740+
#[stable(feature = "pin_default_impls", since = "1.91.0")]
17221741
impl<T> Default for Pin<Box<T>>
17231742
where
17241743
T: ?Sized,

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ pub struct BTreeMap<
194194
root: Option<Root<K, V>>,
195195
length: usize,
196196
/// `ManuallyDrop` to control drop order (needs to be dropped after all the nodes).
197+
// Although some of the accessory types store a copy of the allocator, the nodes do not.
198+
// Because allocations will remain live as long as any copy (like this one) of the allocator
199+
// is live, it's unnecessary to store the allocator in each node.
197200
pub(super) alloc: ManuallyDrop<A>,
198201
// For dropck; the `Box` avoids making the `Unpin` impl more strict than before
199202
_marker: PhantomData<crate::boxed::Box<(K, V), A>>,
@@ -546,7 +549,11 @@ impl<K, V: fmt::Debug> fmt::Debug for ValuesMut<'_, K, V> {
546549
/// [`into_keys`]: BTreeMap::into_keys
547550
#[must_use = "iterators are lazy and do nothing unless consumed"]
548551
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
549-
pub struct IntoKeys<K, V, A: Allocator + Clone = Global> {
552+
pub struct IntoKeys<
553+
K,
554+
V,
555+
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global,
556+
> {
550557
inner: IntoIter<K, V, A>,
551558
}
552559

@@ -1433,7 +1440,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
14331440
/// # Examples
14341441
///
14351442
/// ```
1436-
/// #![feature(btree_extract_if)]
14371443
/// use std::collections::BTreeMap;
14381444
///
14391445
/// // Splitting a map into even and odd keys, reusing the original map:
@@ -1450,7 +1456,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
14501456
/// assert_eq!(low.keys().copied().collect::<Vec<_>>(), [0, 1, 2, 3]);
14511457
/// assert_eq!(high.keys().copied().collect::<Vec<_>>(), [4, 5, 6, 7]);
14521458
/// ```
1453-
#[unstable(feature = "btree_extract_if", issue = "70530")]
1459+
#[stable(feature = "btree_extract_if", since = "1.91.0")]
14541460
pub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, K, V, R, F, A>
14551461
where
14561462
K: Ord,
@@ -1937,7 +1943,7 @@ impl<K, V> Default for Values<'_, K, V> {
19371943
}
19381944

19391945
/// An iterator produced by calling `extract_if` on BTreeMap.
1940-
#[unstable(feature = "btree_extract_if", issue = "70530")]
1946+
#[stable(feature = "btree_extract_if", since = "1.91.0")]
19411947
#[must_use = "iterators are lazy and do nothing unless consumed"]
19421948
pub struct ExtractIf<
19431949
'a,
@@ -1970,7 +1976,7 @@ pub(super) struct ExtractIfInner<'a, K, V, R> {
19701976
range: R,
19711977
}
19721978

1973-
#[unstable(feature = "btree_extract_if", issue = "70530")]
1979+
#[stable(feature = "btree_extract_if", since = "1.91.0")]
19741980
impl<K, V, R, F, A> fmt::Debug for ExtractIf<'_, K, V, R, F, A>
19751981
where
19761982
K: fmt::Debug,
@@ -1982,7 +1988,7 @@ where
19821988
}
19831989
}
19841990

1985-
#[unstable(feature = "btree_extract_if", issue = "70530")]
1991+
#[stable(feature = "btree_extract_if", since = "1.91.0")]
19861992
impl<K, V, R, F, A: Allocator + Clone> Iterator for ExtractIf<'_, K, V, R, F, A>
19871993
where
19881994
K: PartialOrd,
@@ -2056,7 +2062,7 @@ impl<'a, K, V, R> ExtractIfInner<'a, K, V, R> {
20562062
}
20572063
}
20582064

2059-
#[unstable(feature = "btree_extract_if", issue = "70530")]
2065+
#[stable(feature = "btree_extract_if", since = "1.91.0")]
20602066
impl<K, V, R, F> FusedIterator for ExtractIf<'_, K, V, R, F>
20612067
where
20622068
K: PartialOrd,
@@ -2407,7 +2413,7 @@ impl<K, V> Default for BTreeMap<K, V> {
24072413
#[stable(feature = "rust1", since = "1.0.0")]
24082414
impl<K: PartialEq, V: PartialEq, A: Allocator + Clone> PartialEq for BTreeMap<K, V, A> {
24092415
fn eq(&self, other: &BTreeMap<K, V, A>) -> bool {
2410-
self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b)
2416+
self.iter().eq(other)
24112417
}
24122418
}
24132419

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ impl<K: Debug + Ord, V: Debug, A: Allocator + Clone> Debug for OccupiedEntry<'_,
9999
///
100100
/// Contains the occupied entry, and the value that was not inserted.
101101
#[unstable(feature = "map_try_insert", issue = "82766")]
102-
pub struct OccupiedError<'a, K: 'a, V: 'a, A: Allocator + Clone = Global> {
102+
pub struct OccupiedError<
103+
'a,
104+
K: 'a,
105+
V: 'a,
106+
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global,
107+
> {
103108
/// The entry in the map that was already occupied.
104109
pub entry: OccupiedEntry<'a, K, V, A>,
105110
/// The value which was not inserted, because the entry was already occupied.
@@ -271,7 +276,6 @@ impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> {
271276
/// # Examples
272277
///
273278
/// ```
274-
/// #![feature(btree_entry_insert)]
275279
/// use std::collections::BTreeMap;
276280
///
277281
/// let mut map: BTreeMap<&str, String> = BTreeMap::new();
@@ -280,7 +284,7 @@ impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> {
280284
/// assert_eq!(entry.key(), &"poneyland");
281285
/// ```
282286
#[inline]
283-
#[unstable(feature = "btree_entry_insert", issue = "65225")]
287+
#[stable(feature = "btree_entry_insert", since = "CURRENT_RUSTC_VERSION")]
284288
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, A> {
285289
match self {
286290
Occupied(mut entry) => {
@@ -379,7 +383,6 @@ impl<'a, K: Ord, V, A: Allocator + Clone> VacantEntry<'a, K, V, A> {
379383
/// # Examples
380384
///
381385
/// ```
382-
/// #![feature(btree_entry_insert)]
383386
/// use std::collections::BTreeMap;
384387
/// use std::collections::btree_map::Entry;
385388
///
@@ -391,7 +394,7 @@ impl<'a, K: Ord, V, A: Allocator + Clone> VacantEntry<'a, K, V, A> {
391394
/// }
392395
/// assert_eq!(map["poneyland"], 37);
393396
/// ```
394-
#[unstable(feature = "btree_entry_insert", issue = "65225")]
397+
#[stable(feature = "btree_entry_insert", since = "CURRENT_RUSTC_VERSION")]
395398
pub fn insert_entry(mut self, value: V) -> OccupiedEntry<'a, K, V, A> {
396399
let handle = match self.handle {
397400
None => {

0 commit comments

Comments
 (0)