about summary refs log tree commit diff
path: root/src/libstd/io/error.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2019-11-27 10:29:00 -0800
committerDavid Tolnay <dtolnay@gmail.com>2019-11-29 18:43:27 -0800
commit4436c9d35498e7ae3da261f6141d6d73b915e1e8 (patch)
tree5bee9f8714a41c4ad672d0cc5c302ede56197726 /src/libstd/io/error.rs
parent9081929d45f12d3f56d43b1d6db7519981580fc9 (diff)
downloadrust-4436c9d35498e7ae3da261f6141d6d73b915e1e8.tar.gz
rust-4436c9d35498e7ae3da261f6141d6d73b915e1e8.zip
Format libstd with rustfmt
This commit applies rustfmt with rust-lang/rust's default settings to
files in src/libstd *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/libstd -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of libstd.

To confirm no funny business:

    $ git checkout $THIS_COMMIT^
    $ git show --pretty= --name-only $THIS_COMMIT \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ git diff $THIS_COMMIT  # there should be no difference
Diffstat (limited to 'src/libstd/io/error.rs')
-rw-r--r--src/libstd/io/error.rs65
1 files changed, 29 insertions, 36 deletions
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs
index c29a68e6f02..c20bd3097b2 100644
--- a/src/libstd/io/error.rs
+++ b/src/libstd/io/error.rs
@@ -1,8 +1,8 @@
+use crate::convert::From;
 use crate::error;
 use crate::fmt;
 use crate::result;
 use crate::sys;
-use crate::convert::From;
 
 /// A specialized [`Result`](../result/enum.Result.html) type for I/O
 /// operations.
@@ -73,7 +73,7 @@ enum Repr {
 #[derive(Debug)]
 struct Custom {
     kind: ErrorKind,
-    error: Box<dyn error::Error+Send+Sync>,
+    error: Box<dyn error::Error + Send + Sync>,
 }
 
 /// A list specifying general categories of I/O error.
@@ -220,9 +220,7 @@ impl From<ErrorKind> for Error {
     /// [`Error`]: ../../std/io/struct.Error.html
     #[inline]
     fn from(kind: ErrorKind) -> Error {
-        Error {
-            repr: Repr::Simple(kind)
-        }
+        Error { repr: Repr::Simple(kind) }
     }
 }
 
@@ -247,18 +245,14 @@ impl Error {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn new<E>(kind: ErrorKind, error: E) -> Error
-        where E: Into<Box<dyn error::Error+Send+Sync>>
+    where
+        E: Into<Box<dyn error::Error + Send + Sync>>,
     {
         Self::_new(kind, error.into())
     }
 
-    fn _new(kind: ErrorKind, error: Box<dyn error::Error+Send+Sync>) -> Error {
-        Error {
-            repr: Repr::Custom(Box::new(Custom {
-                kind,
-                error,
-            }))
-        }
+    fn _new(kind: ErrorKind, error: Box<dyn error::Error + Send + Sync>) -> Error {
+        Error { repr: Repr::Custom(Box::new(Custom { kind, error })) }
     }
 
     /// Returns an error representing the last OS error which occurred.
@@ -370,7 +364,7 @@ impl Error {
     /// }
     /// ```
     #[stable(feature = "io_error_inner", since = "1.3.0")]
-    pub fn get_ref(&self) -> Option<&(dyn error::Error+Send+Sync+'static)> {
+    pub fn get_ref(&self) -> Option<&(dyn error::Error + Send + Sync + 'static)> {
         match self.repr {
             Repr::Os(..) => None,
             Repr::Simple(..) => None,
@@ -441,7 +435,7 @@ impl Error {
     /// }
     /// ```
     #[stable(feature = "io_error_inner", since = "1.3.0")]
-    pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error+Send+Sync+'static)> {
+    pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)> {
         match self.repr {
             Repr::Os(..) => None,
             Repr::Simple(..) => None,
@@ -475,11 +469,11 @@ impl Error {
     /// }
     /// ```
     #[stable(feature = "io_error_inner", since = "1.3.0")]
-    pub fn into_inner(self) -> Option<Box<dyn error::Error+Send+Sync>> {
+    pub fn into_inner(self) -> Option<Box<dyn error::Error + Send + Sync>> {
         match self.repr {
             Repr::Os(..) => None,
             Repr::Simple(..) => None,
-            Repr::Custom(c) => Some(c.error)
+            Repr::Custom(c) => Some(c.error),
         }
     }
 
@@ -514,11 +508,12 @@ impl Error {
 impl fmt::Debug for Repr {
     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
-            Repr::Os(code) =>
-                fmt.debug_struct("Os")
-                    .field("code", &code)
-                    .field("kind", &sys::decode_error_kind(code))
-                    .field("message", &sys::os::error_string(code)).finish(),
+            Repr::Os(code) => fmt
+                .debug_struct("Os")
+                .field("code", &code)
+                .field("kind", &sys::decode_error_kind(code))
+                .field("message", &sys::os::error_string(code))
+                .finish(),
             Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt),
             Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(),
         }
@@ -567,17 +562,17 @@ impl error::Error for Error {
 }
 
 fn _assert_error_is_sync_send() {
-    fn _is_sync_send<T: Sync+Send>() {}
+    fn _is_sync_send<T: Sync + Send>() {}
     _is_sync_send::<Error>();
 }
 
 #[cfg(test)]
 mod test {
-    use super::{Error, ErrorKind, Repr, Custom};
+    use super::{Custom, Error, ErrorKind, Repr};
     use crate::error;
     use crate::fmt;
-    use crate::sys::os::error_string;
     use crate::sys::decode_error_kind;
+    use crate::sys::os::error_string;
 
     #[test]
     fn test_debug_error() {
@@ -587,20 +582,18 @@ mod test {
         let err = Error {
             repr: Repr::Custom(box Custom {
                 kind: ErrorKind::InvalidInput,
-                error: box Error {
-                    repr: super::Repr::Os(code)
-                },
-            })
+                error: box Error { repr: super::Repr::Os(code) },
+            }),
         };
         let expected = format!(
             "Custom {{ \
-                kind: InvalidInput, \
-                error: Os {{ \
-                    code: {:?}, \
-                    kind: {:?}, \
-                    message: {:?} \
-                }} \
-            }}",
+             kind: InvalidInput, \
+             error: Os {{ \
+             code: {:?}, \
+             kind: {:?}, \
+             message: {:?} \
+             }} \
+             }}",
             code, kind, msg
         );
         assert_eq!(format!("{:?}", err), expected);