Patchwork D7578: rust: run rustfmt

login
register
mail settings
Submitter phabricator
Date Dec. 10, 2019, 3:47 p.m.
Message ID <4cbd0d58af395f93737e4473326d7ad3@localhost.localdomain>
Download mbox | patch
Permalink /patch/43678/
State Not Applicable
Headers show

Comments

phabricator - Dec. 10, 2019, 3:47 p.m.
Closed by commit rHGce088b38f92b: rust: run rustfmt (authored by indygreg).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7578?vs=18538&id=18569

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7578/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7578

AFFECTED FILES
  rust/chg/src/attachio.rs
  rust/chg/src/clientext.rs
  rust/chg/src/locator.rs
  rust/chg/src/main.rs
  rust/chg/src/message.rs
  rust/chg/src/procutil.rs
  rust/chg/src/runcommand.rs
  rust/chg/src/uihandler.rs
  rust/hg-core/src/dirstate/status.rs
  rust/hg-cpython/src/dirstate/status.rs
  rust/hg-cpython/src/filepatterns.rs
  rust/hg-cpython/src/parsers.rs
  rust/hgcli/build.rs
  rust/hgcli/src/main.rs

CHANGE DETAILS




To: indygreg, #hg-reviewers, kevincox, Alphare, pulkit
Cc: durin42, kevincox, mercurial-devel

Patch

diff --git a/rust/hgcli/src/main.rs b/rust/hgcli/src/main.rs
--- a/rust/hgcli/src/main.rs
+++ b/rust/hgcli/src/main.rs
@@ -5,18 +5,18 @@ 
 // This software may be used and distributed according to the terms of the
 // GNU General Public License version 2 or any later version.
 
+extern crate cpython;
 extern crate libc;
-extern crate cpython;
 extern crate python27_sys;
 
 use cpython::{NoArgs, ObjectProtocol, PyModule, PyResult, Python};
 use libc::{c_char, c_int};
 
 use std::env;
-use std::path::PathBuf;
 use std::ffi::{CString, OsStr};
 #[cfg(target_family = "unix")]
 use std::os::unix::ffi::{OsStrExt, OsStringExt};
