diff options
| author | bors <bors@rust-lang.org> | 2019-12-23 02:47:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-23 02:47:52 +0000 |
| commit | a916ac22b9f7f1f0f7aba0a41a789b3ecd765018 (patch) | |
| tree | 139cba4184f0f290fdbdff1aa0aa68352b16ccbb /src/libstd/alloc.rs | |
| parent | 9b98af84c4aa66392236fff59c86da2130d46d46 (diff) | |
| parent | 0f24ccd21d9f734a21daaf3566900127167556d1 (diff) | |
| download | rust-a916ac22b9f7f1f0f7aba0a41a789b3ecd765018.tar.gz rust-a916ac22b9f7f1f0f7aba0a41a789b3ecd765018.zip | |
Auto merge of #67540 - Mark-Simulacrum:fmt-the-world, r=Centril
Format the world This PR modifies the formatting infrastructure a bit in the first commit (to enable the forgotten 2018 edition), as well as removes most directories from the ignore list in rustfmt.toml. It then follows that up with the second commit which runs `x.py fmt` and formats the entire repository. We continue to not format the test directory (`src/test`) because of interactions with pretty printing and, in part, because re-blessing all of those files is somewhat harder to review, so is best suited for a follow up PR in my opinion.
Diffstat (limited to 'src/libstd/alloc.rs')
| -rw-r--r-- | src/libstd/alloc.rs | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/src/libstd/alloc.rs b/src/libstd/alloc.rs index eccf8cabf22..7fd55af1694 100644 --- a/src/libstd/alloc.rs +++ b/src/libstd/alloc.rs @@ -61,9 +61,9 @@ #![stable(feature = "alloc_module", since = "1.28.0")] +use core::ptr::NonNull; use core::sync::atomic::{AtomicPtr, Ordering}; use core::{mem, ptr}; -use core::ptr::NonNull; use crate::sys_common::util::dumb_print; @@ -152,10 +152,12 @@ unsafe impl Alloc for System { } #[inline] - unsafe fn realloc(&mut self, - ptr: NonNull<u8>, - layout: Layout, - new_size: usize) -> Result<NonNull<u8>, AllocErr> { + unsafe fn realloc( + &mut self, + ptr: NonNull<u8>, + layout: Layout, + new_size: usize, + ) -> Result<NonNull<u8>, AllocErr> { NonNull::new(GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size)).ok_or(AllocErr) } } @@ -191,11 +193,7 @@ pub fn set_alloc_error_hook(hook: fn(Layout)) { #[unstable(feature = "alloc_error_hook", issue = "51245")] pub fn take_alloc_error_hook() -> fn(Layout) { let hook = HOOK.swap(ptr::null_mut(), Ordering::SeqCst); - if hook.is_null() { - default_alloc_error_hook - } else { - unsafe { mem::transmute(hook) } - } + if hook.is_null() { default_alloc_error_hook } else { unsafe { mem::transmute(hook) } } } fn default_alloc_error_hook(layout: Layout) { @@ -208,13 +206,12 @@ fn default_alloc_error_hook(layout: Layout) { #[unstable(feature = "alloc_internals", issue = "none")] pub fn rust_oom(layout: Layout) -> ! { let hook = HOOK.load(Ordering::SeqCst); - let hook: fn(Layout) = if hook.is_null() { - default_alloc_error_hook - } else { - unsafe { mem::transmute(hook) } - }; + let hook: fn(Layout) = + if hook.is_null() { default_alloc_error_hook } else { unsafe { mem::transmute(hook) } }; hook(layout); - unsafe { crate::sys::abort_internal(); } + unsafe { + crate::sys::abort_internal(); + } } #[cfg(not(test))] @@ -222,7 +219,7 @@ pub fn rust_oom(layout: Layout) -> ! { #[allow(unused_attributes)] #[unstable(feature = "alloc_internals", issue = "none")] pub mod __default_lib_allocator { - use super::{System, Layout, GlobalAlloc}; + use super::{GlobalAlloc, Layout, System}; // These magic symbol names are used as a fallback for implementing the // `__rust_alloc` etc symbols (see `src/liballoc/alloc.rs) when there is // no `#[global_allocator]` attribute. @@ -234,29 +231,29 @@ pub mod __default_lib_allocator { // ABI #[rustc_std_internal_symbol] - pub unsafe extern fn __rdl_alloc(size: usize, align: usize) -> *mut u8 { + pub unsafe extern "C" fn __rdl_alloc(size: usize, align: usize) -> *mut u8 { let layout = Layout::from_size_align_unchecked(size, align); System.alloc(layout) } #[rustc_std_internal_symbol] - pub unsafe extern fn __rdl_dealloc(ptr: *mut u8, - size: usize, - align: usize) { + pub unsafe extern "C" fn __rdl_dealloc(ptr: *mut u8, size: usize, align: usize) { System.dealloc(ptr, Layout::from_size_align_unchecked(size, align)) } #[rustc_std_internal_symbol] - pub unsafe extern fn __rdl_realloc(ptr: *mut u8, - old_size: usize, - align: usize, - new_size: usize) -> *mut u8 { + pub unsafe extern "C" fn __rdl_realloc( + ptr: *mut u8, + old_size: usize, + align: usize, + new_size: usize, + ) -> *mut u8 { let old_layout = Layout::from_size_align_unchecked(old_size, align); System.realloc(ptr, old_layout, new_size) } #[rustc_std_internal_symbol] - pub unsafe extern fn __rdl_alloc_zeroed(size: usize, align: usize) -> *mut u8 { + pub unsafe extern "C" fn __rdl_alloc_zeroed(size: usize, align: usize) -> *mut u8 { let layout = Layout::from_size_align_unchecked(size, align); System.alloc_zeroed(layout) } |
