diff --git a/.cargo/config.toml b/.cargo/config.toml index f126caa6..f6f39cbb 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -50,7 +50,10 @@ rustflags = [ "-Aclippy::try_err", # Links in public docs can point to private items. - "-Arustdoc::private_intra_doc_links" + "-Arustdoc::private_intra_doc_links", + + # Panics + "-Wclippy::fallible_impl_from", # TODOs: # `cargo fix` might help do these fixes, diff --git a/zebra-chain/src/orchard/keys.rs b/zebra-chain/src/orchard/keys.rs index e0601b6f..11ffba04 100644 --- a/zebra-chain/src/orchard/keys.rs +++ b/zebra-chain/src/orchard/keys.rs @@ -1,7 +1,7 @@ //! Orchard key types. //! //! - +#![allow(clippy::fallible_impl_from)] #![allow(dead_code)] #[cfg(test)] @@ -308,7 +308,9 @@ impl From for [u8; 32] { impl From for SpendValidatingKey { fn from(ask: SpendAuthorizingKey) -> Self { - let sk = redpallas::SigningKey::::try_from(<[u8; 32]>::from(ask)).unwrap(); + let sk = redpallas::SigningKey::::try_from(<[u8; 32]>::from(ask)).expect( + "a scalar converted to byte array and then converted back to a scalar should not fail", + ); Self(redpallas::VerificationKey::from(&sk)) } diff --git a/zebra-chain/src/sapling/keys.rs b/zebra-chain/src/sapling/keys.rs index 897dd309..cd3a3f27 100644 --- a/zebra-chain/src/sapling/keys.rs +++ b/zebra-chain/src/sapling/keys.rs @@ -8,6 +8,7 @@ //! [ps]: https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents //! [3.1]: https://zips.z.cash/protocol/protocol.pdf#addressesandkeys #![allow(clippy::unit_arg)] +#![allow(clippy::fallible_impl_from)] #![allow(dead_code)] #[cfg(test)] @@ -507,7 +508,9 @@ impl From for [u8; 32] { impl From for AuthorizingKey { fn from(ask: SpendAuthorizingKey) -> Self { - let sk = redjubjub::SigningKey::::try_from(<[u8; 32]>::from(ask)).unwrap(); + let sk = redjubjub::SigningKey::::try_from(<[u8; 32]>::from(ask)).expect( + "a scalar converted to byte array and then converted back to a scalar should not fail", + ); Self(redjubjub::VerificationKey::from(&sk)) } } diff --git a/zebra-chain/src/work/u256.rs b/zebra-chain/src/work/u256.rs index 486fcf1e..1897f9ec 100644 --- a/zebra-chain/src/work/u256.rs +++ b/zebra-chain/src/work/u256.rs @@ -3,6 +3,7 @@ // it raises a lot of issues in the macro. #![allow(clippy::all)] #![allow(clippy::range_plus_one)] +#![allow(clippy::fallible_impl_from)] use uint::construct_uint; diff --git a/zebra-network/src/protocol/external/message.rs b/zebra-network/src/protocol/external/message.rs index 11ee9e55..743212b4 100644 --- a/zebra-network/src/protocol/external/message.rs +++ b/zebra-network/src/protocol/external/message.rs @@ -352,7 +352,11 @@ where // use specific varieties of `RejectReason`. ccode: RejectReason::Other, - reason: e.source().unwrap().to_string(), + reason: if let Some(reason) = e.source() { + reason.to_string() + } else { + String::from("") + }, // Allow this to be overridden but not populated by default, methinks. data: None,