mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-29 01:31:33 +00:00
fix(identity): handle warnings related to feature flags
Some of the feature-flags weren't set correctly and thus produced warnings for unused code. We can fix this by using absolute paths instead of imports and allow `dead_code` for the error constructor. It might be possible to write a correct `cfg` for this as well but I think it will be very verbose, hence I didn't bother. Pull-Request: #3859.
This commit is contained in:
@ -166,6 +166,7 @@ pub struct OtherVariantError {
|
||||
}
|
||||
|
||||
impl OtherVariantError {
|
||||
#[allow(dead_code)] // This is used but the cfg is too complicated to write ..
|
||||
pub(crate) fn new(actual: KeyType) -> OtherVariantError {
|
||||
OtherVariantError { actual }
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
use crate::error::OtherVariantError;
|
||||
use crate::error::{DecodingError, SigningError};
|
||||
use crate::{proto, KeyType};
|
||||
use crate::proto;
|
||||
use quick_protobuf::{BytesReader, Writer};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
@ -322,11 +322,11 @@ impl TryInto<ed25519::Keypair> for Keypair {
|
||||
match self {
|
||||
Keypair::Ed25519(inner) => Ok(inner),
|
||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
||||
Keypair::Rsa(_) => Err(OtherVariantError::new(KeyType::RSA)),
|
||||
Keypair::Rsa(_) => Err(OtherVariantError::new(crate::KeyType::RSA)),
|
||||
#[cfg(feature = "secp256k1")]
|
||||
Keypair::Secp256k1(_) => Err(OtherVariantError::new(KeyType::Secp256k1)),
|
||||
Keypair::Secp256k1(_) => Err(OtherVariantError::new(crate::KeyType::Secp256k1)),
|
||||
#[cfg(feature = "ecdsa")]
|
||||
Keypair::Ecdsa(_) => Err(OtherVariantError::new(KeyType::Ecdsa)),
|
||||
Keypair::Ecdsa(_) => Err(OtherVariantError::new(crate::KeyType::Ecdsa)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -340,11 +340,11 @@ impl TryInto<ecdsa::Keypair> for Keypair {
|
||||
match self {
|
||||
Keypair::Ecdsa(inner) => Ok(inner),
|
||||
#[cfg(feature = "ed25519")]
|
||||
Keypair::Ed25519(_) => Err(OtherVariantError::new(KeyType::Ed25519)),
|
||||
Keypair::Ed25519(_) => Err(OtherVariantError::new(crate::KeyType::Ed25519)),
|
||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
||||
Keypair::Rsa(_) => Err(OtherVariantError::new(KeyType::RSA)),
|
||||
Keypair::Rsa(_) => Err(OtherVariantError::new(crate::KeyType::RSA)),
|
||||
#[cfg(feature = "secp256k1")]
|
||||
Keypair::Secp256k1(_) => Err(OtherVariantError::new(KeyType::Secp256k1)),
|
||||
Keypair::Secp256k1(_) => Err(OtherVariantError::new(crate::KeyType::Secp256k1)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -358,11 +358,11 @@ impl TryInto<secp256k1::Keypair> for Keypair {
|
||||
match self {
|
||||
Keypair::Secp256k1(inner) => Ok(inner),
|
||||
#[cfg(feature = "ed25519")]
|
||||
Keypair::Ed25519(_) => Err(OtherVariantError::new(KeyType::Ed25519)),
|
||||
Keypair::Ed25519(_) => Err(OtherVariantError::new(crate::KeyType::Ed25519)),
|
||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
||||
Keypair::Rsa(_) => Err(OtherVariantError::new(KeyType::RSA)),
|
||||
Keypair::Rsa(_) => Err(OtherVariantError::new(crate::KeyType::RSA)),
|
||||
#[cfg(feature = "ecdsa")]
|
||||
Keypair::Ecdsa(_) => Err(OtherVariantError::new(KeyType::Ecdsa)),
|
||||
Keypair::Ecdsa(_) => Err(OtherVariantError::new(crate::KeyType::Ecdsa)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -376,11 +376,11 @@ impl TryInto<rsa::Keypair> for Keypair {
|
||||
match self {
|
||||
Keypair::Rsa(inner) => Ok(inner),
|
||||
#[cfg(feature = "ed25519")]
|
||||
Keypair::Ed25519(_) => Err(OtherVariantError::new(KeyType::Ed25519)),
|
||||
Keypair::Ed25519(_) => Err(OtherVariantError::new(crate::KeyType::Ed25519)),
|
||||
#[cfg(feature = "secp256k1")]
|
||||
Keypair::Secp256k1(_) => Err(OtherVariantError::new(KeyType::Secp256k1)),
|
||||
Keypair::Secp256k1(_) => Err(OtherVariantError::new(crate::KeyType::Secp256k1)),
|
||||
#[cfg(feature = "ecdsa")]
|
||||
Keypair::Ecdsa(_) => Err(OtherVariantError::new(KeyType::Ecdsa)),
|
||||
Keypair::Ecdsa(_) => Err(OtherVariantError::new(crate::KeyType::Ecdsa)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -597,11 +597,11 @@ impl TryInto<ed25519::PublicKey> for PublicKey {
|
||||
match self {
|
||||
PublicKey::Ed25519(inner) => Ok(inner),
|
||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
||||
PublicKey::Rsa(_) => Err(OtherVariantError::new(KeyType::RSA)),
|
||||
PublicKey::Rsa(_) => Err(OtherVariantError::new(crate::KeyType::RSA)),
|
||||
#[cfg(feature = "secp256k1")]
|
||||
PublicKey::Secp256k1(_) => Err(OtherVariantError::new(KeyType::Secp256k1)),
|
||||
PublicKey::Secp256k1(_) => Err(OtherVariantError::new(crate::KeyType::Secp256k1)),
|
||||
#[cfg(feature = "ecdsa")]
|
||||
PublicKey::Ecdsa(_) => Err(OtherVariantError::new(KeyType::Ecdsa)),
|
||||
PublicKey::Ecdsa(_) => Err(OtherVariantError::new(crate::KeyType::Ecdsa)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -615,11 +615,11 @@ impl TryInto<ecdsa::PublicKey> for PublicKey {
|
||||
match self {
|
||||
PublicKey::Ecdsa(inner) => Ok(inner),
|
||||
#[cfg(feature = "ed25519")]
|
||||
PublicKey::Ed25519(_) => Err(OtherVariantError::new(KeyType::Ed25519)),
|
||||
PublicKey::Ed25519(_) => Err(OtherVariantError::new(crate::KeyType::Ed25519)),
|
||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
||||
PublicKey::Rsa(_) => Err(OtherVariantError::new(KeyType::RSA)),
|
||||
PublicKey::Rsa(_) => Err(OtherVariantError::new(crate::KeyType::RSA)),
|
||||
#[cfg(feature = "secp256k1")]
|
||||
PublicKey::Secp256k1(_) => Err(OtherVariantError::new(KeyType::Secp256k1)),
|
||||
PublicKey::Secp256k1(_) => Err(OtherVariantError::new(crate::KeyType::Secp256k1)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -633,11 +633,11 @@ impl TryInto<secp256k1::PublicKey> for PublicKey {
|
||||
match self {
|
||||
PublicKey::Secp256k1(inner) => Ok(inner),
|
||||
#[cfg(feature = "ed25519")]
|
||||
PublicKey::Ed25519(_) => Err(OtherVariantError::new(KeyType::Ed25519)),
|
||||
PublicKey::Ed25519(_) => Err(OtherVariantError::new(crate::KeyType::Ed25519)),
|
||||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
|
||||
PublicKey::Rsa(_) => Err(OtherVariantError::new(KeyType::RSA)),
|
||||
PublicKey::Rsa(_) => Err(OtherVariantError::new(crate::KeyType::RSA)),
|
||||
#[cfg(feature = "ecdsa")]
|
||||
PublicKey::Ecdsa(_) => Err(OtherVariantError::new(KeyType::Ecdsa)),
|
||||
PublicKey::Ecdsa(_) => Err(OtherVariantError::new(crate::KeyType::Ecdsa)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -651,11 +651,11 @@ impl TryInto<rsa::PublicKey> for PublicKey {
|
||||
match self {
|
||||
PublicKey::Rsa(inner) => Ok(inner),
|
||||
#[cfg(feature = "ed25519")]
|
||||
PublicKey::Ed25519(_) => Err(OtherVariantError::new(KeyType::Ed25519)),
|
||||
PublicKey::Ed25519(_) => Err(OtherVariantError::new(crate::KeyType::Ed25519)),
|
||||
#[cfg(feature = "secp256k1")]
|
||||
PublicKey::Secp256k1(_) => Err(OtherVariantError::new(KeyType::Secp256k1)),
|
||||
PublicKey::Secp256k1(_) => Err(OtherVariantError::new(crate::KeyType::Secp256k1)),
|
||||
#[cfg(feature = "ecdsa")]
|
||||
PublicKey::Ecdsa(_) => Err(OtherVariantError::new(KeyType::Ecdsa)),
|
||||
PublicKey::Ecdsa(_) => Err(OtherVariantError::new(crate::KeyType::Ecdsa)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user