From 4d178a7f9f29a637c0857afdb0485c64a31c4620 Mon Sep 17 00:00:00 2001 From: Kornel Date: Tue, 20 May 2025 15:46:11 +0100 Subject: [PATCH] Clippy --- boring-sys/build/config.rs | 6 +++--- boring-sys/build/main.rs | 29 +++++++++++++---------------- boring/examples/mk_certs.rs | 4 ++-- boring/src/asn1.rs | 11 +++++++++-- boring/src/base64.rs | 2 +- boring/src/bn.rs | 24 ++++++++++++------------ boring/src/hash.rs | 16 ++++++++-------- boring/src/rsa.rs | 8 ++++---- boring/src/ssl/bio.rs | 5 +---- boring/src/ssl/callbacks.rs | 6 +++--- boring/src/ssl/ech.rs | 2 +- boring/src/ssl/error.rs | 12 ++++++------ boring/src/ssl/mod.rs | 6 +++--- boring/src/symm.rs | 4 ++-- boring/src/x509/extension.rs | 2 +- boring/src/x509/mod.rs | 2 +- boring/src/x509/tests/mod.rs | 4 ++-- hyper-boring/src/v0.rs | 8 ++++---- hyper-boring/tests/v0.rs | 6 +++--- tokio-boring/src/lib.rs | 2 +- 20 files changed, 80 insertions(+), 79 deletions(-) diff --git a/boring-sys/build/config.rs b/boring-sys/build/config.rs index 353f4d20..7f63b2fa 100644 --- a/boring-sys/build/config.rs +++ b/boring-sys/build/config.rs @@ -152,9 +152,9 @@ impl Env { let kind = if host == target { "HOST" } else { "TARGET" }; // TODO(rmehra): look for just `name` first, as most people just set that - var(&format!("{}_{}", name, target)) - .or_else(|| var(&format!("{}_{}", name, target_with_underscores))) - .or_else(|| var(&format!("{}_{}", kind, name))) + var(&format!("{name}_{target}")) + .or_else(|| var(&format!("{name}_{target_with_underscores}"))) + .or_else(|| var(&format!("{kind}_{name}"))) .or_else(|| var(name)) }; diff --git a/boring-sys/build/main.rs b/boring-sys/build/main.rs index 6cdcad66..129ad484 100644 --- a/boring-sys/build/main.rs +++ b/boring-sys/build/main.rs @@ -165,7 +165,7 @@ fn get_boringssl_platform_output_path(config: &Config) -> String { let deb_info = match debug_env_var.to_str() { Some("false") => false, Some("true") => true, - _ => panic!("Unknown DEBUG={:?} env var.", debug_env_var), + _ => panic!("Unknown DEBUG={debug_env_var:?} env var."), }; let opt_env_var = config @@ -184,12 +184,12 @@ fn get_boringssl_platform_output_path(config: &Config) -> String { } } Some("s" | "z") => "MinSizeRel", - _ => panic!("Unknown OPT_LEVEL={:?} env var.", opt_env_var), + _ => panic!("Unknown OPT_LEVEL={opt_env_var:?} env var."), }; subdir.to_string() } else { - "".to_string() + String::new() } } @@ -242,7 +242,7 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config { } let toolchain_file = android_ndk_home.join("build/cmake/android.toolchain.cmake"); let toolchain_file = toolchain_file.to_str().unwrap(); - eprintln!("android toolchain={}", toolchain_file); + eprintln!("android toolchain={toolchain_file}"); boringssl_cmake.define("CMAKE_TOOLCHAIN_FILE", toolchain_file); // 21 is the minimum level tested. You can give higher value. @@ -273,7 +273,7 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config { "" }; - let cflag = format!("{} {}", bitcode_cflag, target_cflag); + let cflag = format!("{bitcode_cflag} {target_cflag}"); boringssl_cmake.define("CMAKE_ASM_FLAGS", &cflag); boringssl_cmake.cflag(&cflag); } @@ -339,7 +339,7 @@ fn verify_fips_clang_version() -> (&'static str, &'static str) { let output = match Command::new(tool).arg("--version").output() { Ok(o) => o, Err(e) => { - eprintln!("warning: missing {}, trying other compilers: {}", tool, e); + eprintln!("warning: missing {tool}, trying other compilers: {e}"); // NOTE: hard-codes that the loop below checks the version return None; } @@ -369,13 +369,11 @@ fn verify_fips_clang_version() -> (&'static str, &'static str) { return (cc, cxx); } else if cc == "cc" { panic!( - "unsupported clang version \"{}\": FIPS requires clang {}", - cc_version, REQUIRED_CLANG_VERSION + "unsupported clang version \"{cc_version}\": FIPS requires clang {REQUIRED_CLANG_VERSION}" ); } else if !cc_version.is_empty() { eprintln!( - "warning: FIPS requires clang version {}, skipping incompatible version \"{}\"", - REQUIRED_CLANG_VERSION, cc_version + "warning: FIPS requires clang version {REQUIRED_CLANG_VERSION}, skipping incompatible version \"{cc_version}\"" ); } } @@ -425,7 +423,7 @@ fn get_extra_clang_args_for_bindgen(config: &Config) -> Vec { .unwrap(); if !output.status.success() { if let Some(exit_code) = output.status.code() { - eprintln!("xcrun failed: exit code {}", exit_code); + eprintln!("xcrun failed: exit code {exit_code}"); } else { eprintln!("xcrun failed: killed"); } @@ -452,8 +450,7 @@ fn get_extra_clang_args_for_bindgen(config: &Config) -> Vec { Ok(toolchain) => toolchain, Err(e) => { eprintln!( - "warning: failed to find prebuilt Android NDK toolchain for bindgen: {}", - e + "warning: failed to find prebuilt Android NDK toolchain for bindgen: {e}" ); // Uh... let's try anyway, I guess? return params; @@ -537,8 +534,8 @@ fn run_command(command: &mut Command) -> io::Result { if !out.status.success() { let err = match out.status.code() { - Some(code) => format!("{:?} exited with status: {}", command, code), - None => format!("{:?} was terminated by signal", command), + Some(code) => format!("{command:?} exited with status: {code}"), + None => format!("{command:?} was terminated by signal"), }; return Err(io::Error::other(err)); @@ -696,7 +693,7 @@ fn main() { } if let Some(cpp_lib) = get_cpp_runtime_lib(&config) { - println!("cargo:rustc-link-lib={}", cpp_lib); + println!("cargo:rustc-link-lib={cpp_lib}"); } println!("cargo:rustc-link-lib=static=crypto"); println!("cargo:rustc-link-lib=static=ssl"); diff --git a/boring/examples/mk_certs.rs b/boring/examples/mk_certs.rs index ce0c8492..a130dee6 100644 --- a/boring/examples/mk_certs.rs +++ b/boring/examples/mk_certs.rs @@ -146,7 +146,7 @@ fn real_main() -> Result<(), ErrorStack> { // Verify that this cert was issued by this ca match ca_cert.issued(&cert) { Ok(()) => println!("Certificate verified!"), - Err(ver_err) => println!("Failed to verify certificate: {}", ver_err), + Err(ver_err) => println!("Failed to verify certificate: {ver_err}"), }; Ok(()) @@ -155,6 +155,6 @@ fn real_main() -> Result<(), ErrorStack> { fn main() { match real_main() { Ok(()) => println!("Finished."), - Err(e) => println!("Error: {}", e), + Err(e) => println!("Error: {e}"), }; } diff --git a/boring/src/asn1.rs b/boring/src/asn1.rs index ceb76c0c..c5c2f196 100644 --- a/boring/src/asn1.rs +++ b/boring/src/asn1.rs @@ -304,7 +304,8 @@ impl Asn1Time { /// Creates a new time on specified interval in days from now pub fn days_from_now(days: u32) -> Result { - Asn1Time::from_period(days as c_long * 60 * 60 * 24) + // the type varies between platforms, so both into() and try_into() trigger Clippy lints + Self::from_period((days * 60 * 60 * 24) as _) } /// Creates a new time from the specified `time_t` value @@ -494,7 +495,13 @@ impl Asn1IntegerRef { /// [`bn`]: ../bn/struct.BigNumRef.html#method.to_asn1_integer #[corresponds(ASN1_INTEGER_set)] pub fn set(&mut self, value: i32) -> Result<(), ErrorStack> { - unsafe { cvt(crate::ffi::ASN1_INTEGER_set(self.as_ptr(), value as c_long)).map(|_| ()) } + unsafe { + cvt(crate::ffi::ASN1_INTEGER_set( + self.as_ptr(), + c_long::from(value), + )) + .map(|_| ()) + } } } diff --git a/boring/src/base64.rs b/boring/src/base64.rs index 75cc9cc8..98be9d0b 100644 --- a/boring/src/base64.rs +++ b/boring/src/base64.rs @@ -101,7 +101,7 @@ mod tests { #[test] fn test_encode_block() { - assert_eq!("".to_string(), encode_block(b"")); + assert_eq!(String::new(), encode_block(b"")); assert_eq!("Zg==".to_string(), encode_block(b"f")); assert_eq!("Zm8=".to_string(), encode_block(b"fo")); assert_eq!("Zm9v".to_string(), encode_block(b"foo")); diff --git a/boring/src/bn.rs b/boring/src/bn.rs index f6773a95..c60685bd 100644 --- a/boring/src/bn.rs +++ b/boring/src/bn.rs @@ -121,19 +121,19 @@ impl BigNumRef { /// Adds a `u32` to `self`. #[corresponds(BN_add_word)] pub fn add_word(&mut self, w: u32) -> Result<(), ErrorStack> { - unsafe { cvt(ffi::BN_add_word(self.as_ptr(), w as ffi::BN_ULONG)).map(|_| ()) } + unsafe { cvt(ffi::BN_add_word(self.as_ptr(), ffi::BN_ULONG::from(w))).map(|_| ()) } } /// Subtracts a `u32` from `self`. #[corresponds(BN_sub_word)] pub fn sub_word(&mut self, w: u32) -> Result<(), ErrorStack> { - unsafe { cvt(ffi::BN_sub_word(self.as_ptr(), w as ffi::BN_ULONG)).map(|_| ()) } + unsafe { cvt(ffi::BN_sub_word(self.as_ptr(), ffi::BN_ULONG::from(w))).map(|_| ()) } } /// Multiplies a `u32` by `self`. #[corresponds(BN_mul_word)] pub fn mul_word(&mut self, w: u32) -> Result<(), ErrorStack> { - unsafe { cvt(ffi::BN_mul_word(self.as_ptr(), w as ffi::BN_ULONG)).map(|_| ()) } + unsafe { cvt(ffi::BN_mul_word(self.as_ptr(), ffi::BN_ULONG::from(w))).map(|_| ()) } } /// Divides `self` by a `u32`, returning the remainder. @@ -263,7 +263,7 @@ impl BigNumRef { /// `self` positive. #[corresponds(BN_set_negative)] pub fn set_negative(&mut self, negative: bool) { - unsafe { ffi::BN_set_negative(self.as_ptr(), negative as c_int) } + unsafe { ffi::BN_set_negative(self.as_ptr(), c_int::from(negative)) } } /// Compare the absolute values of `self` and `oth`. @@ -332,7 +332,7 @@ impl BigNumRef { self.as_ptr(), bits.into(), msb.0, - odd as c_int, + c_int::from(odd), )) .map(|_| ()) } @@ -347,7 +347,7 @@ impl BigNumRef { self.as_ptr(), bits.into(), msb.0, - odd as c_int, + c_int::from(odd), )) .map(|_| ()) } @@ -388,7 +388,7 @@ impl BigNumRef { cvt(ffi::BN_generate_prime_ex( self.as_ptr(), bits as c_int, - safe as c_int, + c_int::from(safe), add.map(|n| n.as_ptr()).unwrap_or(ptr::null_mut()), rem.map(|n| n.as_ptr()).unwrap_or(ptr::null_mut()), ptr::null_mut(), @@ -712,7 +712,7 @@ impl BigNumRef { self.as_ptr(), checks.into(), ctx.as_ptr(), - do_trial_division as c_int, + c_int::from(do_trial_division), ptr::null_mut(), )) .map(|r| r != 0) @@ -829,7 +829,7 @@ impl BigNum { #[corresponds(BN_set_word)] pub fn from_u32(n: u32) -> Result { BigNum::new().and_then(|v| unsafe { - cvt(ffi::BN_set_word(v.as_ptr(), n as ffi::BN_ULONG)).map(|_| v) + cvt(ffi::BN_set_word(v.as_ptr(), ffi::BN_ULONG::from(n))).map(|_| v) }) } @@ -928,7 +928,7 @@ impl PartialEq for BigNumRef { impl PartialEq for BigNumRef { fn eq(&self, oth: &BigNum) -> bool { - self.eq(oth.deref()) + self.eq(&**oth) } } @@ -956,7 +956,7 @@ impl PartialOrd for BigNumRef { impl PartialOrd for BigNumRef { fn partial_cmp(&self, oth: &BigNum) -> Option { - Some(self.cmp(oth.deref())) + Some(self.cmp(&**oth)) } } @@ -980,7 +980,7 @@ impl PartialOrd for BigNum { impl Ord for BigNum { fn cmp(&self, oth: &BigNum) -> Ordering { - self.deref().cmp(oth.deref()) + self.deref().cmp(&**oth) } } diff --git a/boring/src/hash.rs b/boring/src/hash.rs index ba5d7bab..3e7f6eb5 100644 --- a/boring/src/hash.rs +++ b/boring/src/hash.rs @@ -308,7 +308,7 @@ impl DerefMut for DigestBytes { impl AsRef<[u8]> for DigestBytes { #[inline] fn as_ref(&self) -> &[u8] { - self.deref() + self } } @@ -455,7 +455,7 @@ mod tests { #[test] fn test_md5() { - for test in MD5_TESTS.iter() { + for test in &MD5_TESTS { hash_test(MessageDigest::md5(), test); } } @@ -463,7 +463,7 @@ mod tests { #[test] fn test_md5_recycle() { let mut h = Hasher::new(MessageDigest::md5()).unwrap(); - for test in MD5_TESTS.iter() { + for test in &MD5_TESTS { hash_recycle_test(&mut h, test); } } @@ -514,7 +514,7 @@ mod tests { fn test_sha1() { let tests = [("616263", "a9993e364706816aba3e25717850c26c9cd0d89d")]; - for test in tests.iter() { + for test in &tests { hash_test(MessageDigest::sha1(), test); } } @@ -526,7 +526,7 @@ mod tests { "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7", )]; - for test in tests.iter() { + for test in &tests { hash_test(MessageDigest::sha224(), test); } } @@ -538,7 +538,7 @@ mod tests { "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", )]; - for test in tests.iter() { + for test in &tests { hash_test(MessageDigest::sha256(), test); } } @@ -551,7 +551,7 @@ mod tests { 192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", )]; - for test in tests.iter() { + for test in &tests { hash_test(MessageDigest::sha512(), test); } } @@ -563,7 +563,7 @@ mod tests { "53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23", )]; - for test in tests.iter() { + for test in &tests { hash_test(MessageDigest::sha512_256(), test); } } diff --git a/boring/src/rsa.rs b/boring/src/rsa.rs index 7bb641fb..bef3b276 100644 --- a/boring/src/rsa.rs +++ b/boring/src/rsa.rs @@ -143,7 +143,7 @@ where to: &mut [u8], padding: Padding, ) -> Result { - assert!(from.len() <= i32::MAX as usize); + assert!(i32::try_from(from.len()).is_ok()); assert!(to.len() >= self.size() as usize); unsafe { @@ -170,7 +170,7 @@ where to: &mut [u8], padding: Padding, ) -> Result { - assert!(from.len() <= i32::MAX as usize); + assert!(i32::try_from(from.len()).is_ok()); assert!(to.len() >= self.size() as usize); unsafe { @@ -334,7 +334,7 @@ where to: &mut [u8], padding: Padding, ) -> Result { - assert!(from.len() <= i32::MAX as usize); + assert!(i32::try_from(from.len()).is_ok()); assert!(to.len() >= self.size() as usize); unsafe { @@ -360,7 +360,7 @@ where to: &mut [u8], padding: Padding, ) -> Result { - assert!(from.len() <= i32::MAX as usize); + assert!(i32::try_from(from.len()).is_ok()); assert!(to.len() >= self.size() as usize); unsafe { diff --git a/boring/src/ssl/bio.rs b/boring/src/ssl/bio.rs index f3b83672..e700dbe3 100644 --- a/boring/src/ssl/bio.rs +++ b/boring/src/ssl/bio.rs @@ -85,10 +85,7 @@ pub unsafe extern "C" fn take_stream(bio: *mut BIO) -> S { pub unsafe fn set_dtls_mtu_size(bio: *mut BIO, mtu_size: usize) { if mtu_size as u64 > c_long::MAX as u64 { - panic!( - "Given MTU size {} can't be represented in a positive `c_long` range", - mtu_size - ) + panic!("Given MTU size {mtu_size} can't be represented in a positive `c_long` range") } state::(bio).dtls_mtu_size = mtu_size as c_long; } diff --git a/boring/src/ssl/callbacks.rs b/boring/src/ssl/callbacks.rs index 8ab17b98..8ad4ba55 100644 --- a/boring/src/ssl/callbacks.rs +++ b/boring/src/ssl/callbacks.rs @@ -40,7 +40,7 @@ where // because there is no `X509StoreContextRef::ssl_mut(&mut self)` method. let verify = unsafe { &*(verify as *const F) }; - verify(preverify_ok != 0, ctx) as c_int + c_int::from(verify(preverify_ok != 0, ctx)) } pub(super) unsafe extern "C" fn raw_custom_verify( @@ -89,7 +89,7 @@ where // so the callback can't replace itself. let verify = unsafe { &*(verify as *const F) }; - verify(ctx) as c_int + c_int::from(verify(ctx)) } pub(super) unsafe extern "C" fn ssl_raw_custom_verify( @@ -235,7 +235,7 @@ where .expect("BUG: ssl verify callback missing") .clone(); - callback(preverify_ok != 0, ctx) as c_int + c_int::from(callback(preverify_ok != 0, ctx)) } pub(super) unsafe extern "C" fn raw_sni( diff --git a/boring/src/ssl/ech.rs b/boring/src/ssl/ech.rs index 27ccc5b5..cdc1f53b 100644 --- a/boring/src/ssl/ech.rs +++ b/boring/src/ssl/ech.rs @@ -35,7 +35,7 @@ impl SslEchKeysBuilder { unsafe { cvt_0i(ffi::SSL_ECH_KEYS_add( self.keys.as_ptr(), - is_retry_config as c_int, + c_int::from(is_retry_config), ech_config.as_ptr(), ech_config.len(), key.as_ptr(), diff --git a/boring/src/ssl/error.rs b/boring/src/ssl/error.rs index a17243df..a83a084e 100644 --- a/boring/src/ssl/error.rs +++ b/boring/src/ssl/error.rs @@ -136,14 +136,14 @@ impl fmt::Display for Error { None => fmt.write_str("the operation should be retried"), }, ErrorCode::SYSCALL => match self.io_error() { - Some(err) => write!(fmt, "{}", err), + Some(err) => write!(fmt, "{err}"), None => fmt.write_str("unexpected EOF"), }, ErrorCode::SSL => match self.ssl_error() { - Some(e) => write!(fmt, "{}", e), + Some(e) => write!(fmt, "{e}"), None => fmt.write_str("unknown BoringSSL error"), }, - ErrorCode(code) => write!(fmt, "unknown error code {}", code), + ErrorCode(code) => write!(fmt, "unknown error code {code}"), } } } @@ -185,7 +185,7 @@ impl fmt::Display for HandshakeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { HandshakeError::SetupFailure(ref e) => { - write!(f, "TLS stream setup failed {}", e) + write!(f, "TLS stream setup failed {e}") } HandshakeError::Failure(ref s) => fmt_mid_handshake_error(s, f, "TLS handshake failed"), HandshakeError::WouldBlock(ref s) => { @@ -209,8 +209,8 @@ fn fmt_mid_handshake_error( match s.ssl().verify_result() { // INVALID_CALL is returned if no verification took place, // such as before a cert is sent. - Ok(()) | Err(X509VerifyError::INVALID_CALL) => write!(f, "{}", prefix)?, - Err(verify) => write!(f, "{}: cert verification failed - {}", prefix, verify)?, + Ok(()) | Err(X509VerifyError::INVALID_CALL) => write!(f, "{prefix}")?, + Err(verify) => write!(f, "{prefix}: cert verification failed - {verify}")?, } write!(f, " {}", s.error()) diff --git a/boring/src/ssl/mod.rs b/boring/src/ssl/mod.rs index c293ed00..980026a1 100644 --- a/boring/src/ssl/mod.rs +++ b/boring/src/ssl/mod.rs @@ -593,7 +593,7 @@ impl TryFrom for SslVersion { type Error = &'static str; fn try_from(value: u16) -> Result { - match value as i32 { + match i32::from(value) { ffi::SSL3_VERSION | ffi::TLS1_VERSION | ffi::TLS1_1_VERSION @@ -908,7 +908,7 @@ impl SslInfoCallbackAlert { /// The value of the SSL alert. pub fn alert(&self) -> SslAlert { - let value = self.0 & (u8::MAX as i32); + let value = self.0 & i32::from(u8::MAX); SslAlert(value) } } @@ -1226,7 +1226,7 @@ impl SslContextBuilder { #[corresponds(SSL_CTX_set_read_ahead)] pub fn set_read_ahead(&mut self, read_ahead: bool) { unsafe { - ffi::SSL_CTX_set_read_ahead(self.as_ptr(), read_ahead as c_int); + ffi::SSL_CTX_set_read_ahead(self.as_ptr(), c_int::from(read_ahead)); } } diff --git a/boring/src/symm.rs b/boring/src/symm.rs index 1df9a77c..4f5527b2 100644 --- a/boring/src/symm.rs +++ b/boring/src/symm.rs @@ -341,7 +341,7 @@ impl Crypter { } iv.as_ptr() as *mut _ } - (Some(_), None) | (None, None) => ptr::null_mut(), + (Some(_) | None, None) => ptr::null_mut(), (None, Some(_)) => panic!("an IV is required for this cipher"), }; cvt(ffi::EVP_CipherInit_ex( @@ -363,7 +363,7 @@ impl Crypter { /// be a multiple of the cipher's block size. pub fn pad(&mut self, padding: bool) { unsafe { - ffi::EVP_CIPHER_CTX_set_padding(self.ctx, padding as c_int); + ffi::EVP_CIPHER_CTX_set_padding(self.ctx, c_int::from(padding)); } } diff --git a/boring/src/x509/extension.rs b/boring/src/x509/extension.rs index 639d28bd..e8797327 100644 --- a/boring/src/x509/extension.rs +++ b/boring/src/x509/extension.rs @@ -78,7 +78,7 @@ impl BasicConstraints { value.push_str("FALSE"); } if let Some(pathlen) = self.pathlen { - write!(value, ",pathlen:{}", pathlen).unwrap(); + write!(value, ",pathlen:{pathlen}").unwrap(); } X509Extension::new_nid(None, None, Nid::BASIC_CONSTRAINTS, &value) } diff --git a/boring/src/x509/mod.rs b/boring/src/x509/mod.rs index 2e17dbb3..2640f784 100644 --- a/boring/src/x509/mod.rs +++ b/boring/src/x509/mod.rs @@ -1516,7 +1516,7 @@ impl X509VerifyError { ffi::init(); unsafe { - let s = ffi::X509_verify_cert_error_string(self.0 as c_long); + let s = ffi::X509_verify_cert_error_string(c_long::from(self.0)); str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap() } } diff --git a/boring/src/x509/tests/mod.rs b/boring/src/x509/tests/mod.rs index f02c3fe3..c7919466 100644 --- a/boring/src/x509/tests/mod.rs +++ b/boring/src/x509/tests/mod.rs @@ -37,7 +37,7 @@ fn test_cert_loading() { fn test_debug() { let cert = include_bytes!("../../../test/cert.pem"); let cert = X509::from_pem(cert).unwrap(); - let debugged = format!("{:#?}", cert); + let debugged = format!("{cert:#?}"); assert!(debugged.contains(r#"serial_number: "8771f7bdee982fa5""#)); assert!(debugged.contains(r#"signature_algorithm: sha256WithRSAEncryption"#)); @@ -497,7 +497,7 @@ fn test_save_subject_der() { let cert = X509::from_pem(cert).unwrap(); let der = cert.subject_name().to_der().unwrap(); - println!("der: {:?}", der); + println!("der: {der:?}"); assert!(!der.is_empty()); } diff --git a/hyper-boring/src/v0.rs b/hyper-boring/src/v0.rs index 172d1640..07597498 100644 --- a/hyper-boring/src/v0.rs +++ b/hyper-boring/src/v0.rs @@ -259,10 +259,10 @@ where let last = host.len() - 1; let mut chars = host.chars(); - if let (Some('['), Some(']')) = (chars.next(), chars.last()) { - if host[1..last].parse::().is_ok() { - host = &host[1..last]; - } + if (chars.next(), chars.last()) == (Some('['), Some(']')) + && host[1..last].parse::().is_ok() + { + host = &host[1..last]; } } diff --git a/hyper-boring/tests/v0.rs b/hyper-boring/tests/v0.rs index 08cfce12..f52e1851 100644 --- a/hyper-boring/tests/v0.rs +++ b/hyper-boring/tests/v0.rs @@ -76,7 +76,7 @@ async fn localhost() { let file = File::create("../target/keyfile.log").unwrap(); ssl.set_keylog_callback(move |_, line| { - let _ = writeln!(&file, "{}", line); + let _ = writeln!(&file, "{line}"); }); let ssl = HttpsConnector::with_connector(connector, ssl).unwrap(); @@ -84,7 +84,7 @@ async fn localhost() { for _ in 0..3 { let resp = client - .get(format!("https://foobar.com:{}", port).parse().unwrap()) + .get(format!("https://foobar.com:{port}").parse().unwrap()) .await .unwrap(); assert!(resp.status().is_success(), "{}", resp.status()); @@ -147,7 +147,7 @@ async fn alpn_h2() { let client = Client::builder().build::<_, Body>(ssl); let resp = client - .get(format!("https://foobar.com:{}", port).parse().unwrap()) + .get(format!("https://foobar.com:{port}").parse().unwrap()) .await .unwrap(); assert!(resp.status().is_success(), "{}", resp.status()); diff --git a/tokio-boring/src/lib.rs b/tokio-boring/src/lib.rs index 89d10127..0dae747a 100644 --- a/tokio-boring/src/lib.rs +++ b/tokio-boring/src/lib.rs @@ -234,7 +234,7 @@ where fn poll_shutdown(mut self: Pin<&mut Self>, ctx: &mut Context) -> Poll> { match self.run_in_context(ctx, |s| s.shutdown()) { - Ok(ShutdownResult::Sent) | Ok(ShutdownResult::Received) => {} + Ok(ShutdownResult::Sent | ShutdownResult::Received) => {} Err(ref e) if e.code() == ErrorCode::ZERO_RETURN => {} Err(ref e) if e.code() == ErrorCode::WANT_READ || e.code() == ErrorCode::WANT_WRITE => { return Poll::Pending;