Patchwork D8955: rhg: fix clippy warnings

login
register
mail settings
Submitter phabricator
Date Aug. 26, 2020, 1:23 p.m.
Message ID <differential-rev-PHID-DREV-vk5lajcnztxx675ap3eq-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47054/
State Superseded
Headers show

Comments

phabricator - Aug. 26, 2020, 1:23 p.m.
acezar created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/rhg/src/error.rs
  rust/rhg/src/ui.rs

CHANGE DETAILS




To: acezar, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/rhg/src/ui.rs b/rust/rhg/src/ui.rs
--- a/rust/rhg/src/ui.rs
+++ b/rust/rhg/src/ui.rs
@@ -34,22 +34,18 @@ 
     pub fn write_stdout(&self, bytes: &[u8]) -> Result<(), UiError> {
         let mut stdout = self.stdout.lock();
 
-        stdout
-            .write_all(bytes)
-            .or_else(|e| handle_stdout_error(e))?;
+        stdout.write_all(bytes).or_else(handle_stdout_error)?;
 
-        stdout.flush().or_else(|e| handle_stdout_error(e))
+        stdout.flush().or_else(handle_stdout_error)
     }
 
     /// Write bytes to stderr
     pub fn write_stderr(&self, bytes: &[u8]) -> Result<(), UiError> {
         let mut stderr = self.stderr.lock();
 
-        stderr
-            .write_all(bytes)
-            .or_else(|e| handle_stderr_error(e))?;
+        stderr.write_all(bytes).or_else(handle_stderr_error)?;
 
-        stderr.flush().or_else(|e| handle_stderr_error(e))
+        stderr.flush().or_else(handle_stderr_error)
     }
 }
 
@@ -66,14 +62,12 @@ 
 
     /// Write bytes to stdout buffer
     pub fn write_all(&mut self, bytes: &[u8]) -> Result<(), UiError> {
-        self.buf
-            .write_all(bytes)
-            .or_else(|e| handle_stdout_error(e))
+        self.buf.write_all(bytes).or_else(handle_stdout_error)
     }
 
     /// Flush bytes to stdout
     pub fn flush(&mut self) -> Result<(), UiError> {
-        self.buf.flush().or_else(|e| handle_stdout_error(e))
+        self.buf.flush().or_else(handle_stdout_error)
     }
 }
 
@@ -88,9 +82,9 @@ 
 
     stderr
         .write_all(&[b"abort: ", error.to_string().as_bytes(), b"\n"].concat())
-        .map_err(|e| UiError::StderrError(e))?;
+        .map_err(UiError::StderrError)?;
 
-    stderr.flush().map_err(|e| UiError::StderrError(e))?;
+    stderr.flush().map_err(UiError::StderrError)?;
 
     Err(UiError::StdoutError(error))
 }
diff --git a/rust/rhg/src/error.rs b/rust/rhg/src/error.rs
--- a/rust/rhg/src/error.rs
+++ b/rust/rhg/src/error.rs
@@ -69,7 +69,7 @@ 
 
 impl CommandError {
     /// Exist the process with the corresponding exit code.
-    pub fn exit(&self) -> () {
+    pub fn exit(&self) {
         std::process::exit(self.kind.get_exit_code())
     }