Bug 1443853 - Avoid std::io::{Result,Error} renaming. r?jgraham draft
authorAndreas Tolfsen <ato@sny.no>
Wed, 07 Mar 2018 21:31:31 +0000
changeset 765979 b162adc88b152f365d66be40377bb126c1baeda9
parent 765978 3ed0b4106633426b46bfbac903bcd8fd6cf51495
child 765980 a57f837800f6de114b429524e02a102f22fa2c29
push id102198
push userbmo:ato@sny.no
push dateSun, 11 Mar 2018 16:03:30 +0000
reviewersjgraham
bugs1443853
milestone60.0a1
Bug 1443853 - Avoid std::io::{Result,Error} renaming. r?jgraham We can pick up std::io::Result and std::io::Error directly from the std::io namespace without having to rename them. MozReview-Commit-ID: 9Xz92HvcFpO
testing/mozbase/rust/mozrunner/src/runner.rs
--- a/testing/mozbase/rust/mozrunner/src/runner.rs
+++ b/testing/mozbase/rust/mozrunner/src/runner.rs
@@ -1,17 +1,18 @@
 use mozprofile::prefreader::PrefReaderError;
 use mozprofile::profile::Profile;
 use std::collections::HashMap;
 use std::convert::From;
 use std::env;
 use std::error::Error;
 use std::ffi::{OsStr, OsString};
 use std::fmt;
-use std::io::{Error as IoError, ErrorKind, Result as IoResult};
+use std::io;
+use std::io::ErrorKind;
 use std::path::{Path, PathBuf};
 use std::process::{Child, Command, Stdio};
 use std::process;
 
 pub trait Runner {
     type Process;
 
     fn arg<'a, S>(&'a mut self, arg: S) -> &'a mut Self
@@ -41,29 +42,29 @@ pub trait Runner {
     fn stderr<'a, T>(&'a mut self, stderr: T) -> &'a mut Self
     where
         T: Into<Stdio>;
 
     fn start(self) -> Result<Self::Process, RunnerError>;
 }
 
 pub trait RunnerProcess {
-    fn status(&mut self) -> IoResult<Option<process::ExitStatus>>;
+    fn status(&mut self) -> io::Result<Option<process::ExitStatus>>;
 
     /// Determine if the process is still running.
     fn running(&mut self) -> bool;
 
     /// Forces the process to exit and returns the exit status.  This is
     /// equivalent to sending a SIGKILL on Unix platforms.
-    fn kill(&mut self) -> IoResult<process::ExitStatus>;
+    fn kill(&mut self) -> io::Result<process::ExitStatus>;
 }
 
 #[derive(Debug)]
 pub enum RunnerError {
-    Io(IoError),
+    Io(io::Error),
     PrefReader(PrefReaderError),
 }
 
 impl fmt::Display for RunnerError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         self.description().fmt(f)
     }
 }
@@ -84,18 +85,18 @@ impl Error for RunnerError {
     fn cause(&self) -> Option<&Error> {
         Some(match *self {
             RunnerError::Io(ref err) => err as &Error,
             RunnerError::PrefReader(ref err) => err as &Error,
         })
     }
 }
 
-impl From<IoError> for RunnerError {
-    fn from(value: IoError) -> RunnerError {
+impl From<io::Error> for RunnerError {
+    fn from(value: io::Error) -> RunnerError {
         RunnerError::Io(value)
     }
 }
 
 impl From<PrefReaderError> for RunnerError {
     fn from(value: PrefReaderError) -> RunnerError {
         RunnerError::PrefReader(value)
     }
@@ -103,25 +104,25 @@ impl From<PrefReaderError> for RunnerErr
 
 #[derive(Debug)]
 pub struct FirefoxProcess {
     process: Child,
     profile: Profile,
 }
 
 impl RunnerProcess for FirefoxProcess {
-    fn status(&mut self) -> IoResult<Option<process::ExitStatus>> {
+    fn status(&mut self) -> io::Result<Option<process::ExitStatus>> {
         self.process.try_wait()
     }
 
     fn running(&mut self) -> bool {
         self.status().unwrap().is_none()
     }
 
-    fn kill(&mut self) -> IoResult<process::ExitStatus> {
+    fn kill(&mut self) -> io::Result<process::ExitStatus> {
         self.process.kill()?;
         self.process.wait()
     }
 }
 
 #[derive(Debug)]
 pub struct FirefoxRunner {
     binary: PathBuf,