From 9d58c7d29e5279d7590fc3ce7bd5241a2f912e92 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 4 Nov 2022 22:11:05 +0100 Subject: [PATCH] chore: apply clippy suggestions from 1.65 (#122) --- tokio-rustls/src/lib.rs | 1 + tokio-rustls/tests/early-data.rs | 29 +++++++++++++---------------- tokio-rustls/tests/test.rs | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tokio-rustls/src/lib.rs b/tokio-rustls/src/lib.rs index 27b26e1..6f4a21b 100644 --- a/tokio-rustls/src/lib.rs +++ b/tokio-rustls/src/lib.rs @@ -389,6 +389,7 @@ impl Future for FallibleAccept { /// /// This abstracts over the inner `client::TlsStream` and `server::TlsStream`, so you can use /// a single type to keep both client- and server-initiated TLS-encrypted connections. +#[allow(clippy::large_enum_variant)] // https://github.com/rust-lang/rust-clippy/issues/9798 #[derive(Debug)] pub enum TlsStream { Client(client::TlsStream), diff --git a/tokio-rustls/tests/early-data.rs b/tokio-rustls/tests/early-data.rs index b619f6d..fe98290 100644 --- a/tokio-rustls/tests/early-data.rs +++ b/tokio-rustls/tests/early-data.rs @@ -75,7 +75,7 @@ async fn send( match read_task.await { Ok(()) => (), Err(ref err) if err.kind() == io::ErrorKind::UnexpectedEof => (), - Err(err) => return Err(err.into()), + Err(err) => return Err(err), } Ok(rd) as io::Result<_> @@ -106,9 +106,9 @@ async fn test_0rtt() -> io::Result<()> { .arg("s_server") .arg("-early_data") .arg("-tls1_3") - .args(&["-cert", "./tests/end.cert"]) - .args(&["-key", "./tests/end.rsa"]) - .args(&["-port", "12354"]) + .args(["-cert", "./tests/end.cert"]) + .args(["-key", "./tests/end.rsa"]) + .args(["-port", "12354"]) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() @@ -119,19 +119,16 @@ async fn test_0rtt() -> io::Result<()> { let mut chain = BufReader::new(Cursor::new(include_str!("end.chain"))); let certs = rustls_pemfile::certs(&mut chain).unwrap(); - let trust_anchors = certs - .iter() - .map(|cert| { - let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); - OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject, - ta.spki, - ta.name_constraints, - ) - }) - .collect::>(); + let trust_anchors = certs.iter().map(|cert| { + let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); + OwnedTrustAnchor::from_subject_spki_name_constraints( + ta.subject, + ta.spki, + ta.name_constraints, + ) + }); let mut root_store = RootCertStore::empty(); - root_store.add_server_trust_anchors(trust_anchors.into_iter()); + root_store.add_server_trust_anchors(trust_anchors); let mut config = rustls::ClientConfig::builder() .with_safe_default_cipher_suites() .with_safe_default_kx_groups() diff --git a/tokio-rustls/tests/test.rs b/tokio-rustls/tests/test.rs index 9ec6360..c7ba137 100644 --- a/tokio-rustls/tests/test.rs +++ b/tokio-rustls/tests/test.rs @@ -79,7 +79,7 @@ lazy_static! { } fn start_server() -> &'static (SocketAddr, &'static str, &'static [u8]) { - &*TEST_SERVER + &TEST_SERVER } async fn start_client(addr: SocketAddr, domain: &str, config: Arc) -> io::Result<()> {