Skip to content

Commit bf62129

Browse files
committed
Merge commit '22fc544a713c1182881ce9d487a31ca76886315a' into rust-1.72.0
2 parents ca1749e + 22fc544 commit bf62129

File tree

202 files changed

+3598
-1834
lines changed

Some content is hidden

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

202 files changed

+3598
-1834
lines changed

library/alloc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ compiler-builtins-mem = ['compiler_builtins/mem']
3535
compiler-builtins-c = ["compiler_builtins/c"]
3636
compiler-builtins-no-asm = ["compiler_builtins/no-asm"]
3737
compiler-builtins-mangled-names = ["compiler_builtins/mangled-names"]
38+
compiler-builtins-weak-intrinsics = ["compiler_builtins/weak-intrinsics"]

library/alloc/benches/btree/map.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,15 @@ pub fn clone_slim_100_and_clear(b: &mut Bencher) {
385385
#[bench]
386386
pub fn clone_slim_100_and_drain_all(b: &mut Bencher) {
387387
let src = slim_map(100);
388-
b.iter(|| src.clone().drain_filter(|_, _| true).count())
388+
b.iter(|| src.clone().extract_if(|_, _| true).count())
389389
}
390390

391391
#[bench]
392392
pub fn clone_slim_100_and_drain_half(b: &mut Bencher) {
393393
let src = slim_map(100);
394394
b.iter(|| {
395395
let mut map = src.clone();
396-
assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 100 / 2);
396+
assert_eq!(map.extract_if(|i, _| i % 2 == 0).count(), 100 / 2);
397397
assert_eq!(map.len(), 100 / 2);
398398
})
399399
}
@@ -456,15 +456,15 @@ pub fn clone_slim_10k_and_clear(b: &mut Bencher) {
456456
#[bench]
457457
pub fn clone_slim_10k_and_drain_all(b: &mut Bencher) {
458458
let src = slim_map(10_000);
459-
b.iter(|| src.clone().drain_filter(|_, _| true).count())
459+
b.iter(|| src.clone().extract_if(|_, _| true).count())
460460
}
461461

462462
#[bench]
463463
pub fn clone_slim_10k_and_drain_half(b: &mut Bencher) {
464464
let src = slim_map(10_000);
465465
b.iter(|| {
466466
let mut map = src.clone();
467-
assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 10_000 / 2);
467+
assert_eq!(map.extract_if(|i, _| i % 2 == 0).count(), 10_000 / 2);
468468
assert_eq!(map.len(), 10_000 / 2);
469469
})
470470
}
@@ -527,15 +527,15 @@ pub fn clone_fat_val_100_and_clear(b: &mut Bencher) {
527527
#[bench]
528528
pub fn clone_fat_val_100_and_drain_all(b: &mut Bencher) {
529529
let src = fat_val_map(100);
530-
b.iter(|| src.clone().drain_filter(|_, _| true).count())
530+
b.iter(|| src.clone().extract_if(|_, _| true).count())
531531
}
532532

533533
#[bench]
534534
pub fn clone_fat_val_100_and_drain_half(b: &mut Bencher) {
535535
let src = fat_val_map(100);
536536
b.iter(|| {
537537
let mut map = src.clone();
538-
assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 100 / 2);
538+
assert_eq!(map.extract_if(|i, _| i % 2 == 0).count(), 100 / 2);
539539
assert_eq!(map.len(), 100 / 2);
540540
})
541541
}

