introduce `fallible_impl_from` lint with exeptions (#4609)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Alfredo Garcia 2022-06-20 00:57:41 -03:00 committed by GitHub
parent 3b3b59f71a
commit b7536c7f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 5 deletions

View File

@ -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,

View File

@ -1,7 +1,7 @@
//! Orchard key types.
//!
//! <https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents>
#![allow(clippy::fallible_impl_from)]
#![allow(dead_code)]
#[cfg(test)]
@ -308,7 +308,9 @@ impl From<SpendValidatingKey> for [u8; 32] {
impl From<SpendAuthorizingKey> for SpendValidatingKey {
fn from(ask: SpendAuthorizingKey) -> Self {
let sk = redpallas::SigningKey::<SpendAuth>::try_from(<[u8; 32]>::from(ask)).unwrap();
let sk = redpallas::SigningKey::<SpendAuth>::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))
}

View File

@ -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<AuthorizingKey> for [u8; 32] {
impl From<SpendAuthorizingKey> for AuthorizingKey {
fn from(ask: SpendAuthorizingKey) -> Self {
let sk = redjubjub::SigningKey::<SpendAuth>::try_from(<[u8; 32]>::from(ask)).unwrap();
let sk = redjubjub::SigningKey::<SpendAuth>::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))
}
}

View File

@ -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;

View File

@ -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,