Skip to content

Commit 876a7d8

Browse files
committed
Auto merge of #100036 - DrMeepster:box_free_free_box, r=oli-obk
Remove `box_free` lang item This PR removes the `box_free` lang item, replacing it with `Box`'s `Drop` impl. Box dropping is still slightly magic because the contained value is still dropped by the compiler.
2 parents 9176f51 + ec10051 commit 876a7d8

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

example/mini_core.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> fo
490490

491491
impl<T: ?Sized, A: Allocator> Drop for Box<T, A> {
492492
fn drop(&mut self) {
493-
// drop is currently performed by compiler.
493+
// inner value is dropped by compiler
494+
libc::free(self.pointer.0 as *mut u8);
494495
}
495496
}
496497

@@ -507,11 +508,6 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
507508
libc::malloc(size)
508509
}
509510

510-
#[lang = "box_free"]
511-
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, _alloc: ()) {
512-
libc::free(ptr.pointer.0 as *mut u8);
513-
}
514-
515511
#[lang = "drop"]
516512
pub trait Drop {
517513
fn drop(&mut self);

0 commit comments

Comments
 (0)