about summary refs log tree commit diff
path: root/src/libcore/array
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-23 02:47:52 +0000
committerbors <bors@rust-lang.org>2019-12-23 02:47:52 +0000
commita916ac22b9f7f1f0f7aba0a41a789b3ecd765018 (patch)
tree139cba4184f0f290fdbdff1aa0aa68352b16ccbb /src/libcore/array
parent9b98af84c4aa66392236fff59c86da2130d46d46 (diff)
parent0f24ccd21d9f734a21daaf3566900127167556d1 (diff)
downloadrust-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/libcore/array')
-rw-r--r--src/libcore/array/iter.rs54
-rw-r--r--src/libcore/array/mod.rs21
2 files changed, 28 insertions, 47 deletions
diff --git a/src/libcore/array/iter.rs b/src/libcore/array/iter.rs
index aab9463e3aa..80eaae0d4af 100644
--- a/src/libcore/array/iter.rs
+++ b/src/libcore/array/iter.rs
@@ -1,5 +1,6 @@
 //! Defines the `IntoIter` owned iterator for arrays.
 
+use super::LengthAtMost32;
 use crate::{
     fmt,
     iter::{ExactSizeIterator, FusedIterator, TrustedLen},
@@ -7,8 +8,6 @@ use crate::{
     ops::Range,
     ptr,
 };
-use super::LengthAtMost32;
-
 
 /// A by-value [array] iterator.
 ///
@@ -40,7 +39,7 @@ where
     alive: Range<usize>,
 }
 
-impl<T, const N: usize> IntoIter<T, {N}>
+impl<T, const N: usize> IntoIter<T, { N }>
 where
     [T; N]: LengthAtMost32,
 {
@@ -75,10 +74,7 @@ where
             data
         };
 
-        Self {
-            data,
-            alive: 0..N,
-        }
+        Self { data, alive: 0..N }
     }
 
     /// Returns an immutable slice of all elements that have not been yielded
@@ -88,9 +84,7 @@ where
         // SAFETY: This transmute is safe. As mentioned in `new`, `MaybeUninit` retains
         // the size and alignment of `T`. Furthermore, we know that all
         // elements within `alive` are properly initialized.
-        unsafe {
-            mem::transmute::<&[MaybeUninit<T>], &[T]>(slice)
-        }
+        unsafe { mem::transmute::<&[MaybeUninit<T>], &[T]>(slice) }
     }
 
     /// Returns a mutable slice of all elements that have not been yielded yet.
@@ -100,15 +94,12 @@ where
         // SAFETY: This transmute is safe. As mentioned in `new`, `MaybeUninit` retains
         // the size and alignment of `T`. Furthermore, we know that all
         // elements within `alive` are properly initialized.
-        unsafe {
-            mem::transmute::<&mut [MaybeUninit<T>], &mut [T]>(slice)
-        }
+        unsafe { mem::transmute::<&mut [MaybeUninit<T>], &mut [T]>(slice) }
     }
 }
 
