diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:04 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:47 -0500 |
| commit | a06baa56b95674fc626b3c3fd680d6a65357fe60 (patch) | |
| tree | cd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libcore/ptr | |
| parent | 8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff) | |
| download | rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip | |
Format the world
Diffstat (limited to 'src/libcore/ptr')
| -rw-r--r-- | src/libcore/ptr/const_ptr.rs | 80 | ||||
| -rw-r--r-- | src/libcore/ptr/mod.rs | 4 | ||||
| -rw-r--r-- | src/libcore/ptr/mut_ptr.rs | 112 |
3 files changed, 108 insertions, 88 deletions
diff --git a/src/libcore/ptr/const_ptr.rs b/src/libcore/ptr/const_ptr.rs index be2b7ff5f77..e5297a0c1e0 100644 --- a/src/libcore/ptr/const_ptr.rs +++ b/src/libcore/ptr/const_ptr.rs @@ -1,7 +1,7 @@ -use crate::cmp::Ordering::{self, Less, Equal, Greater}; +use super::*; +use crate::cmp::Ordering::{self, Equal, Greater, Less}; use crate::intrinsics; use crate::mem; -use super::*; // ignore-tidy-undocumented-unsafe @@ -154,8 +154,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn offset(self, count: isize) -> *const T - where - T: Sized, + where + T: Sized, { intrinsics::offset(self, count) } @@ -212,8 +212,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "ptr_wrapping_offset", since = "1.16.0")] #[inline] pub fn wrapping_offset(self, count: isize) -> *const T - where - T: Sized, + where + T: Sized, { unsafe { intrinsics::arith_offset(self, count) } } @@ -284,8 +284,8 @@ impl<T: ?Sized> *const T { #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "41079")] #[inline] pub const unsafe fn offset_from(self, origin: *const T) -> isize - where - T: Sized, + where + T: Sized, { let pointee_size = mem::size_of::<T>(); let ok = 0 < pointee_size && pointee_size <= isize::max_value() as usize; @@ -332,8 +332,8 @@ impl<T: ?Sized> *const T { #[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")] #[inline] pub fn wrapping_offset_from(self, origin: *const T) -> isize - where - T: Sized, + where + T: Sized, { let pointee_size = mem::size_of::<T>(); assert!(0 < pointee_size && pointee_size <= isize::max_value() as usize); @@ -396,8 +396,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn add(self, count: usize) -> Self - where - T: Sized, + where + T: Sized, { self.offset(count as isize) } @@ -457,8 +457,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn sub(self, count: usize) -> Self - where - T: Sized, + where + T: Sized, { self.offset((count as isize).wrapping_neg()) } @@ -512,8 +512,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub fn wrapping_add(self, count: usize) -> Self - where - T: Sized, + where + T: Sized, { self.wrapping_offset(count as isize) } @@ -567,8 +567,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub fn wrapping_sub(self, count: usize) -> Self - where - T: Sized, + where + T: Sized, { self.wrapping_offset((count as isize).wrapping_neg()) } @@ -582,8 +582,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read(self) -> T - where - T: Sized, + where + T: Sized, { read(self) } @@ -601,8 +601,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read_volatile(self) -> T - where - T: Sized, + where + T: Sized, { read_volatile(self) } @@ -618,8 +618,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read_unaligned(self) -> T - where - T: Sized, + where + T: Sized, { read_unaligned(self) } @@ -635,8 +635,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_to(self, dest: *mut T, count: usize) - where - T: Sized, + where + T: Sized, { copy(self, dest, count) } @@ -652,8 +652,8 @@ impl<T: ?Sized> *const T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) - where - T: Sized, + where + T: Sized, { copy_nonoverlapping(self, dest, count) } @@ -699,8 +699,8 @@ impl<T: ?Sized> *const T { /// ``` #[stable(feature = "align_offset", since = "1.36.0")] pub fn align_offset(self, align: usize) -> usize - where - T: Sized, + where + T: Sized, { if !align.is_power_of_two() { panic!("align_offset: align is not a power-of-two"); @@ -713,7 +713,9 @@ impl<T: ?Sized> *const T { #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> PartialEq for *const T { #[inline] - fn eq(&self, other: &*const T) -> bool { *self == *other } + fn eq(&self, other: &*const T) -> bool { + *self == *other + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -742,14 +744,22 @@ impl<T: ?Sized> PartialOrd for *const T { } #[inline] - fn lt(&self, other: &*const T) -> bool { *self < *other } + fn lt(&self, other: &*const T) -> bool { + *self < *other + } #[inline] - fn le(&self, other: &*const T) -> bool { *self <= *other } + fn le(&self, other: &*const T) -> bool { + *self <= *other + } #[inline] - fn gt(&self, other: &*const T) -> bool { *self > *other } + fn gt(&self, other: &*const T) -> bool { + *self > *other + } #[inline] - fn ge(&self, other: &*const T) -> bool { *self >= *other } + fn ge(&self, other: &*const T) -> bool { + *self >= *other + } } diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index d42b673ff65..d7b351f1345 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -69,11 +69,11 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::intrinsics; +use crate::cmp::Ordering; use crate::fmt; use crate::hash; +use crate::intrinsics; use crate::mem::{self, MaybeUninit}; -use crate::cmp::Ordering; #[stable(feature = "rust1", since = "1.0.0")] pub use crate::intrinsics::copy_nonoverlapping; diff --git a/src/libcore/ptr/mut_ptr.rs b/src/libcore/ptr/mut_ptr.rs index fd5decbd7ea..b3bb2f179b1 100644 --- a/src/libcore/ptr/mut_ptr.rs +++ b/src/libcore/ptr/mut_ptr.rs @@ -1,6 +1,6 @@ -use crate::cmp::Ordering::{self, Less, Equal, Greater}; -use crate::intrinsics; use super::*; +use crate::cmp::Ordering::{self, Equal, Greater, Less}; +use crate::intrinsics; // ignore-tidy-undocumented-unsafe @@ -148,8 +148,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn offset(self, count: isize) -> *mut T - where - T: Sized, + where + T: Sized, { intrinsics::offset(self, count) as *mut T } @@ -205,8 +205,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "ptr_wrapping_offset", since = "1.16.0")] #[inline] pub fn wrapping_offset(self, count: isize) -> *mut T - where - T: Sized, + where + T: Sized, { unsafe { intrinsics::arith_offset(self, count) as *mut T } } @@ -322,8 +322,8 @@ impl<T: ?Sized> *mut T { #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "41079")] #[inline] pub const unsafe fn offset_from(self, origin: *const T) -> isize - where - T: Sized, + where + T: Sized, { (self as *const T).offset_from(origin) } @@ -365,8 +365,8 @@ impl<T: ?Sized> *mut T { #[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")] #[inline] pub fn wrapping_offset_from(self, origin: *const T) -> isize - where - T: Sized, + where + T: Sized, { (self as *const T).wrapping_offset_from(origin) } @@ -425,8 +425,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn add(self, count: usize) -> Self - where - T: Sized, + where + T: Sized, { self.offset(count as isize) } @@ -486,8 +486,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn sub(self, count: usize) -> Self - where - T: Sized, + where + T: Sized, { self.offset((count as isize).wrapping_neg()) } @@ -541,8 +541,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub fn wrapping_add(self, count: usize) -> Self - where - T: Sized, + where + T: Sized, { self.wrapping_offset(count as isize) } @@ -596,8 +596,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub fn wrapping_sub(self, count: usize) -> Self - where - T: Sized, + where + T: Sized, { self.wrapping_offset((count as isize).wrapping_neg()) } @@ -611,8 +611,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read(self) -> T - where - T: Sized, + where + T: Sized, { read(self) } @@ -630,8 +630,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read_volatile(self) -> T - where - T: Sized, + where + T: Sized, { read_volatile(self) } @@ -647,8 +647,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read_unaligned(self) -> T - where - T: Sized, + where + T: Sized, { read_unaligned(self) } @@ -664,8 +664,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_to(self, dest: *mut T, count: usize) - where - T: Sized, + where + T: Sized, { copy(self, dest, count) } @@ -681,8 +681,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) - where - T: Sized, + where + T: Sized, { copy_nonoverlapping(self, dest, count) } @@ -698,8 +698,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_from(self, src: *const T, count: usize) - where - T: Sized, + where + T: Sized, { copy(src, self, count) } @@ -715,8 +715,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize) - where - T: Sized, + where + T: Sized, { copy_nonoverlapping(src, self, count) } @@ -741,8 +741,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn write(self, val: T) - where - T: Sized, + where + T: Sized, { write(self, val) } @@ -756,8 +756,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn write_bytes(self, val: u8, count: usize) - where - T: Sized, + where + T: Sized, { write_bytes(self, val, count) } @@ -775,8 +775,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn write_volatile(self, val: T) - where - T: Sized, + where + T: Sized, { write_volatile(self, val) } @@ -792,8 +792,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn write_unaligned(self, val: T) - where - T: Sized, + where + T: Sized, { write_unaligned(self, val) } @@ -807,8 +807,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn replace(self, src: T) -> T - where - T: Sized, + where + T: Sized, { replace(self, src) } @@ -823,8 +823,8 @@ impl<T: ?Sized> *mut T { #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn swap(self, with: *mut T) - where - T: Sized, + where + T: Sized, { swap(self, with) } @@ -870,8 +870,8 @@ impl<T: ?Sized> *mut T { /// ``` #[stable(feature = "align_offset", since = "1.36.0")] pub fn align_offset(self, align: usize) -> usize - where - T: Sized, + where + T: Sized, { if !align.is_power_of_two() { panic!("align_offset: align is not a power-of-two"); @@ -884,7 +884,9 @@ impl<T: ?Sized> *mut T { #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> PartialEq for *mut T { #[inline] - fn eq(&self, other: &*mut T) -> bool { *self == *other } + fn eq(&self, other: &*mut T) -> bool { + *self == *other + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -912,14 +914,22 @@ impl<T: ?Sized> PartialOrd for *mut T { } #[inline] - fn lt(&self, other: &*mut T) -> bool { *self < *other } + fn lt(&self, other: &*mut T) -> bool { + *self < *other + } #[inline] - fn le(&self, other: &*mut T) -> bool { *self <= *other } + fn le(&self, other: &*mut T) -> bool { + *self <= *other + } #[inline] - fn gt(&self, other: &*mut T) -> bool { *self > *other } + fn gt(&self, other: &*mut T) -> bool { + *self > *other + } #[inline] - fn ge(&self, other: &*mut T) -> bool { *self >= *other } + fn ge(&self, other: &*mut T) -> bool { + *self >= *other + } } |