library/alloc/benches/btree/set.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ pub fn clone_100_and_clear(b: &mut Bencher) {
6969
#[bench]
7070
pub fn clone_100_and_drain_all(b: &mut Bencher) {
7171
let src = slim_set(100);
72-
b.iter(|| src.clone().drain_filter(|_| true).count())
72+
b.iter(|| src.clone().extract_if(|_| true).count())
7373
}
7474

7575
#[bench]
7676
pub fn clone_100_and_drain_half(b: &mut Bencher) {
7777
let src = slim_set(100);
7878
b.iter(|| {
7979
let mut set = src.clone();
80-
assert_eq!(set.drain_filter(|i| i % 2 == 0).count(), 100 / 2);
80+
assert_eq!(set.extract_if(|i| i % 2 == 0).count(), 100 / 2);
8181
assert_eq!(set.len(), 100 / 2);
8282
})
8383
}
@@ -140,15 +140,15 @@ pub fn clone_10k_and_clear(b: &mut Bencher) {
140140
#[bench]
141141
pub fn clone_10k_and_drain_all(b: &mut Bencher) {
142142
let src = slim_set(10_000);
143-
b.iter(|| src.clone().drain_filter(|_| true).count())
143+
b.iter(|| src.clone().extract_if(|_| true).count())
144144
}
145145

146146
#[bench]
147147
pub fn clone_10k_and_drain_half(b: &mut Bencher) {
148148
let src = slim_set(10_000);
149149
b.iter(|| {
150150
let mut set = src.clone();
151-
assert_eq!(set.drain_filter(|i| i % 2 == 0).count(), 10_000 / 2);
151+
assert_eq!(set.extract_if(|i| i % 2 == 0).count(), 10_000 / 2);
152152
assert_eq!(set.len(), 10_000 / 2);
153153
})
154154
}

library/alloc/benches/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Disabling on android for the time being
22
// See https://github.com/rust-lang/rust/issues/73535#event-3477699747
33
#![cfg(not(target_os = "android"))]
4-
#![feature(btree_drain_filter)]
4+
#![feature(btree_extract_if)]
55
#![feature(iter_next_chunk)]
66
#![feature(repr_simd)]
77
#![feature(slice_partition_dedup)]

library/alloc/src/alloc.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
#[cfg(not(test))]
66
use core::intrinsics;
7+
#[cfg(all(bootstrap, not(test)))]
78
use core::intrinsics::{min_align_of_val, size_of_val};
89

10+
#[cfg(all(bootstrap, not(test)))]
911
use core::ptr::Unique;
1012
#[cfg(not(test))]
1113
use core::ptr::{self, NonNull};
@@ -38,7 +40,6 @@ extern "Rust" {
3840
#[rustc_nounwind]
3941
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
4042

41-
#[cfg(not(bootstrap))]
4243
static __rust_no_alloc_shim_is_unstable: u8;
4344
}
4445

@@ -96,7 +97,6 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 {
9697
unsafe {
9798
// Make sure we don't accidentally allow omitting the allocator shim in
9899
// stable code until it is actually stabilized.
99-
#[cfg(not(bootstrap))]
100100
core::ptr::read_volatile(&__rust_no_alloc_shim_is_unstable);
101101

102102
__rust_alloc(layout.size(), layout.align())
@@ -337,14 +337,15 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
337337
}
338338
}
339339

340-
#[cfg_attr(not(test), lang = "box_free")]
340+
#[cfg(all(bootstrap, not(test)))]
341+
#[lang = "box_free"]
341342
#[inline]
342343
// This signature has to be the same as `Box`, otherwise an ICE will happen.
343344
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
344345
// well.
345346
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
346347
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
347-
pub(crate) unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: Unique<T>, alloc: A) {
348+
unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: Unique<T>, alloc: A) {
348349
unsafe {
349350
let size = size_of_val(ptr.as_ref());
350351
let align = min_align_of_val(ptr.as_ref());

library/alloc/src/boxed.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,8 +1211,16 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
12111211

12121212
#[stable(feature = "rust1", since = "1.0.0")]
12131213
unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Box<T, A> {
1214+
#[inline]
12141215
fn drop(&mut self) {
1215-
// FIXME: Do nothing, drop is currently performed by compiler.
1216+
// the T in the Box is dropped by the compiler before the destructor is run
1217+
1218+
let ptr = self.0;
1219+
1220+
unsafe {
1221+
let layout = Layout::for_value_raw(ptr.as_ptr());
1222+
self.1.deallocate(From::from(ptr.cast()), layout)
1223+
}
12161224
}
12171225
}
12181226

0 commit comments

Comments
 (0)