Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Feb 19, 2022
1 parent 7572df5 commit 437fc75
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SslSession> {
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ mod test;

fn key_index() -> Result<Index<Ssl, SessionKey>, ErrorStack> {
static IDX: OnceCell<Index<Ssl, SessionKey>> = 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<Mutex<SessionCache>>,
#[allow(clippy::type_complexity)]
callback: Option<
Arc<dyn Fn(&mut ConnectConfiguration, &Uri) -> Result<(), ErrorStack> + Sync + Send>,
>,
Expand Down Expand Up @@ -84,8 +85,6 @@ impl HttpsLayer {
/// ALPN is configured to support both HTTP/2 and HTTP/1.1.
pub fn new() -> Result<HttpsLayer, ErrorStack> {
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")?;
Expand Down Expand Up @@ -202,6 +201,7 @@ where
{
type Response = MaybeHttpsStream<S::Response>;
type Error = Box<dyn Error + Sync + Send>;
#[allow(clippy::type_complexity)]
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Expand All @@ -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)?;
Expand Down Expand Up @@ -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") {
Expand Down
6 changes: 3 additions & 3 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}
}

Expand Down Expand Up @@ -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() {}
}
}

Expand Down Expand Up @@ -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() {}
}

0 comments on commit 437fc75

Please sign in to comment.