+use std::path::PathBuf;
 
 #[derive(Debug)]
 struct Environment {
diff --git a/rust/hgcli/build.rs b/rust/hgcli/build.rs
--- a/rust/hgcli/build.rs
+++ b/rust/hgcli/build.rs
@@ -18,9 +18,8 @@ 
 fn get_python_config() -> PythonConfig {
     // The python27-sys crate exports a Cargo variable defining the full
     // path to the interpreter being used.
-    let python = env::var("DEP_PYTHON27_PYTHON_INTERPRETER").expect(
-        "Missing DEP_PYTHON27_PYTHON_INTERPRETER; bad python27-sys crate?",
-    );
+    let python = env::var("DEP_PYTHON27_PYTHON_INTERPRETER")
+        .expect("Missing DEP_PYTHON27_PYTHON_INTERPRETER; bad python27-sys crate?");
 
     if !Path::new(&python).exists() {
         panic!(
@@ -33,8 +32,8 @@ 
     let separator = "SEPARATOR STRING";
 
     let script = "import sysconfig; \
-c = sysconfig.get_config_vars(); \
-print('SEPARATOR STRING'.join('%s=%s' % i for i in c.items()))";
+                  c = sysconfig.get_config_vars(); \
+                  print('SEPARATOR STRING'.join('%s=%s' % i for i in c.items()))";
 
     let mut command = Command::new(&python);
     command.arg("-c").arg(script);
diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
--- a/rust/hg-cpython/src/parsers.rs
+++ b/rust/hg-cpython/src/parsers.rs
@@ -9,7 +9,6 @@ 
 //! `hg-core` package.
 //!
 //! From Python, this will be seen as `mercurial.rustext.parsers`
-//!
 use cpython::{
     exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyResult, PyTuple, Python,
     PythonObject, ToPyObject,
diff --git a/rust/hg-cpython/src/filepatterns.rs b/rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs
+++ b/rust/hg-cpython/src/filepatterns.rs
@@ -10,7 +10,6 @@ 
 //! `hg-core` crate. From Python, this will be seen as `rustext.filepatterns`
 //! and can be used as replacement for the the pure `filepatterns` Python
 //! module.
-//!
 use crate::exceptions::{PatternError, PatternFileError};
 use cpython::{
     PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
diff --git a/rust/hg-cpython/src/dirstate/status.rs b/rust/hg-cpython/src/dirstate/status.rs
--- a/rust/hg-cpython/src/dirstate/status.rs
+++ b/rust/hg-cpython/src/dirstate/status.rs
@@ -8,7 +8,6 @@ 
 //! Bindings for the `hg::status` module provided by the
 //! `hg-core` crate. From Python, this will be seen as
 //! `rustext.dirstate.status`.
-//!
 
 use crate::dirstate::DirstateMap;
 use cpython::exc::ValueError;
diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -170,8 +170,8 @@ 
     pub removed: Vec<&'a HgPath>,
     pub deleted: Vec<&'a HgPath>,
     pub clean: Vec<&'a HgPath>,
-    // TODO ignored
-    // TODO unknown
+    /* TODO ignored
+     * TODO unknown */
 }
 
 fn build_response(
diff --git a/rust/chg/src/uihandler.rs b/rust/chg/src/uihandler.rs
--- a/rust/chg/src/uihandler.rs
+++ b/rust/chg/src/uihandler.rs
@@ -3,8 +3,8 @@ 
 // This software may be used and distributed according to the terms of the
 // GNU General Public License version 2 or any later version.
 
+use futures::future::IntoFuture;
 use futures::Future;
-use futures::future::IntoFuture;
 use std::io;
 use std::os::unix::io::AsRawFd;
 use std::os::unix::process::ExitStatusExt;
@@ -33,8 +33,7 @@ 
 }
 
 /// Default cHg implementation to process requests received from server.
-pub struct ChgUiHandler {
-}
+pub struct ChgUiHandler {}
 
 impl ChgUiHandler {
     pub fn new() -> ChgUiHandler {
@@ -57,7 +56,7 @@ 
         // otherwise the server won't get SIGPIPE if it does not write
         // anything. (issue5278)
         // kill(peerpid, SIGPIPE);
-        tokio::spawn(pager.map(|_| ()).map_err(|_| ()));  // just ignore errors
+        tokio::spawn(pager.map(|_| ()).map_err(|_| ())); // just ignore errors
         Ok((self, pin))
     }
 
@@ -67,7 +66,9 @@ 
             .into_future()
             .flatten()
             .map(|status| {
-                let code = status.code().or_else(|| status.signal().map(|n| -n))
+                let code = status
+                    .code()
+                    .or_else(|| status.signal().map(|n| -n))
                     .expect("either exit code or signal should be set");
                 (self, code)
             });
@@ -84,4 +85,4 @@ 
         .env_clear()
         .envs(spec.envs.iter().cloned());
     builder
- }
+}
diff --git a/rust/chg/src/runcommand.rs b/rust/chg/src/runcommand.rs
--- a/rust/chg/src/runcommand.rs
+++ b/rust/chg/src/runcommand.rs
@@ -11,9 +11,9 @@ 
 use std::io;
 use std::mem;
 use std::os::unix::io::AsRawFd;
-use tokio_hglib::{Client, Connection};
 use tokio_hglib::codec::ChannelMessage;
 use tokio_hglib::protocol::MessageLoop;
+use tokio_hglib::{Client, Connection};
 
 use super::attachio::AttachIo;
 use super::message::{self, CommandType};
@@ -26,8 +26,9 @@ 
 }
 
 enum CommandState<C, H>
-    where C: Connection,
-          H: SystemHandler,
+where
+    C: Connection,
+    H: SystemHandler,
 {
     Running(MessageLoop<C>, H),
     SpawningPager(Client<C>, <H::SpawnPagerResult as IntoFuture>::Future),
@@ -41,18 +42,19 @@ 
 /// Future resolves to `(exit_code, client)`.
 #[must_use = "futures do nothing unless polled"]
 pub struct ChgRunCommand<C, H>
-    where C: Connection,
-          H: SystemHandler,
+where
+    C: Connection,
+    H: SystemHandler,
 {
     state: CommandState<C, H>,
 }
 
 impl<C, H> ChgRunCommand<C, H>
-    where C: Connection + AsRawFd,
-          H: SystemHandler,
+where
+    C: Connection + AsRawFd,
+    H: SystemHandler,
 {
-    pub fn with_client(client: Client<C>, handler: H, packed_args: Bytes)
-                       -> ChgRunCommand<C, H> {
+    pub fn with_client(client: Client<C>, handler: H, packed_args: Bytes) -> ChgRunCommand<C, H> {
         let msg_loop = MessageLoop::start_with_args(client, b"runcommand", packed_args);
         ChgRunCommand {
             state: CommandState::Running(msg_loop, handler),
@@ -61,8 +63,9 @@ 
 }
 
 impl<C, H> Future for ChgRunCommand<C, H>
-    where C: Connection + AsRawFd,
-          H: SystemHandler,
+where
+    C: Connection + AsRawFd,
+    H: SystemHandler,
 {
     type Item = (Client<C>, H, i32);
     type Error = io::Error;
@@ -87,8 +90,9 @@ 
 }
 
 impl<C, H> CommandState<C, H>
-    where C: Connection + AsRawFd,
-          H: SystemHandler,
+where
+    C: Connection + AsRawFd,
+    H: SystemHandler,
 {
     fn poll(self) -> CommandPoll<C, H> {
         match self {
@@ -102,14 +106,16 @@ 
             CommandState::SpawningPager(client, mut fut) => {
                 if let Async::Ready((handler, pin)) = fut.poll()? {
                     let fut = AttachIo::with_client(client, io::stdin(), pin, None);
-                    Ok(AsyncS::PollAgain(CommandState::AttachingPager(fut, handler)))
+                    Ok(AsyncS::PollAgain(CommandState::AttachingPager(
+                        fut, handler,
+                    )))
                 } else {
                     Ok(AsyncS::NotReady(CommandState::SpawningPager(client, fut)))
                 }
             }
             CommandState::AttachingPager(mut fut, handler) => {
                 if let Async::Ready(client) = fut.poll()? {
-                    let msg_loop = MessageLoop::start(client, b"");  // terminator
+                    let msg_loop = MessageLoop::start(client, b""); // terminator
                     Ok(AsyncS::PollAgain(CommandState::Running(msg_loop, handler)))
                 } else {
                     Ok(AsyncS::NotReady(CommandState::AttachingPager(fut, handler)))
@@ -124,14 +130,15 @@ 
                     Ok(AsyncS::NotReady(CommandState::WaitingSystem(client, fut)))
                 }
             }
-            CommandState::Finished => panic!("poll ChgRunCommand after it's done")
+            CommandState::Finished => panic!("poll ChgRunCommand after it's done"),
         }
     }
 }
 
 fn process_message<C, H>(client: Client<C>, handler: H, msg: ChannelMessage) -> CommandPoll<C, H>
-    where C: Connection,
-          H: SystemHandler,
+where
+    C: Connection,
+    H: SystemHandler,
 {
     match msg {
         ChannelMessage::Data(b'r', data) => {
@@ -143,9 +150,10 @@ 
             let msg_loop = MessageLoop::resume(client);
             Ok(AsyncS::PollAgain(CommandState::Running(msg_loop, handler)))
         }
-        ChannelMessage::InputRequest(..) | ChannelMessage::LineRequest(..) => {
-            Err(io::Error::new(io::ErrorKind::InvalidData, "unsupported request"))
-        }
+        ChannelMessage::InputRequest(..) | ChannelMessage::LineRequest(..) => Err(io::Error::new(
+            io::ErrorKind::InvalidData,
+            "unsupported request",
+        )),
         ChannelMessage::SystemRequest(data) => {
             let (cmd_type, cmd_spec) = message::parse_command_spec(data)?;
             match cmd_type {
diff --git a/rust/chg/src/procutil.rs b/rust/chg/src/procutil.rs
--- a/rust/chg/src/procutil.rs
+++ b/rust/chg/src/procutil.rs
@@ -33,7 +33,7 @@ 
     }
     let r = unsafe { libc::fcntl(fd, libc::F_SETFL, flags & !libc::O_NONBLOCK) };
     if r < 0 {
-        return Err(io::Error::last_os_error())
+        return Err(io::Error::last_os_error());
     }
     Ok(())
 }
diff --git a/rust/chg/src/message.rs b/rust/chg/src/message.rs
--- a/rust/chg/src/message.rs
+++ b/rust/chg/src/message.rs
@@ -11,7 +11,7 @@ 
 use std::io;
 use std::os::unix::ffi::OsStrExt;
 
-pub use tokio_hglib::message::*;  // re-exports
+pub use tokio_hglib::message::*; // re-exports
 
 /// Shell command type requested by the server.
 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -42,7 +42,10 @@ 
         let mut s = l.splitn(2, |&c| c == b'=');
         let k = s.next().unwrap();
         let v = s.next().ok_or(new_parse_error("malformed env"))?;
-        envs.push((OsStr::from_bytes(k).to_owned(), OsStr::from_bytes(v).to_owned()));
+        envs.push((
+            OsStr::from_bytes(k).to_owned(),
+            OsStr::from_bytes(v).to_owned(),
+        ));
     }
 
     let spec = CommandSpec {
@@ -57,41 +60,54 @@ 
     match value {
         b"pager" => Ok(CommandType::Pager),
         b"system" => Ok(CommandType::System),
-        _ => Err(new_parse_error(format!("unknown command type: {}", decode_latin1(value)))),
+        _ => Err(new_parse_error(format!(
+            "unknown command type: {}",
+            decode_latin1(value)
+        ))),
     }
 }
 
 fn decode_latin1<S>(s: S) -> String
-    where S: AsRef<[u8]>,
+where
+    S: AsRef<[u8]>,
 {
     s.as_ref().iter().map(|&c| c as char).collect()
 }
 
 fn new_parse_error<E>(error: E) -> io::Error
-    where E: Into<Box<error::Error + Send + Sync>>,
+where
+    E: Into<Box<error::Error + Send + Sync>>,
 {
     io::Error::new(io::ErrorKind::InvalidData, error)
 }
 
 #[cfg(test)]
 mod tests {
+    use super::*;
     use std::os::unix::ffi::OsStringExt;
-    use super::*;
 
     #[test]
     fn parse_command_spec_good() {
-        let src = [b"pager".as_ref(),
-                   b"less -FRX".as_ref(),
-                   b"/tmp".as_ref(),
-                   b"LANG=C".as_ref(),
-                   b"HGPLAIN=".as_ref()].join(&0);
+        let src = [
+            b"pager".as_ref(),
+            b"less -FRX".as_ref(),
+            b"/tmp".as_ref(),
+            b"LANG=C".as_ref(),
+            b"HGPLAIN=".as_ref(),
+        ]
+        .join(&0);
         let spec = CommandSpec {
             command: os_string_from(b"less -FRX"),
             current_dir: os_string_from(b"/tmp"),
-            envs: vec![(os_string_from(b"LANG"), os_string_from(b"C")),
-                       (os_string_from(b"HGPLAIN"), os_string_from(b""))],
+            envs: vec![
+                (os_string_from(b"LANG"), os_string_from(b"C")),
+                (os_string_from(b"HGPLAIN"), os_string_from(b"")),
+            ],
         };
-        assert_eq!(parse_command_spec(Bytes::from(src)).unwrap(), (CommandType::Pager, spec));
+        assert_eq!(
+            parse_command_spec(Bytes::from(src)).unwrap(),
+            (CommandType::Pager, spec)
+        );
     }
 
     #[test]
diff --git a/rust/chg/src/main.rs b/rust/chg/src/main.rs
--- a/rust/chg/src/main.rs
+++ b/rust/chg/src/main.rs
@@ -9,9 +9,9 @@ 
 extern crate tokio;
 extern crate tokio_hglib;
 
-use chg::{ChgClientExt, ChgUiHandler};
 use chg::locator;
 use chg::procutil;
+use chg::{ChgClientExt, ChgUiHandler};
 use futures::sync::oneshot;
 use std::env;
 use std::io;
@@ -42,13 +42,19 @@ 
             // just make the output looks similar to chg of C
             let l = format!("{}", record.level()).to_lowercase();
             let t = self.start.elapsed();
-            writeln!(io::stderr(), "chg: {}: {}.{:06} {}",
-                     l, t.as_secs(), t.subsec_micros(), record.args()).unwrap_or(());
+            writeln!(
+                io::stderr(),
+                "chg: {}: {}.{:06} {}",
+                l,
+                t.as_secs(),
+                t.subsec_micros(),
+                record.args()
+            )
+            .unwrap_or(());
         }
     }
 
-    fn flush(&self) {
-    }
+    fn flush(&self) {}
 }
 
 fn main() {
@@ -71,28 +77,24 @@ 
     let handler = ChgUiHandler::new();
     let (result_tx, result_rx) = oneshot::channel();
     let fut = UnixClient::connect(sock_path)
-        .and_then(|client| {
-            client.set_current_dir(current_dir)
-        })
-        .and_then(|client| {
-            client.attach_io(io::stdin(), io::stdout(), io::stderr())
-        })
+        .and_then(|client| client.set_current_dir(current_dir))
+        .and_then(|client| client.attach_io(io::stdin(), io::stdout(), io::stderr()))
         .and_then(|client| {
             let pid = client.server_spec().process_id.unwrap();
             let pgid = client.server_spec().process_group_id;
             procutil::setup_signal_handler_once(pid, pgid)?;
             Ok(client)
         })
-        .and_then(|client| {
-            client.run_command_chg(handler, env::args_os().skip(1))
-        })
+        .and_then(|client| client.run_command_chg(handler, env::args_os().skip(1)))
         .map(|(_client, _handler, code)| {
             procutil::restore_signal_handler_once()?;
             Ok(code)
         })
-        .or_else(|err| Ok(Err(err)))  // pass back error to caller
+        .or_else(|err| Ok(Err(err))) // pass back error to caller
         .map(|res| result_tx.send(res).unwrap());
     tokio::run(fut);
-    result_rx.wait().unwrap_or(Err(io::Error::new(io::ErrorKind::Other,
-                                                  "no exit code set")))
+    result_rx.wait().unwrap_or(Err(io::Error::new(
+        io::ErrorKind::Other,
+        "no exit code set",
+    )))
 }
diff --git a/rust/chg/src/locator.rs b/rust/chg/src/locator.rs
--- a/rust/chg/src/locator.rs
+++ b/rust/chg/src/locator.rs
@@ -91,11 +91,16 @@ 
 /// Determines the default hg command.
 pub fn default_hg_command() -> OsString {
     // TODO: maybe allow embedding the path at compile time (or load from hgrc)
-    env::var_os("CHGHG").or(env::var_os("HG")).unwrap_or(OsStr::new("hg").to_owned())
+    env::var_os("CHGHG")
+        .or(env::var_os("HG"))
+        .unwrap_or(OsStr::new("hg").to_owned())
 }
 
 fn default_timeout() -> Duration {
-    let secs = env::var("CHGTIMEOUT").ok().and_then(|s| s.parse().ok()).unwrap_or(60);
+    let secs = env::var("CHGTIMEOUT")
+        .ok()
+        .and_then(|s| s.parse().ok())
+        .unwrap_or(60);
     Duration::from_secs(secs)
 }
 
@@ -103,19 +108,24 @@ 
 ///
 /// If the directory already exists, tests its permission.
 fn create_secure_dir<P>(path: P) -> io::Result<()>
-    where P: AsRef<Path>,
+where
+    P: AsRef<Path>,
 {
-    DirBuilder::new().mode(0o700).create(path.as_ref()).or_else(|err| {
-        if err.kind() == io::ErrorKind::AlreadyExists {
-            check_secure_dir(path).map(|_| ())
-        } else {
-            Err(err)
-        }
-    })
+    DirBuilder::new()
+        .mode(0o700)
+        .create(path.as_ref())
+        .or_else(|err| {
+            if err.kind() == io::ErrorKind::AlreadyExists {
+                check_secure_dir(path).map(|_| ())
+            } else {
+                Err(err)
+            }
+        })
 }
 
 fn check_secure_dir<P>(path: P) -> io::Result<P>
-    where P: AsRef<Path>,
+where
+    P: AsRef<Path>,
 {
     let a = fs::symlink_metadata(path.as_ref())?;
     if a.is_dir() && a.uid() == procutil::get_effective_uid() && (a.mode() & 0o777) == 0o700 {
diff --git a/rust/chg/src/clientext.rs b/rust/chg/src/clientext.rs
--- a/rust/chg/src/clientext.rs
+++ b/rust/chg/src/clientext.rs
@@ -9,8 +9,8 @@ 
 use std::os::unix::ffi::OsStrExt;
 use std::os::unix::io::AsRawFd;
 use std::path::Path;
+use tokio_hglib::protocol::OneShotRequest;
 use tokio_hglib::{Client, Connection};
-use tokio_hglib::protocol::OneShotRequest;
 
 use super::attachio::AttachIo;
 use super::message;
@@ -18,46 +18,54 @@ 
 use super::uihandler::SystemHandler;
 
 pub trait ChgClientExt<C>
-    where C: Connection + AsRawFd,
+where
+    C: Connection + AsRawFd,
 {
     /// Attaches the client file descriptors to the server.
     fn attach_io<I, O, E>(self, stdin: I, stdout: O, stderr: E) -> AttachIo<C, I, O, E>
-        where I: AsRawFd,
-              O: AsRawFd,
-              E: AsRawFd;
+    where
+        I: AsRawFd,
+        O: AsRawFd,
+        E: AsRawFd;
 
     /// Changes the working directory of the server.
     fn set_current_dir<P>(self, dir: P) -> OneShotRequest<C>
-        where P: AsRef<Path>;
+    where
+        P: AsRef<Path>;
 
     /// Runs the specified Mercurial command with cHg extension.
     fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H>
-        where I: IntoIterator<Item = P>,
-              P: AsRef<OsStr>,
-              H: SystemHandler;
+    where
+        I: IntoIterator<Item = P>,
+        P: AsRef<OsStr>,
+        H: SystemHandler;
 }
 
 impl<C> ChgClientExt<C> for Client<C>
-    where C: Connection + AsRawFd,
+where
+    C: Connection + AsRawFd,
 {
     fn attach_io<I, O, E>(self, stdin: I, stdout: O, stderr: E) -> AttachIo<C, I, O, E>
-        where I: AsRawFd,
-              O: AsRawFd,
-              E: AsRawFd,
+    where
+        I: AsRawFd,
+        O: AsRawFd,
+        E: AsRawFd,
     {
         AttachIo::with_client(self, stdin, stdout, Some(stderr))
     }
 
     fn set_current_dir<P>(self, dir: P) -> OneShotRequest<C>
-        where P: AsRef<Path>,
+    where
+        P: AsRef<Path>,
     {
         OneShotRequest::start_with_args(self, b"chdir", dir.as_ref().as_os_str().as_bytes())
     }
 
     fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H>
-        where I: IntoIterator<Item = P>,
-              P: AsRef<OsStr>,
-              H: SystemHandler,
+    where
+        I: IntoIterator<Item = P>,
+        P: AsRef<OsStr>,
+        H: SystemHandler,
     {
         ChgRunCommand::with_client(self, handler, message::pack_args_os(args))
     }
diff --git a/rust/chg/src/attachio.rs b/rust/chg/src/attachio.rs
--- a/rust/chg/src/attachio.rs
+++ b/rust/chg/src/attachio.rs
@@ -8,9 +8,9 @@ 
 use futures::{Async, Future, Poll};
 use std::io;
 use std::os::unix::io::AsRawFd;
-use tokio_hglib::{Client, Connection};
 use tokio_hglib::codec::ChannelMessage;
 use tokio_hglib::protocol::MessageLoop;
+use tokio_hglib::{Client, Connection};
 
 use super::message;
 use super::procutil;
@@ -28,7 +28,8 @@ 
 /// dispose of the client-side handle once attached.
 #[must_use = "futures do nothing unless polled"]
 pub struct AttachIo<C, I, O, E>
-    where C: Connection,
+where
+    C: Connection,
 {
     msg_loop: MessageLoop<C>,
     stdin: I,
@@ -37,23 +38,34 @@ 
 }
 
 impl<C, I, O, E> AttachIo<C, I, O, E>
-    where C: Connection + AsRawFd,
-          I: AsRawFd,
-          O: AsRawFd,
-          E: AsRawFd,
+where
+    C: Connection + AsRawFd,
+    I: AsRawFd,
+    O: AsRawFd,
+    E: AsRawFd,
 {
-    pub fn with_client(client: Client<C>, stdin: I, stdout: O, stderr: Option<E>)
-                       -> AttachIo<C, I, O, E> {
+    pub fn with_client(
+        client: Client<C>,
+        stdin: I,
+        stdout: O,
+        stderr: Option<E>,
+    ) -> AttachIo<C, I, O, E> {
         let msg_loop = MessageLoop::start(client, b"attachio");
-        AttachIo { msg_loop, stdin, stdout, stderr }
+        AttachIo {
+            msg_loop,
+            stdin,
+            stdout,
+            stderr,
+        }
     }
 }
 
 impl<C, I, O, E> Future for AttachIo<C, I, O, E>
-    where C: Connection + AsRawFd,
-          I: AsRawFd,
-          O: AsRawFd,
-          E: AsRawFd,
+where
+    C: Connection + AsRawFd,
+    I: AsRawFd,
+    O: AsRawFd,
+    E: AsRawFd,
 {
     type Item = Client<C>;
     type Error = io::Error;
@@ -67,8 +79,10 @@ 
                     if fd_cnt == 3 {
                         return Ok(Async::Ready(client));
                     } else {
-                        return Err(io::Error::new(io::ErrorKind::InvalidData,
-                                                  "unexpected attachio result"));
+                        return Err(io::Error::new(
+                            io::ErrorKind::InvalidData,
+                            "unexpected attachio result",
+                        ));
                     }
                 }
                 ChannelMessage::Data(..) => {
@@ -86,10 +100,13 @@ 
                     procutil::send_raw_fds(sock_fd, &[ifd, ofd, efd])?;
                     self.msg_loop = MessageLoop::resume(client);
                 }
-                ChannelMessage::InputRequest(..) | ChannelMessage::LineRequest(..) |
-                ChannelMessage::SystemRequest(..) => {
-                    return Err(io::Error::new(io::ErrorKind::InvalidData,
-                                              "unsupported request while attaching io"));
+                ChannelMessage::InputRequest(..)
+                | ChannelMessage::LineRequest(..)
+                | ChannelMessage::SystemRequest(..) => {
+                    return Err(io::Error::new(
+                        io::ErrorKind::InvalidData,
+                        "unsupported request while attaching io",
+                    ));
                 }
             }
         }