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

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

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/sys/unix/ext')
-rw-r--r--src/libstd/sys/unix/ext/fs.rs108
-rw-r--r--src/libstd/sys/unix/ext/io.rs26
-rw-r--r--src/libstd/sys/unix/ext/process.rs19
-rw-r--r--src/libstd/sys/unix/ext/raw.rs25
4 files changed, 123 insertions, 55 deletions
diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs
index 0c52dc5b81b..732cd677a18 100644
--- a/src/libstd/sys/unix/ext/fs.rs
+++ b/src/libstd/sys/unix/ext/fs.rs
@@ -2,12 +2,12 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use crate::fs::{self, Permissions, OpenOptions};
+use crate::fs::{self, OpenOptions, Permissions};
 use crate::io;
 use crate::path::Path;
 use crate::sys;
-use crate::sys_common::{FromInner, AsInner, AsInnerMut};
 use crate::sys::platform::fs::MetadataExt as UnixMetadataExt;
+use crate::sys_common::{AsInner, AsInnerMut, FromInner};
 
 /// Unix-specific extensions to [`File`].
 ///
@@ -112,8 +112,7 @@ pub trait FileExt {
             }
         }
         if !buf.is_empty() {
-            Err(io::Error::new(io::ErrorKind::UnexpectedEof,
-                               "failed to fill whole buffer"))
+            Err(io::Error::new(io::ErrorKind::UnexpectedEof, "failed to fill whole buffer"))
         } else {
             Ok(())
         }
