diff options
| author | David Tolnay <dtolnay@gmail.com> | 2019-11-24 01:43:32 -0800 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2019-11-26 23:02:11 -0800 |
| commit | 95e00bfed801e264e9c4ac817004153ca0f19eb6 (patch) | |
| tree | 79549f727c3fc8bb0b09779a7dc3f94df43654f2 /src/libcore/ptr | |
| parent | 809e180a76ce97340bf4354ff357bc59e3ca40b2 (diff) | |
Format libcore with rustfmt
This commit applies rustfmt with default settings to files in
src/libcore *that are not involved in any currently open PR* to minimize
merge conflicts. The list of files involved in open PRs was determined
by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8
With the list of files from the script in `outstanding_files`, the
relevant commands were:
$ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018
$ rg libcore outstanding_files | xargs git checkout --
Repeating this process several months apart should get us coverage of
most of the rest of libcore.
Diffstat (limited to 'src/libcore/ptr')
| -rw-r--r-- | src/libcore/ptr/non_null.rs | 24 | ||||
| -rw-r--r-- | src/libcore/ptr/unique.rs | 29 |
2 files changed, 23 insertions, 30 deletions
diff --git a/src/libcore/ptr/non_null.rs b/src/libcore/ptr/non_null.rs index 7599991f0f1..a121389bef3 100644 --- a/src/libcore/ptr/non_null.rs +++ b/src/libcore/ptr/non_null.rs @@ -1,11 +1,11 @@ +use crate::cmp::Ordering; use crate::convert::From; -use crate::ops::{CoerceUnsized, DispatchFromDyn}; use crate::fmt; use crate::hash; use crate::marker::Unsize; use crate::mem; +use crate::ops::{CoerceUnsized, DispatchFromDyn}; use crate::ptr::Unique; -use crate::cmp::Ordering; // ignore-tidy-undocumented-unsafe @@ -48,12 +48,12 @@ pub struct NonNull<T: ?Sized> { /// `NonNull` pointers are not `Send` because the data they reference may be aliased. // N.B., this impl is unnecessary, but should provide better error messages. #[stable(feature = "nonnull", since = "1.25.0")] -impl<T: ?Sized> !Send for NonNull<T> { } +impl<T: ?Sized> !Send for NonNull<T> {} /// `NonNull` pointers are not `Sync` because the data they reference may be aliased. // N.B., this impl is unnecessary, but should provide better error messages. #[stable(feature = "nonnull", since = "1.25.0")] -impl<T: ?Sized> !Sync for NonNull<T> { } +impl<T: ?Sized> !Sync for NonNull<T> {} impl<T: Sized> NonNull<T> { /// Creates a new `NonNull` that is dangling, but well-aligned. @@ -91,11 +91,7 @@ impl<T: ?Sized> NonNull<T> { #[stable(feature = "nonnull", since = "1.25.0")] #[inline] pub fn new(ptr: *mut T) -> Option<Self> { - if !ptr.is_null() { - Some(unsafe { Self::new_unchecked(ptr) }) - } else { - None - } + if !ptr.is_null() { Some(unsafe { Self::new_unchecked(ptr) }) } else { None } } /// Acquires the underlying `*mut` pointer. @@ -131,9 +127,7 @@ impl<T: ?Sized> NonNull<T> { #[stable(feature = "nonnull_cast", since = "1.27.0")] #[inline] pub const fn cast<U>(self) -> NonNull<U> { - unsafe { - NonNull::new_unchecked(self.as_ptr() as *mut U) - } + unsafe { NonNull::new_unchecked(self.as_ptr() as *mut U) } } } @@ -146,13 +140,13 @@ impl<T: ?Sized> Clone for NonNull<T> { } #[stable(feature = "nonnull", since = "1.25.0")] -impl<T: ?Sized> Copy for NonNull<T> { } +impl<T: ?Sized> Copy for NonNull<T> {} #[unstable(feature = "coerce_unsized", issue = "27732")] -impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> { } +impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {} #[unstable(feature = "dispatch_from_dyn", issue = "0")] -impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> { } +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {} #[stable(feature = "nonnull", since = "1.25.0")] impl<T: ?Sized> fmt::Debug for NonNull<T> { diff --git a/src/libcore/ptr/unique.rs b/src/libcore/ptr/unique.rs index 11a3aed1ab4..546b7c9d777 100644 --- a/src/libcore/ptr/unique.rs +++ b/src/libcore/ptr/unique.rs @@ -1,8 +1,8 @@ use crate::convert::From; -use crate::ops::{CoerceUnsized, DispatchFromDyn}; use crate::fmt; use crate::marker::{PhantomData, Unsize}; use crate::mem; +use crate::ops::{CoerceUnsized, DispatchFromDyn}; use crate::ptr::NonNull; // ignore-tidy-undocumented-unsafe @@ -27,9 +27,12 @@ use crate::ptr::NonNull; /// /// Unlike `*mut T`, `Unique<T>` is covariant over `T`. This should always be correct /// for any type which upholds Unique's aliasing requirements. -#[unstable(feature = "ptr_internals", issue = "0", - reason = "use `NonNull` instead and consider `PhantomData<T>` \ - (if you also use `#[may_dangle]`), `Send`, and/or `Sync`")] +#[unstable( + feature = "ptr_internals", + issue = "0", + reason = "use `NonNull` instead and consider `PhantomData<T>` \ + (if you also use `#[may_dangle]`), `Send`, and/or `Sync`" +)] #[doc(hidden)] #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(1)] @@ -48,14 +51,14 @@ pub struct Unique<T: ?Sized> { /// unenforced by the type system; the abstraction using the /// `Unique` must enforce it. #[unstable(feature = "ptr_internals", issue = "0")] -unsafe impl<T: Send + ?Sized> Send for Unique<T> { } +unsafe impl<T: Send + ?Sized> Send for Unique<T> {} /// `Unique` pointers are `Sync` if `T` is `Sync` because the data they /// reference is unaliased. Note that this aliasing invariant is /// unenforced by the type system; the abstraction using the /// `Unique` must enforce it. #[unstable(feature = "ptr_internals", issue = "0")] -unsafe impl<T: Sync + ?Sized> Sync for Unique<T> { } +unsafe impl<T: Sync + ?Sized> Sync for Unique<T> {} #[unstable(feature = "ptr_internals", issue = "0")] impl<T: Sized> Unique<T> { @@ -71,9 +74,7 @@ impl<T: Sized> Unique<T> { // FIXME: rename to dangling() to match NonNull? #[inline] pub const fn empty() -> Self { - unsafe { - Unique::new_unchecked(mem::align_of::<T>() as *mut T) - } + unsafe { Unique::new_unchecked(mem::align_of::<T>() as *mut T) } } } @@ -128,9 +129,7 @@ impl<T: ?Sized> Unique<T> { /// Casts to a pointer of another type. #[inline] pub const fn cast<U>(self) -> Unique<U> { - unsafe { - Unique::new_unchecked(self.as_ptr() as *mut U) - } + unsafe { Unique::new_unchecked(self.as_ptr() as *mut U) } } } @@ -143,13 +142,13 @@ impl<T: ?Sized> Clone for Unique<T> { } #[unstable(feature = "ptr_internals", issue = "0")] -impl<T: ?Sized> Copy for Unique<T> { } +impl<T: ?Sized> Copy for Unique<T> {} #[unstable(feature = "ptr_internals", issue = "0")] -impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> { } +impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {} #[unstable(feature = "ptr_internals", issue = "0")] -impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> { } +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {} #[unstable(feature = "ptr_internals", issue = "0")] impl<T: ?Sized> fmt::Debug for Unique<T> { |
