From 437fc75544fd332325131f0eeeac1f4356aabcd6 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 19 Feb 2022 12:36:38 -0500 Subject: [PATCH] clippy --- build.rs | 1 + src/cache.rs | 2 +- src/lib.rs | 10 ++++------ src/test.rs | 6 +++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/build.rs b/build.rs index 3c94a721..0cfee1a3 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,6 @@ use std::env; +#[allow(clippy::unusual_byte_groupings)] fn main() { if let Ok(version) = env::var("DEP_OPENSSL_VERSION_NUMBER") { let version = u64::from_str_radix(&version, 16).unwrap(); diff --git a/src/cache.rs b/src/cache.rs index b5d71e6a..6e2d3480 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -58,7 +58,7 @@ impl SessionCache { .entry(key.clone()) .or_insert_with(LinkedHashSet::new) .insert(session.clone()); - self.reverse.insert(session.clone(), key); + self.reverse.insert(session, key); } pub fn get(&mut self, key: &SessionKey) -> Option { diff --git a/src/lib.rs b/src/lib.rs index df8ea406..7d05c59e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,13 +35,14 @@ mod test; fn key_index() -> Result, ErrorStack> { static IDX: OnceCell> = OnceCell::new(); - IDX.get_or_try_init(|| Ssl::new_ex_index()).map(|v| *v) + IDX.get_or_try_init(Ssl::new_ex_index).map(|v| *v) } #[derive(Clone)] struct Inner { ssl: SslConnector, cache: Arc>, + #[allow(clippy::type_complexity)] callback: Option< Arc Result<(), ErrorStack> + Sync + Send>, >, @@ -84,8 +85,6 @@ impl HttpsLayer { /// ALPN is configured to support both HTTP/2 and HTTP/1.1. pub fn new() -> Result { let mut ssl = SslConnector::builder(SslMethod::tls())?; - // avoid unused_mut warnings when building against OpenSSL 1.0.1 - ssl = ssl; #[cfg(ossl102)] ssl.set_alpn_protos(b"\x02h2\x08http/1.1")?; @@ -202,6 +201,7 @@ where { type Response = MaybeHttpsStream; type Error = Box; + #[allow(clippy::type_complexity)] type Future = Pin> + Send>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -225,7 +225,7 @@ where None => return Ok(MaybeHttpsStream::Http(conn)), }; - let host = uri.host().ok_or_else(|| "URI missing host")?; + let host = uri.host().ok_or("URI missing host")?; let config = inner.setup_ssl(&uri, host)?; let ssl = config.into_ssl(host)?; @@ -333,8 +333,6 @@ where MaybeHttpsStream::Http(s) => s.connected(), MaybeHttpsStream::Https(s) => { let mut connected = s.get_ref().connected(); - // Avoid unused_mut warnings on OpenSSL 1.0.1 - connected = connected; #[cfg(ossl102)] { if s.ssl().selected_alpn_protocol() == Some(b"h2") { diff --git a/src/test.rs b/src/test.rs index 349f6863..f202daf9 100644 --- a/src/test.rs +++ b/src/test.rs @@ -22,7 +22,7 @@ async fn google() { .unwrap(); assert!(resp.status().is_success(), "{}", resp.status()); let mut body = resp.into_body(); - while let Some(_) = body.next().await.transpose().unwrap() {} + while body.next().await.transpose().unwrap().is_some() {} } } @@ -87,7 +87,7 @@ async fn localhost() { .unwrap(); assert!(resp.status().is_success(), "{}", resp.status()); let mut body = resp.into_body(); - while let Some(_) = body.next().await.transpose().unwrap() {} + while body.next().await.transpose().unwrap().is_some() {} } } @@ -145,5 +145,5 @@ async fn alpn_h2() { .unwrap(); assert!(resp.status().is_success(), "{}", resp.status()); let mut body = resp.into_body(); - while let Some(_) = body.next().await.transpose().unwrap() {} + while body.next().await.transpose().unwrap().is_some() {} }