@@ -195,8 +194,12 @@ pub trait FileExt {
     fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> {
         while !buf.is_empty() {
             match self.write_at(buf, offset) {
-                Ok(0) => return Err(io::Error::new(io::ErrorKind::WriteZero,
-                                                   "failed to write whole buffer")),
+                Ok(0) => {
+                    return Err(io::Error::new(
+                        io::ErrorKind::WriteZero,
+                        "failed to write whole buffer",
+                    ));
+                }
                 Ok(n) => {
                     buf = &buf[n..];
                     offset += n as u64
@@ -356,11 +359,13 @@ pub trait OpenOptionsExt {
 #[stable(feature = "fs_ext", since = "1.1.0")]
 impl OpenOptionsExt for OpenOptions {
     fn mode(&mut self, mode: u32) -> &mut OpenOptions {
-        self.as_inner_mut().mode(mode); self
+        self.as_inner_mut().mode(mode);
+        self
     }
 
     fn custom_flags(&mut self, flags: i32) -> &mut OpenOptions {
-        self.as_inner_mut().custom_flags(flags); self
+        self.as_inner_mut().custom_flags(flags);
+        self
     }
 }
 
@@ -657,22 +662,54 @@ pub trait MetadataExt {
 
 #[stable(feature = "metadata_ext", since = "1.1.0")]
 impl MetadataExt for fs::Metadata {
-    fn dev(&self) -> u64 { self.st_dev() }
-    fn ino(&self) -> u64 { self.st_ino() }
-    fn mode(&self) -> u32 { self.st_mode() }
-    fn nlink(&self) -> u64 { self.st_nlink() }
-    fn uid(&self) -> u32 { self.st_uid() }
-    fn gid(&self) -> u32 { self.st_gid() }
-    fn rdev(&self) -> u64 { self.st_rdev() }
-    fn size(&self) -> u64 { self.st_size() }
-    fn atime(&self) -> i64 { self.st_atime() }
-    fn atime_nsec(&self) -> i64 { self.st_atime_nsec() }
-    fn mtime(&self) -> i64 { self.st_mtime() }
-    fn mtime_nsec(&self) -> i64 { self.st_mtime_nsec() }
-    fn ctime(&self) -> i64 { self.st_ctime() }
-    fn ctime_nsec(&self) -> i64 { self.st_ctime_nsec() }
-    fn blksize(&self) -> u64 { self.st_blksize() }
-    fn blocks(&self) -> u64 { self.st_blocks() }
+    fn dev(&self) -> u64 {
+        self.st_dev()
+    }
+    fn ino(&self) -> u64 {
+        self.st_ino()
+    }
+    fn mode(&self) -> u32 {
+        self.st_mode()
+    }
+    fn nlink(&self) -> u64 {
+        self.st_nlink()
+    }
+    fn uid(&self) -> u32 {
+        self.st_uid()
+    }
+    fn gid(&self) -> u32 {
+        self.st_gid()
+    }
+    fn rdev(&self) -> u64 {
+        self.st_rdev()
+    }
+    fn size(&self) -> u64 {
+        self.st_size()
+    }
+    fn atime(&self) -> i64 {
+        self.st_atime()
+    }
+    fn atime_nsec(&self) -> i64 {
+        self.st_atime_nsec()
+    }
+    fn mtime(&self) -> i64 {
+        self.st_mtime()
+    }
+    fn mtime_nsec(&self) -> i64 {
+        self.st_mtime_nsec()
+    }
+    fn ctime(&self) -> i64 {
+        self.st_ctime()
+    }
+    fn ctime_nsec(&self) -> i64 {
+        self.st_ctime_nsec()
+    }
+    fn blksize(&self) -> u64 {
+        self.st_blksize()
+    }
+    fn blocks(&self) -> u64 {
+        self.st_blocks()
+    }
 }
 
 /// Unix-specific extensions for [`FileType`].
@@ -759,10 +796,18 @@ pub trait FileTypeExt {
 
 #[stable(feature = "file_type_ext", since = "1.5.0")]
 impl FileTypeExt for fs::FileType {
-    fn is_block_device(&self) -> bool { self.as_inner().is(libc::S_IFBLK) }
-    fn is_char_device(&self) -> bool { self.as_inner().is(libc::S_IFCHR) }
-    fn is_fifo(&self) -> bool { self.as_inner().is(libc::S_IFIFO) }
-    fn is_socket(&self) -> bool { self.as_inner().is(libc::S_IFSOCK) }
+    fn is_block_device(&self) -> bool {
+        self.as_inner().is(libc::S_IFBLK)
+    }
+    fn is_char_device(&self) -> bool {
+        self.as_inner().is(libc::S_IFCHR)
+    }
+    fn is_fifo(&self) -> bool {
+        self.as_inner().is(libc::S_IFIFO)
+    }
+    fn is_socket(&self) -> bool {
+        self.as_inner().is(libc::S_IFSOCK)
+    }
 }
 
 /// Unix-specific extension methods for [`fs::DirEntry`].
@@ -794,7 +839,9 @@ pub trait DirEntryExt {
 
 #[stable(feature = "dir_entry_ext", since = "1.1.0")]
 impl DirEntryExt for fs::DirEntry {
-    fn ino(&self) -> u64 { self.as_inner().ino() }
+    fn ino(&self) -> u64 {
+        self.as_inner().ino()
+    }
 }
 
 /// Creates a new symbolic link on the filesystem.
@@ -821,8 +868,7 @@ impl DirEntryExt for fs::DirEntry {
 /// }
 /// ```
 #[stable(feature = "symlink", since = "1.1.0")]
-pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>
-{
+pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
     sys::fs::symlink(src.as_ref(), dst.as_ref())
 }
 
diff --git a/src/libstd/sys/unix/ext/io.rs b/src/libstd/sys/unix/ext/io.rs
index 6bcc59495e3..5077e2e28d1 100644
--- a/src/libstd/sys/unix/ext/io.rs
+++ b/src/libstd/sys/unix/ext/io.rs
@@ -3,9 +3,9 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 use crate::fs;
+use crate::io;
 use crate::os::raw;
 use crate::sys;
-use crate::io;
 use crate::sys_common::{AsInner, FromInner, IntoInner};
 
 /// Raw file descriptors.
@@ -83,30 +83,42 @@ impl IntoRawFd for fs::File {
 
 #[stable(feature = "asraw_stdio", since = "1.21.0")]
 impl AsRawFd for io::Stdin {
-    fn as_raw_fd(&self) -> RawFd { libc::STDIN_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDIN_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio", since = "1.21.0")]
 impl AsRawFd for io::Stdout {
-    fn as_raw_fd(&self) -> RawFd { libc::STDOUT_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDOUT_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio", since = "1.21.0")]
 impl AsRawFd for io::Stderr {
-    fn as_raw_fd(&self) -> RawFd { libc::STDERR_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDERR_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
 impl<'a> AsRawFd for io::StdinLock<'a> {
-    fn as_raw_fd(&self) -> RawFd { libc::STDIN_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDIN_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
 impl<'a> AsRawFd for io::StdoutLock<'a> {
-    fn as_raw_fd(&self) -> RawFd { libc::STDOUT_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDOUT_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
 impl<'a> AsRawFd for io::StderrLock<'a> {
-    fn as_raw_fd(&self) -> RawFd { libc::STDERR_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDERR_FILENO
+    }
 }
diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs
index 0e95f97486b..fa8670b4aec 100644
--- a/src/libstd/sys/unix/ext/process.rs
+++ b/src/libstd/sys/unix/ext/process.rs
@@ -4,10 +4,10 @@
 
 use crate::ffi::OsStr;
 use crate::io;
-use crate::os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
+use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
 use crate::process;
 use crate::sys;
-use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
+use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
 
 /// Unix-specific extensions to the [`process::Command`] builder.
 ///
@@ -56,7 +56,8 @@ pub trait CommandExt {
     /// locations may not appear where intended.
     #[stable(feature = "process_pre_exec", since = "1.34.0")]
     unsafe fn pre_exec<F>(&mut self, f: F) -> &mut process::Command
-        where F: FnMut() -> io::Result<()> + Send + Sync + 'static;
+    where
+        F: FnMut() -> io::Result<()> + Send + Sync + 'static;
 
     /// Schedules a closure to be run just before the `exec` function is
     /// invoked.
@@ -68,7 +69,8 @@ pub trait CommandExt {
     #[stable(feature = "process_exec", since = "1.15.0")]
     #[rustc_deprecated(since = "1.37.0", reason = "should be unsafe, use `pre_exec` instead")]
     fn before_exec<F>(&mut self, f: F) -> &mut process::Command
-        where F: FnMut() -> io::Result<()> + Send + Sync + 'static
+    where
+        F: FnMut() -> io::Result<()> + Send + Sync + 'static,
     {
         unsafe { self.pre_exec(f) }
     }
@@ -111,7 +113,8 @@ pub trait CommandExt {
     /// default executable path.
     #[unstable(feature = "process_set_argv0", issue = "66510")]
     fn arg0<S>(&mut self, arg: S) -> &mut process::Command
-        where S: AsRef<OsStr>;
+    where
+        S: AsRef<OsStr>;
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -127,7 +130,8 @@ impl CommandExt for process::Command {
     }
 
     unsafe fn pre_exec<F>(&mut self, f: F) -> &mut process::Command
-        where F: FnMut() -> io::Result<()> + Send + Sync + 'static
+    where
+        F: FnMut() -> io::Result<()> + Send + Sync + 'static,
     {
         self.as_inner_mut().pre_exec(Box::new(f));
         self
@@ -138,7 +142,8 @@ impl CommandExt for process::Command {
     }
 
     fn arg0<S>(&mut self, arg: S) -> &mut process::Command
-        where S: AsRef<OsStr>
+    where
+        S: AsRef<OsStr>,
     {
         self.as_inner_mut().set_arg_0(arg.as_ref());
         self
diff --git a/src/libstd/sys/unix/ext/raw.rs b/src/libstd/sys/unix/ext/raw.rs
index 75ae54a919a..d81368a18b4 100644
--- a/src/libstd/sys/unix/ext/raw.rs
+++ b/src/libstd/sys/unix/ext/raw.rs
@@ -1,23 +1,28 @@
 //! Unix-specific primitives available on all unix platforms
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
-#![rustc_deprecated(since = "1.8.0",
-                    reason = "these type aliases are no longer supported by \
-                              the standard library, the `libc` crate on \
-                              crates.io should be used instead for the correct \
-                              definitions")]
+#![rustc_deprecated(
+    since = "1.8.0",
+    reason = "these type aliases are no longer supported by \
+              the standard library, the `libc` crate on \
+              crates.io should be used instead for the correct \
+              definitions"
+)]
 #![allow(deprecated)]
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type pid_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type uid_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type gid_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type pid_t = i32;
 
 #[doc(inline)]
 #[stable(feature = "pthread_t", since = "1.8.0")]
 pub use crate::sys::platform::raw::pthread_t;
 #[doc(inline)]
 #[stable(feature = "raw_ext", since = "1.1.0")]
-pub use crate::sys::platform::raw::{dev_t, ino_t, mode_t, nlink_t, off_t, blksize_t};
+pub use crate::sys::platform::raw::{blkcnt_t, time_t};
 #[doc(inline)]
 #[stable(feature = "raw_ext", since = "1.1.0")]
-pub use crate::sys::platform::raw::{blkcnt_t, time_t};
+pub use crate::sys::platform::raw::{blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t};