diff --git a/src/errno.rs b/src/errno.rs index 8de55b8021..4218bf9cd3 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -1,6 +1,6 @@ use libc::c_int; -use std::{fmt, io, error, result}; -use Error; +use std::{fmt, io, error}; +use {Error, Result}; pub use self::consts::*; pub use self::consts::Errno::*; @@ -117,8 +117,6 @@ impl From for io::Error { } } -pub type Result = result::Result; - fn last() -> Errno { Errno::from_i32(errno()) } diff --git a/src/fcntl.rs b/src/fcntl.rs index 197f0059f9..2b1c7b8959 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -1,5 +1,4 @@ -use NixPath; -use errno::{Errno, Result}; +use {Errno, Result, NixPath}; use libc::{c_int, c_uint}; use sys::stat::Mode; use std::os::unix::io::RawFd; diff --git a/src/lib.rs b/src/lib.rs index cc72f704e6..2b77cec9da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ extern crate nix_test as nixtest; // Re-exports pub use libc::{c_int, c_void}; -pub use errno::{Errno, Result}; +pub use errno::Errno; pub mod errno; pub mod features; @@ -43,12 +43,12 @@ pub mod unistd; /* * - * ===== Error ===== + * ===== Result / Error ===== * */ use libc::c_char; -use std::ptr; +use std::{ptr, result}; use std::ffi::CStr; use std::path::{Path, PathBuf}; use std::os::unix::ffi::OsStrExt; @@ -57,6 +57,8 @@ use std::fmt; use std::error; use libc::PATH_MAX; +pub type Result = result::Result; + #[derive(Clone, Copy, Debug, PartialEq)] pub enum Error { Sys(errno::Errno), diff --git a/src/mount.rs b/src/mount.rs index 0535cdd048..8ef1b74a6f 100644 --- a/src/mount.rs +++ b/src/mount.rs @@ -1,6 +1,5 @@ use libc::{c_ulong, c_int}; -use NixPath; -use errno::{Errno, Result}; +use {Errno, Result, NixPath}; bitflags!( flags MsFlags: c_ulong { diff --git a/src/mqueue.rs b/src/mqueue.rs index 1625d4ef9b..bc3eca2cc1 100644 --- a/src/mqueue.rs +++ b/src/mqueue.rs @@ -2,7 +2,7 @@ //! //! [Further reading and details on the C API](http://man7.org/linux/man-pages/man7/mq_overview.7.html) -use errno::{Errno, Result}; +use {Errno, Result}; use libc::{c_int, c_long, c_char, size_t, mode_t, strlen}; use std::ffi::CString; diff --git a/src/poll.rs b/src/poll.rs index 631a47cc48..88ca982573 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -1,5 +1,5 @@ use libc::c_int; -use errno::{Errno, Result}; +use {Errno, Result}; pub use self::ffi::PollFd; pub use self::ffi::consts::*; diff --git a/src/sched.rs b/src/sched.rs index 7d7ec0f0fc..ce34005d76 100644 --- a/src/sched.rs +++ b/src/sched.rs @@ -1,7 +1,7 @@ use std::mem; use std::os::unix::io::RawFd; use libc::{c_int, c_uint, c_void, c_ulong, pid_t}; -use errno::{Errno, Result}; +use {Errno, Result}; pub type CloneFlags = c_uint; diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs index a079649a36..592f10a17b 100644 --- a/src/sys/epoll.rs +++ b/src/sys/epoll.rs @@ -1,4 +1,4 @@ -use errno::{Errno, Result}; +use {Errno, Result}; use libc::c_int; use std::os::unix::io::RawFd; diff --git a/src/sys/memfd.rs b/src/sys/memfd.rs index c5b7b803bb..1cd94150eb 100644 --- a/src/sys/memfd.rs +++ b/src/sys/memfd.rs @@ -1,6 +1,6 @@ use libc; use std::os::unix::io::RawFd; -use errno::{Errno, Result}; +use {Errno, Result}; use std::ffi::CStr; bitflags!( diff --git a/src/sys/mman.rs b/src/sys/mman.rs index cb36cf7bfd..7537c272e7 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -1,5 +1,4 @@ -use {NixPath, Error}; -use errno::{Errno, Result}; +use {Errno, Error, Result, NixPath}; use fcntl::OFlag; use libc::{c_void, size_t, off_t, mode_t}; use sys::stat::Mode; diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs index 9d8e6932a2..63c7482ddd 100644 --- a/src/sys/ptrace.rs +++ b/src/sys/ptrace.rs @@ -1,5 +1,4 @@ -use Error; -use errno::{Errno, Result}; +use {Errno, Error, Result}; use libc::{pid_t, c_void, c_long}; #[cfg(all(target_os = "linux", diff --git a/src/sys/quota.rs b/src/sys/quota.rs index 7a7718e45a..a6a1b9b0bb 100644 --- a/src/sys/quota.rs +++ b/src/sys/quota.rs @@ -1,5 +1,4 @@ -use NixPath; -use errno::{Errno, Result}; +use {Errno, Result, NixPath}; use libc::{c_int, c_char}; #[cfg(all(target_os = "linux", diff --git a/src/sys/select.rs b/src/sys/select.rs index db0a55b933..9d7c41f8b8 100644 --- a/src/sys/select.rs +++ b/src/sys/select.rs @@ -1,7 +1,7 @@ use std::ptr::null_mut; use std::os::unix::io::RawFd; use libc::c_int; -use errno::{Errno, Result}; +use {Errno, Result}; use sys::time::TimeVal; pub const FD_SETSIZE: RawFd = 1024; diff --git a/src/sys/signal.rs b/src/sys/signal.rs index 76984f2c0e..3d26729432 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -2,7 +2,7 @@ // See http://rust-lang.org/COPYRIGHT. use libc; -use errno::{Errno, Result}; +use {Errno, Result}; use std::mem; use std::ptr; diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 49a1ecf5a9..343e54f9fd 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -1,6 +1,5 @@ use super::{consts, sa_family_t}; -use {NixPath, Error}; -use errno::{Errno, Result}; +use {Errno, Error, Result, NixPath}; use libc; use std::{fmt, hash, mem, net, ptr}; use std::ffi::OsStr; diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 60b138eddd..fe88b376c7 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -1,8 +1,7 @@ //! Socket interface functions //! //! [Further reading](http://man7.org/linux/man-pages/man7/socket.7.html) -use Error; -use errno::{Errno, Result}; +use {Error, Errno, Result}; use features; use fcntl::{fcntl, FD_CLOEXEC, O_NONBLOCK}; use fcntl::FcntlArg::{F_SETFD, F_SETFL}; diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index a9d6e67c2f..f0845033eb 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -1,5 +1,5 @@ use super::{ffi, consts, GetSockOpt, SetSockOpt}; -use errno::{Errno, Result}; +use {Errno, Result}; use sys::time::TimeVal; use libc::{c_int, uint8_t, c_void, socklen_t}; use std::mem; diff --git a/src/sys/stat.rs b/src/sys/stat.rs index 391924dac0..cd142a9600 100644 --- a/src/sys/stat.rs +++ b/src/sys/stat.rs @@ -1,8 +1,7 @@ pub use libc::dev_t; pub use libc::stat as FileStat; -use NixPath; -use errno::{Errno, Result}; +use {Errno, Result, NixPath}; use libc::mode_t; use std::mem; use std::os::unix::io::RawFd; diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs index 0552e3d064..7c61a3ab31 100644 --- a/src/sys/statfs.rs +++ b/src/sys/statfs.rs @@ -1,5 +1,4 @@ -use NixPath; -use errno::{Errno, Result}; +use {Errno, Result, NixPath}; use std::os::unix::io::AsRawFd; pub mod vfs { diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs index abfc6c9b3d..5b72a16bd8 100644 --- a/src/sys/statvfs.rs +++ b/src/sys/statvfs.rs @@ -2,8 +2,7 @@ //! //! See the `vfs::Statvfs` struct for some rusty wrappers -use NixPath; -use errno::{Errno, Result}; +use {Errno, Result, NixPath}; use std::os::unix::io::AsRawFd; pub mod vfs { diff --git a/src/sys/termios.rs b/src/sys/termios.rs index 9c26661f47..78e980286f 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -1,4 +1,4 @@ -use errno::{Errno, Result}; +use {Errno, Result}; use libc::c_int; use std::mem; use std::os::unix::io::RawFd; diff --git a/src/sys/uio.rs b/src/sys/uio.rs index 7e734f84d7..03f2a3a8b8 100644 --- a/src/sys/uio.rs +++ b/src/sys/uio.rs @@ -1,7 +1,7 @@ // Silence invalid warnings due to rust-lang/rust#16719 #![allow(improper_ctypes)] -use errno::{Errno, Result}; +use {Errno, Result}; use libc::{c_int, c_void, size_t, off_t}; use std::marker::PhantomData; use std::os::unix::io::RawFd; diff --git a/src/sys/wait.rs b/src/sys/wait.rs index ab91a8484c..3d9b3a5044 100644 --- a/src/sys/wait.rs +++ b/src/sys/wait.rs @@ -1,5 +1,5 @@ use libc::{pid_t, c_int}; -use errno::{Errno, Result}; +use {Errno, Result}; use sys::signal; diff --git a/src/unistd.rs b/src/unistd.rs index f2c1fdced0..a4e666180c 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -1,7 +1,6 @@ //! Standard symbolic constants and types //! -use {NixPath, Error}; -use errno::{Errno, Result}; +use {Errno, Error, Result, NixPath}; use fcntl::{fcntl, OFlag, O_NONBLOCK, O_CLOEXEC, FD_CLOEXEC}; use fcntl::FcntlArg::{F_SETFD, F_SETFL}; use libc::{c_char, c_void, c_int, size_t, pid_t, off_t, uid_t, gid_t}; @@ -373,8 +372,7 @@ pub fn getegid() -> gid_t { #[cfg(any(target_os = "linux", target_os = "android"))] mod linux { use sys::syscall::{syscall, SYSPIVOTROOT}; - use NixPath; - use errno::{Errno, Result}; + use {Errno, Result, NixPath}; #[cfg(feature = "execvpe")] use std::ffi::CString;