-
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
-impl<T, const N: usize> Iterator for IntoIter<T, {N}>
+impl<T, const N: usize> Iterator for IntoIter<T, { N }>
 where
     [T; N]: LengthAtMost32,
 {
@@ -155,7 +146,7 @@ where
 }
 
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
-impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, {N}>
+impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, { N }>
 where
     [T; N]: LengthAtMost32,
 {
@@ -191,7 +182,7 @@ where
 }
 
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
-impl<T, const N: usize> Drop for IntoIter<T, {N}>
+impl<T, const N: usize> Drop for IntoIter<T, { N }>
 where
     [T; N]: LengthAtMost32,
 {
@@ -199,14 +190,12 @@ where
         // SAFETY: This is safe: `as_mut_slice` returns exactly the sub-slice
         // of elements that have not been moved out yet and that remain
         // to be dropped.
-        unsafe {
-            ptr::drop_in_place(self.as_mut_slice())
-        }
+        unsafe { ptr::drop_in_place(self.as_mut_slice()) }
     }
 }
 
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
-impl<T, const N: usize> ExactSizeIterator for IntoIter<T, {N}>
+impl<T, const N: usize> ExactSizeIterator for IntoIter<T, { N }>
 where
     [T; N]: LengthAtMost32,
 {
@@ -221,23 +210,17 @@ where
 }
 
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
-impl<T, const N: usize> FusedIterator for IntoIter<T, {N}>
-where
-    [T; N]: LengthAtMost32,
-{}
+impl<T, const N: usize> FusedIterator for IntoIter<T, { N }> where [T; N]: LengthAtMost32 {}
 
 // The iterator indeed reports the correct length. The number of "alive"
 // elements (that will still be yielded) is the length of the range `alive`.
 // This range is decremented in length in either `next` or `next_back`. It is
 // always decremented by 1 in those methods, but only if `Some(_)` is returned.
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
-unsafe impl<T, const N: usize> TrustedLen for IntoIter<T, {N}>
-where
-    [T; N]: LengthAtMost32,
-{}
+unsafe impl<T, const N: usize> TrustedLen for IntoIter<T, { N }> where [T; N]: LengthAtMost32 {}
 
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
-impl<T: Clone, const N: usize> Clone for IntoIter<T, {N}>
+impl<T: Clone, const N: usize> Clone for IntoIter<T, { N }>
 where
     [T; N]: LengthAtMost32,
 {
@@ -260,24 +243,19 @@ where
                 new_data.get_unchecked_mut(idx).write(clone);
             }
 
-            Self {
-                data: new_data,
-                alive: self.alive.clone(),
-            }
+            Self { data: new_data, alive: self.alive.clone() }
         }
     }
 }
 
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
-impl<T: fmt::Debug, const N: usize> fmt::Debug for IntoIter<T, {N}>
+impl<T: fmt::Debug, const N: usize> fmt::Debug for IntoIter<T, { N }>
 where
     [T; N]: LengthAtMost32,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         // Only print the elements that were not yielded yet: we cannot
         // access the yielded elements anymore.
-        f.debug_tuple("IntoIter")
-            .field(&self.as_slice())
-            .finish()
+        f.debug_tuple("IntoIter").field(&self.as_slice()).finish()
     }
 }
diff --git a/src/libcore/array/mod.rs b/src/libcore/array/mod.rs
index fd80000b6fb..937451274cf 100644
--- a/src/libcore/array/mod.rs
+++ b/src/libcore/array/mod.rs
@@ -10,7 +10,7 @@ use crate::borrow::{Borrow, BorrowMut};
 use crate::cmp::Ordering;
 use crate::convert::{Infallible, TryFrom};
 use crate::fmt;
-use crate::hash::{Hash, self};
+use crate::hash::{self, Hash};
 use crate::marker::Unsize;
 use crate::slice::{Iter, IterMut};
 
@@ -71,10 +71,12 @@ impl fmt::Display for TryFromSliceError {
 }
 
 impl TryFromSliceError {
-    #[unstable(feature = "array_error_internals",
-           reason = "available through Error trait and this method should not \
+    #[unstable(
+        feature = "array_error_internals",
+        reason = "available through Error trait and this method should not \
                      be exposed publicly",
-           issue = "none")]
+        issue = "none"
+    )]
     #[inline]
     #[doc(hidden)]
     pub fn __description(&self) -> &str {
@@ -385,11 +387,12 @@ where
 }
 
 /// Implemented for lengths where trait impls are allowed on arrays in core/std
-#[rustc_on_unimplemented(
-    message="arrays only have std trait implementations for lengths 0..=32",
+#[rustc_on_unimplemented(message = "arrays only have std trait implementations for lengths 0..=32")]
+#[unstable(
+    feature = "const_generic_impls_guard",
+    issue = "none",
+    reason = "will never be stable, just a temporary step until const generics are stable"
 )]
-#[unstable(feature = "const_generic_impls_guard", issue = "none",
-    reason = "will never be stable, just a temporary step until const generics are stable")]
 pub trait LengthAtMost32 {}
 
 macro_rules! array_impls {
@@ -429,4 +432,4 @@ macro_rules! array_impl_default {
     };
 }
 
-array_impl_default!{32, T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T}
+array_impl_default! {32, T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T}