diff --git a/build.rs b/build.rs index 68ce68987..3932dd201 100644 --- a/build.rs +++ b/build.rs @@ -157,7 +157,7 @@ const RING_PERL_INCLUDES: &[&str] = const RING_BUILD_FILE: &[&str] = &["build.rs"]; -const PREGENERATED: &'static str = "pregenerated"; +const PREGENERATED: &str = "pregenerated"; fn c_flags(target: &Target) -> &'static [&'static str] { if target.env != MSVC { @@ -245,10 +245,10 @@ const ASM_TARGETS: &[(&str, Option<&str>, &str)] = &[ ("arm", None, "linux32"), ]; -const WINDOWS: &'static str = "windows"; -const MSVC: &'static str = "msvc"; -const MSVC_OBJ_OPT: &'static str = "/Fo"; -const MSVC_OBJ_EXT: &'static str = "obj"; +const WINDOWS: &str = "windows"; +const MSVC: &str = "msvc"; +const MSVC_OBJ_OPT: &str = "/Fo"; +const MSVC_OBJ_EXT: &str = "obj"; fn main() { if let Ok(package_name) = std::env::var("CARGO_PKG_NAME") { diff --git a/src/aead/block.rs b/src/aead/block.rs index 5294e880e..6cf692377 100644 --- a/src/aead/block.rs +++ b/src/aead/block.rs @@ -72,12 +72,12 @@ impl Block { } } -impl<'a> From<&'a [u8; BLOCK_LEN]> for Block { +impl From<&'_ [u8; BLOCK_LEN]> for Block { #[inline] fn from(bytes: &[u8; BLOCK_LEN]) -> Self { unsafe { core::mem::transmute_copy(bytes) } } } -impl<'a> From_<&'a [u8; 2 * BLOCK_LEN]> for [Block; 2] { +impl From_<&'_ [u8; 2 * BLOCK_LEN]> for [Block; 2] { #[inline] fn from_(bytes: &[u8; 2 * BLOCK_LEN]) -> Self { unsafe { core::mem::transmute_copy(bytes) } } } diff --git a/src/aead/chacha.rs b/src/aead/chacha.rs index 240e780db..3184a716e 100644 --- a/src/aead/chacha.rs +++ b/src/aead/chacha.rs @@ -24,7 +24,7 @@ use libc::size_t; #[repr(C)] pub struct Key([Block; KEY_BLOCKS]); -impl<'a> From<&'a [u8; KEY_LEN]> for Key { +impl From<&'_ [u8; KEY_LEN]> for Key { fn from(value: &[u8; KEY_LEN]) -> Self { Key(<[Block; KEY_BLOCKS]>::from_(value)) } } diff --git a/src/agreement.rs b/src/agreement.rs index 55ace064b..a2cb8584c 100644 --- a/src/agreement.rs +++ b/src/agreement.rs @@ -99,7 +99,7 @@ pub struct EphemeralPrivateKey { alg: &'static Algorithm, } -impl<'a> EphemeralPrivateKey { +impl EphemeralPrivateKey { /// Generate a new ephemeral private key for the given algorithm. pub fn generate( alg: &'static Algorithm, rng: &rand::SecureRandom, @@ -126,7 +126,7 @@ impl<'a> EphemeralPrivateKey { } #[cfg(test)] - pub fn bytes(&'a self) -> &'a [u8] { self.private_key.bytes_less_safe() } + pub fn bytes(&self) -> &[u8] { self.private_key.bytes_less_safe() } } /// A public key for key agreement. diff --git a/src/debug.rs b/src/debug.rs index b9b1fedeb..5becf3236 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -62,7 +62,7 @@ pub(crate) fn write_hex_tuple( struct HexStr<'a>(pub &'a [u8]); -impl<'a> core::fmt::Debug for HexStr<'a> { +impl core::fmt::Debug for HexStr<'_> { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { fmt.write_str("\"")?; write_hex_bytes(fmt, self.0)?; diff --git a/src/ec/curve25519/ed25519/signing.rs b/src/ec/curve25519/ed25519/signing.rs index b0e879ef0..93b459cb9 100644 --- a/src/ec/curve25519/ed25519/signing.rs +++ b/src/ec/curve25519/ed25519/signing.rs @@ -42,7 +42,7 @@ pub struct KeyPair { derive_debug_via_field!(KeyPair, stringify!(Ed25519KeyPair), public_key); -impl<'a> KeyPair { +impl KeyPair { /// Generates a new key pair and returns the key pair serialized as a /// PKCS#8 document. /// diff --git a/src/ec/suite_b/ecdh.rs b/src/ec/suite_b/ecdh.rs index 0488c6b0b..a82967403 100644 --- a/src/ec/suite_b/ecdh.rs +++ b/src/ec/suite_b/ecdh.rs @@ -140,12 +140,7 @@ mod tests { use crate::{agreement, ec, limb, test}; use core; - static SUPPORTED_SUITE_B_ALGS: [( - &'static str, - &'static agreement::Algorithm, - &'static ec::Curve, - &'static ops::CommonOps, - ); 2] = [ + static SUPPORTED_SUITE_B_ALGS: [(&str, &agreement::Algorithm, &ec::Curve, &ops::CommonOps); 2] = [ ( "P-256", &agreement::ECDH_P256, diff --git a/src/ec/suite_b/ecdsa/signing.rs b/src/ec/suite_b/ecdsa/signing.rs index 4a8a4e1ca..86b93e062 100644 --- a/src/ec/suite_b/ecdsa/signing.rs +++ b/src/ec/suite_b/ecdsa/signing.rs @@ -36,8 +36,7 @@ pub struct Algorithm { private_key_ops: &'static PrivateKeyOps, digest_alg: &'static digest::Algorithm, pkcs8_template: &'static pkcs8::Template, - format_rs: - for<'a> fn(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &'a mut [u8]) -> usize, + format_rs: fn(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize, id: AlgorithmID, } @@ -246,9 +245,7 @@ impl AsRef<[u8]> for PublicKey { fn as_ref(&self) -> &[u8] { self.0.as_ref() } } -fn format_rs_fixed<'a>( - ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &'a mut [u8], -) -> usize { +fn format_rs_fixed(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize { let scalar_len = ops.scalar_bytes_len(); let (r_out, rest) = out.split_at_mut(scalar_len); @@ -260,7 +257,7 @@ fn format_rs_fixed<'a>( 2 * scalar_len } -fn format_rs_asn1<'a>(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &'a mut [u8]) -> usize { +fn format_rs_asn1(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize { // This assumes `a` is not zero since neither `r` or `s` is allowed to be // zero. fn format_integer_tlv(ops: &ScalarOps, a: &Scalar, out: &mut [u8]) -> usize { diff --git a/src/io/der.rs b/src/io/der.rs index a567a85f3..d689cdde3 100644 --- a/src/io/der.rs +++ b/src/io/der.rs @@ -219,9 +219,9 @@ mod tests { assert!(r.is_err()); } - static ZERO_INTEGER: &'static [u8] = &[0x02, 0x01, 0x00]; + static ZERO_INTEGER: &[u8] = &[0x02, 0x01, 0x00]; - static GOOD_POSITIVE_INTEGERS: &'static [(&'static [u8], u8)] = &[ + static GOOD_POSITIVE_INTEGERS: &[(&[u8], u8)] = &[ (&[0x02, 0x01, 0x01], 0x01), (&[0x02, 0x01, 0x02], 0x02), (&[0x02, 0x01, 0x7e], 0x7e), @@ -234,7 +234,7 @@ mod tests { (&[0x02, 0x02, 0x00, 0xff], 0xff), ]; - static BAD_NONNEGATIVE_INTEGERS: &'static [&'static [u8]] = &[ + static BAD_NONNEGATIVE_INTEGERS: &[&[u8]] = &[ &[], // At end of input &[0x02], // Tag only &[0x02, 0x00], // Empty value diff --git a/src/pbkdf2.rs b/src/pbkdf2.rs index cfe8f5915..2cc43f06f 100644 --- a/src/pbkdf2.rs +++ b/src/pbkdf2.rs @@ -33,7 +33,7 @@ //! use ring::{digest, pbkdf2}; //! use std::{collections::HashMap, num::NonZeroU32}; //! -//! static DIGEST_ALG: &'static digest::Algorithm = &digest::SHA256; +//! static DIGEST_ALG: &digest::Algorithm = &digest::SHA256; //! const CREDENTIAL_LEN: usize = digest::SHA256_OUTPUT_LEN; //! pub type Credential = [u8; CREDENTIAL_LEN]; //! diff --git a/src/rand.rs b/src/rand.rs index b6fb6bc4c..0d271fafa 100644 --- a/src/rand.rs +++ b/src/rand.rs @@ -285,7 +285,7 @@ mod darwin { #[link(name = "Security", kind = "framework")] extern "C" { - static kSecRandomDefault: &'static SecRandomRef; + static kSecRandomDefault: &SecRandomRef; // For now `rnd` must be `kSecRandomDefault`. #[must_use] diff --git a/src/rsa/bigint.rs b/src/rsa/bigint.rs index 7081abe9b..f2f6c9048 100644 --- a/src/rsa/bigint.rs +++ b/src/rsa/bigint.rs @@ -350,7 +350,7 @@ struct PartialModulus<'a, M> { m: PhantomData, } -impl<'a, M> PartialModulus<'a, M> { +impl PartialModulus<'_, M> { // TODO: XXX Avoid duplication with `Modulus`. fn zero(&self) -> Elem { let width = Width { diff --git a/src/rsa/signing.rs b/src/rsa/signing.rs index 08ec3dcb3..adb8307ec 100644 --- a/src/rsa/signing.rs +++ b/src/rsa/signing.rs @@ -407,7 +407,7 @@ impl PublicKey { } /// The public modulus (n). - pub fn modulus<'a>(&'a self) -> io::Positive<'a> { + pub fn modulus(&self) -> io::Positive { // Parsing won't fail because we serialized it ourselves. let (public_key, _exponent) = super::parse_public_key(untrusted::Input::from(self.as_ref())).unwrap(); @@ -415,7 +415,7 @@ impl PublicKey { } /// The public exponent (e). - pub fn exponent<'a>(&'a self) -> io::Positive<'a> { + pub fn exponent(&self) -> io::Positive { // Parsing won't fail because we serialized it ourselves. let (_public_key, exponent) = super::parse_public_key(untrusted::Input::from(self.as_ref())).unwrap(); diff --git a/src/test.rs b/src/test.rs index 901becda9..68d28dfef 100644 --- a/src/test.rs +++ b/src/test.rs @@ -376,8 +376,8 @@ fn from_hex_digit(d: u8) -> Result { } } -fn parse_test_case<'a>( - current_section: &mut String, lines: &mut Iterator, +fn parse_test_case( + current_section: &mut String, lines: &mut Iterator, ) -> Option { let mut attributes = Vec::new(); @@ -478,7 +478,7 @@ pub mod rand { pub bytes: &'a [u8], } - impl<'a> rand::SecureRandom for FixedSliceRandom<'a> { + impl rand::SecureRandom for FixedSliceRandom<'_> { fn fill(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> { dest.copy_from_slice(self.bytes); Ok(()) @@ -501,7 +501,7 @@ pub mod rand { pub current: core::cell::UnsafeCell, } - impl<'a> rand::SecureRandom for FixedSliceSequenceRandom<'a> { + impl rand::SecureRandom for FixedSliceSequenceRandom<'_> { fn fill(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> { let current = unsafe { *self.current.get() }; let bytes = self.bytes[current]; @@ -513,7 +513,7 @@ pub mod rand { } } - impl<'a> Drop for FixedSliceSequenceRandom<'a> { + impl Drop for FixedSliceSequenceRandom<'_> { fn drop(&mut self) { // Ensure that `fill()` was called exactly the right number of // times. @@ -522,8 +522,8 @@ pub mod rand { } impl sealed::Sealed for FixedByteRandom {} - impl<'a> sealed::Sealed for FixedSliceRandom<'a> {} - impl<'a> sealed::Sealed for FixedSliceSequenceRandom<'a> {} + impl sealed::Sealed for FixedSliceRandom<'_> {} + impl sealed::Sealed for FixedSliceSequenceRandom<'_> {} } diff --git a/tests/ecdsa_tests.rs b/tests/ecdsa_tests.rs index 8bcaf99d6..15d96c663 100644 --- a/tests/ecdsa_tests.rs +++ b/tests/ecdsa_tests.rs @@ -210,9 +210,9 @@ fn signature_ecdsa_verify_fixed_test() { #[test] fn ecdsa_test_public_key_coverage() { - const PRIVATE_KEY: &'static [u8] = include_bytes!("ecdsa_test_private_key_p256.p8"); - const PUBLIC_KEY: &'static [u8] = include_bytes!("ecdsa_test_public_key_p256.der"); - const PUBLIC_KEY_DEBUG: &'static str = include_str!("ecdsa_test_public_key_p256_debug.txt"); + const PRIVATE_KEY: &[u8] = include_bytes!("ecdsa_test_private_key_p256.p8"); + const PUBLIC_KEY: &[u8] = include_bytes!("ecdsa_test_public_key_p256.der"); + const PUBLIC_KEY_DEBUG: &str = include_str!("ecdsa_test_public_key_p256_debug.txt"); let key_pair = signature::EcdsaKeyPair::from_pkcs8( &signature::ECDSA_P256_SHA256_FIXED_SIGNING, diff --git a/tests/ed25519_tests.rs b/tests/ed25519_tests.rs index 209bb5627..dd7734b15 100644 --- a/tests/ed25519_tests.rs +++ b/tests/ed25519_tests.rs @@ -168,8 +168,8 @@ fn test_ed25519_from_pkcs8() { #[test] fn ed25519_test_public_key_coverage() { - const PRIVATE_KEY: &'static [u8] = include_bytes!("ed25519_test_private_key.p8"); - const PUBLIC_KEY: &'static [u8] = include_bytes!("ed25519_test_public_key.der"); + const PRIVATE_KEY: &[u8] = include_bytes!("ed25519_test_private_key.p8"); + const PUBLIC_KEY: &[u8] = include_bytes!("ed25519_test_public_key.der"); const PUBLIC_KEY_DEBUG: &'static str = "PublicKey(\"5809e9fef6dcec58f0f2e3b0d67e9880a11957e083ace85835c3b6c8fbaf6b7d\")"; diff --git a/tests/rsa_tests.rs b/tests/rsa_tests.rs index daf298426..80c8185a3 100644 --- a/tests/rsa_tests.rs +++ b/tests/rsa_tests.rs @@ -280,9 +280,9 @@ fn test_signature_rsa_primitive_verification() { #[cfg(feature = "use_heap")] #[test] fn rsa_test_public_key_coverage() { - const PRIVATE_KEY: &'static [u8] = include_bytes!("rsa_test_private_key_2048.p8"); - const PUBLIC_KEY: &'static [u8] = include_bytes!("rsa_test_public_key_2048.der"); - const PUBLIC_KEY_DEBUG: &'static str = include_str!("rsa_test_public_key_2048_debug.txt"); + const PRIVATE_KEY: &[u8] = include_bytes!("rsa_test_private_key_2048.p8"); + const PUBLIC_KEY: &[u8] = include_bytes!("rsa_test_public_key_2048.der"); + const PUBLIC_KEY_DEBUG: &str = include_str!("rsa_test_public_key_2048_debug.txt"); let key_pair = signature::RsaKeyPair::from_pkcs8(untrusted::Input::from(PRIVATE_KEY)).unwrap();