From 7056e446916d30c83760f4d5507761b8f3273486 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 20 Apr 2020 09:43:20 +1000 Subject: [PATCH 1/3] Remove unused parentheses As per Rust's convention, this allows the removal of a build warning. --- lightning/src/chain/keysinterface.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning/src/chain/keysinterface.rs b/lightning/src/chain/keysinterface.rs index 58bdd722609..fb163966f9a 100644 --- a/lightning/src/chain/keysinterface.rs +++ b/lightning/src/chain/keysinterface.rs @@ -620,6 +620,6 @@ impl KeysInterface for KeysManager { let child_privkey = self.channel_id_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32).expect("key space exhausted")).expect("Your RNG is busted"); sha.input(&child_privkey.private_key.key[..]); - (Sha256::from_engine(sha).into_inner()) + Sha256::from_engine(sha).into_inner() } } From 8fe3fca3e1f418ed6f744d32bafe02d44362c4b8 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 20 Apr 2020 10:38:12 +1000 Subject: [PATCH 2/3] Allow use of deprecated `Error::description` for `DecodeError` While `Error::description()` usage is deprecated, it allows us to define static string slices for the various error messages. Until more advance formatting is needed, it is better to use `description` instead of the `Display` trait as recommended by Rust. This also removes a build warning. --- lightning/src/ln/msgs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 9698798c22e..5e2429f9a07 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -702,6 +702,7 @@ impl Error for DecodeError { } impl fmt::Display for DecodeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[allow(deprecated)] f.write_str(self.description()) } } From 84677cd826e961c98f5b486e392ef768b8fd0623 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 20 Apr 2020 10:21:24 +1000 Subject: [PATCH 3/3] Allow use of deprecated `Error::description` for `io::Error` `ToString::to_string()` should be favored in place of the deprecated `Error::description()` trait function. However, using `to_string` adds a heap allocation due to its use of dynamic type `String`. It should be noted that std::io::Error provides a richer context in the `Display` trait implementation in the deprecated `description` one. By electing to use `description`, we consciously choose to stay in the stack over usability. This also removes a build warning. --- lightning/src/ln/msgs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 5e2429f9a07..e7fda0090fe 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -696,6 +696,7 @@ impl Error for DecodeError { DecodeError::InvalidValue => "Nonsense bytes didn't map to the type they were interpreted as", DecodeError::ShortRead => "Packet extended beyond the provided bytes", DecodeError::BadLengthDescriptor => "A length descriptor in the packet didn't describe the later data correctly", + #[allow(deprecated)] DecodeError::Io(ref e) => e.description(), } }