From 3e4ddca409c0b01d2981fe9e5a15c03cd41f1b24 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 5 Aug 2020 13:55:27 +0200 Subject: Rustup to rustc 1.47.0-nightly (f9d422ea7 2020-08-04) --- build_sysroot/alloc_system/lib.rs | 96 --------------------------------------- 1 file changed, 96 deletions(-) (limited to 'build_sysroot/alloc_system') diff --git a/build_sysroot/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs index bb0ceb229f4..e80a584e981 100644 --- a/build_sysroot/alloc_system/lib.rs +++ b/build_sysroot/alloc_system/lib.rs @@ -72,102 +72,6 @@ use core::intrinsics; /// independently of the standard library’s global allocator. #[stable(feature = "alloc_system_type", since = "1.28.0")] pub struct System; -#[unstable(feature = "allocator_api", issue = "32838")] -unsafe impl AllocRef for System { - #[inline] - fn alloc(&mut self, layout: Layout, init: AllocInit) -> Result { - unsafe { - let size = layout.size(); - if size == 0 { - Ok(MemoryBlock { ptr: layout.dangling(), size: 0 }) - } else { - let raw_ptr = match init { - AllocInit::Uninitialized => GlobalAlloc::alloc(self, layout), - AllocInit::Zeroed => GlobalAlloc::alloc_zeroed(self, layout), - }; - let ptr = NonNull::new(raw_ptr).ok_or(AllocErr)?; - Ok(MemoryBlock { ptr, size }) - } - } - } - - #[inline] - unsafe fn dealloc(&mut self, ptr: NonNull, layout: Layout) { - if layout.size() != 0 { - GlobalAlloc::dealloc(self, ptr.as_ptr(), layout) - } - } - - #[inline] - unsafe fn grow( - &mut self, - ptr: NonNull, - layout: Layout, - new_size: usize, - placement: ReallocPlacement, - init: AllocInit, - ) -> Result { - let size = layout.size(); - debug_assert!( - new_size >= size, - "`new_size` must be greater than or equal to `memory.size()`" - ); - - if size == new_size { - return Ok(MemoryBlock { ptr, size }); - } - - match placement { - ReallocPlacement::InPlace => Err(AllocErr), - ReallocPlacement::MayMove if layout.size() == 0 => { - let new_layout = Layout::from_size_align_unchecked(new_size, layout.align()); - self.alloc(new_layout, init) - } - ReallocPlacement::MayMove => { - // `realloc` probably checks for `new_size > size` or something similar. - intrinsics::assume(new_size > size); - let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size); - let memory = - MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }; - init.init_offset(memory, size); - Ok(memory) - } - } - } - - #[inline] - unsafe fn shrink( - &mut self, - ptr: NonNull, - layout: Layout, - new_size: usize, - placement: ReallocPlacement, - ) -> Result { - let size = layout.size(); - debug_assert!( - new_size <= size, - "`new_size` must be smaller than or equal to `memory.size()`" - ); - - if size == new_size { - return Ok(MemoryBlock { ptr, size }); - } - - match placement { - ReallocPlacement::InPlace => Err(AllocErr), - ReallocPlacement::MayMove if new_size == 0 => { - self.dealloc(ptr, layout); - Ok(MemoryBlock { ptr: layout.dangling(), size: 0 }) - } - ReallocPlacement::MayMove => { - // `realloc` probably checks for `new_size < size` or something similar. - intrinsics::assume(new_size < size); - let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size); - Ok(MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }) - } - } - } -} #[cfg(any(windows, unix, target_os = "cloudabi", target_os = "redox"))] mod realloc_fallback { use core::alloc::{GlobalAlloc, Layout}; -- cgit 1.4.1-3-g733a5