summary refs log tree commit diff
path: root/src/argument.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-03-01 18:07:56 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-02 17:41:31 -0800
commitc69f97542a6071f78d48a743ee94119a93bc9471 (patch)
tree69ee27de806bf460c108219d9d2c64bd633cf35d /src/argument.rs
parent5e1b46cbd8cb031a12c0fb20e94670f1007fd789 (diff)
downloadcrosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar
crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.gz
crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.bz2
crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.lz
crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.xz
crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.tar.zst
crosvm-c69f97542a6071f78d48a743ee94119a93bc9471.zip
error: Consistently use Display instead of error description()
The description method is deprecated and its signature forces less
helpful error messages than what Display can provide.

BUG=none
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: I27fc99d59d0ef457c5273dc53e4c563ef439c2c0
Reviewed-on: https://chromium-review.googlesource.com/1497735
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'src/argument.rs')
-rw-r--r--src/argument.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/argument.rs b/src/argument.rs
index baadb02..224a17c 100644
--- a/src/argument.rs
+++ b/src/argument.rs
@@ -40,7 +40,7 @@
 //! }
 //! ```
 
-use std::fmt;
+use std::fmt::{self, Display};
 use std::result;
 
 /// An error with argument parsing.
@@ -64,18 +64,20 @@ pub enum Error {
     PrintHelp,
 }
 
-impl fmt::Display for Error {
+impl Display for Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        use self::Error::*;
+
         match self {
-            Error::Syntax(s) => write!(f, "syntax error: {}", s),
-            Error::UnknownArgument(s) => write!(f, "unknown argument: {}", s),
-            Error::ExpectedArgument(s) => write!(f, "expected argument: {}", s),
-            Error::InvalidValue { value, expected } => {
+            Syntax(s) => write!(f, "syntax error: {}", s),
+            UnknownArgument(s) => write!(f, "unknown argument: {}", s),
+            ExpectedArgument(s) => write!(f, "expected argument: {}", s),
+            InvalidValue { value, expected } => {
                 write!(f, "invalid value {:?}: {}", value, expected)
             }
-            Error::TooManyArguments(s) => write!(f, "too many arguments: {}", s),
-            Error::ExpectedValue(s) => write!(f, "expected parameter value: {}", s),
-            Error::PrintHelp => write!(f, "help was requested"),
+            TooManyArguments(s) => write!(f, "too many arguments: {}", s),
+            ExpectedValue(s) => write!(f, "expected parameter value: {}", s),
+            PrintHelp => write!(f, "help was requested"),
         }
     }
 }