remove box_free and replace with drop impl

This commit is contained in:
DrMeepster 2022-08-01 13:51:58 -07:00
parent 81ea0b29ea
commit f429b3e67f

View File

@ -546,7 +546,8 @@ pub fn new(val: T) -> Box<T> {
impl<T: ?Sized, A> Drop for Box<T, A> { impl<T: ?Sized, A> Drop for Box<T, A> {
fn drop(&mut self) { fn drop(&mut self) {
// drop is currently performed by compiler. // inner value is dropped by compiler
libc::free(self.0.pointer.0 as *mut u8);
} }
} }
@ -563,11 +564,6 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
libc::malloc(size) libc::malloc(size)
} }
#[lang = "box_free"]
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, _alloc: ()) {
libc::free(ptr.pointer.0 as *mut u8);
}
#[lang = "drop"] #[lang = "drop"]
pub trait Drop { pub trait Drop {
fn drop(&mut self); fn drop(&mut self);