Repository: evansmurithi/cloak (language: rust)

Issue:
Deprecate failure
https://rustsec.org/advisories/RUSTSEC-2020-0036.html


Discussion / hints:

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index 6eb628c..2597628 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,20 +1,5 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
-[[package]]
-name = "addr2line"
-version = "0.14.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7"
-dependencies = [
- "gimli",
-]
-
-[[package]]
-name = "adler"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
-
 [[package]]
 name = "aho-corasick"
 version = "0.7.15"
@@ -89,20 +74,6 @@ version = "1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
 
-[[package]]
-name = "backtrace"
-version = "0.3.55"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598"
-dependencies = [
- "addr2line",
- "cfg-if 1.0.0",
- "libc",
- "miniz_oxide",
- "object",
- "rustc-demangle",
-]
-
 [[package]]
 name = "base64"
 version = "0.13.0"
@@ -184,13 +155,13 @@ dependencies = [
  "data-encoding",
  "dirs",
  "escargot",
- "failure",
  "lazy_static",
  "open",
  "predicates",
  "ring",
  "serde",
  "serde_derive",
+ "thiserror",
  "toml",
 ]
 
@@ -261,28 +232,6 @@ dependencies = [
  "serde_json",
 ]
 
-[[package]]
-name = "failure"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
-dependencies = [
- "backtrace",
- "failure_derive",
-]
-
-[[package]]
-name = "failure_derive"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "synstructure",
-]
-
 [[package]]
 name = "float-cmp"
 version = "0.8.0"
@@ -320,12 +269,6 @@ dependencies = [
  "wasi 0.10.1+wasi-snapshot-preview1",
 ]
 
-[[package]]
-name = "gimli"
-version = "0.23.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
-
 [[package]]
 name = "globset"
 version = "0.4.6"
@@ -418,16 +361,6 @@ version = "2.3.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
 
-[[package]]
-name = "miniz_oxide"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d"
-dependencies = [
- "adler",
- "autocfg",
-]
-
 [[package]]
 name = "normalize-line-endings"
 version = "0.3.0"
@@ -443,12 +376,6 @@ dependencies = [
  "autocfg",
 ]
 
-[[package]]
-name = "object"
-version = "0.22.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
-
 [[package]]
 name = "once_cell"
 version = "1.5.2"
@@ -637,12 +564,6 @@ dependencies = [
  "crossbeam-utils",
 ]
 
-[[package]]
-name = "rustc-demangle"
-version = "0.1.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
-
 [[package]]
 name = "ryu"
 version = "1.0.5"
@@ -712,18 +633,6 @@ dependencies = [
  "unicode-xid",
 ]
 
-[[package]]
-name = "synstructure"
-version = "0.12.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "unicode-xid",
-]
-
 [[package]]
 name = "tempfile"
 version = "3.2.0"
@@ -747,6 +656,26 @@ dependencies = [
  "unicode-width",
 ]
 
+[[package]]
+name = "thiserror"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "thread_local"
 version = "1.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index a7c7cbf..5514a52 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,7 +20,7 @@ serde = "1.0.119"
 serde_derive = "1.0.119"
 open = "1.4.0"
 dirs = "3.0.1"
-failure = "0.1.7"
+thiserror = "1.0.23"
 lazy_static = "1.4.0"
 
 [dev-dependencies]
diff --git a/src/errors.rs b/src/errors.rs
index 661830a..d4af334 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -1,44 +1,27 @@
 use data_encoding::DecodeError;
 use std::io;
 use std::result;
+use thiserror::Error as ThisError;
 use toml::{de, ser};
 
 // `Result` returned by this crate
 pub type Result<T> = result::Result<T, Error>;
 
 // `cloak` error
-#[derive(Debug, Fail)]
+#[derive(Debug, ThisError)]
 pub enum Error {
-    #[fail(display = "Decoding failed for key '{}': {}", key, cause)]
+    #[error("Decoding failed for key '{}': {}", key, cause)]
     KeyDecode {
         key: String,
         cause: Box<DecodeError>,
     },
 
-    #[fail(display = "I/O error: {}", _0)]
-    Io(#[cause] io::Error),
+    #[error("I/O error: {}", _0)]
+    Io(#[from] io::Error),
 
-    #[fail(display = "Could not write to accounts file: {}", _0)]
-    TomlSerialize(#[cause] ser::Error),
+    #[error("Could not write to accounts file: {}", _0)]
+    TomlSerialize(#[from] ser::Error),
 
-    #[fail(display = "Could not parse the accounts file: {}", _0)]
-    TomlDeserialize(#[cause] de::Error),
-}
-
-impl From<io::Error> for Error {
-    fn from(err: io::Error) -> Self {
-        Error::Io(err)
-    }
-}
-
-impl From<de::Error> for Error {
-    fn from(err: de::Error) -> Self {
-        Error::TomlDeserialize(err)
-    }
-}
-
-impl From<ser::Error> for Error {
-    fn from(err: ser::Error) -> Self {
-        Error::TomlSerialize(err)
-    }
+    #[error("Could not parse the accounts file: {}", _0)]
+    TomlDeserialize(#[from] de::Error),
 }
diff --git a/src/main.rs b/src/main.rs
index e82169e..727388a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,10 +3,9 @@ extern crate clap;
 extern crate data_encoding;
 extern crate dirs as dirs_rs;
 extern crate open;
-#[macro_use]
-extern crate failure;
 extern crate ring;
 extern crate serde;
+extern crate thiserror;
 #[macro_use]
 extern crate serde_derive;
 extern crate toml;


Test patch: