diff --git a/.clippy.toml b/.clippy.toml index 6b6a85a00c8..cc94ec53e13 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,7 +1 @@ upper-case-acronyms-aggressive = true - -# only intended to affect main rustls crate - need to allow disallowed-types in all other crates in Clippy CI job -disallowed-types = [ - { path = "std::sync::Arc", reason = "must use Arc from sync module to support downstream forks targeting architectures without atomic ptrs" }, - { path = "std::sync::Weak", reason = "must use Weak from sync module to support downstream forks targeting architectures without atomic ptrs" }, -] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd21e1f8a60..e61667d3c05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -476,12 +476,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: components: clippy - # We want to be free of any warnings, so deny them. - # - Allow `clippy::disallowed_types` as a workaround since `disallowed_types` configured in `.clippy.toml` - # is only intended for the main `rustls` crate. - - run: ./admin/clippy -- --deny warnings --allow clippy::disallowed_types - # - Keep the main crate free of all warnings. - - run: cargo clippy -p rustls -- --deny warnings + - run: ./admin/clippy -- --deny warnings clippy-nightly: name: Clippy (Nightly) diff --git a/bogo/src/main.rs b/bogo/src/main.rs index 59429a4cf14..065912c7788 100644 --- a/bogo/src/main.rs +++ b/bogo/src/main.rs @@ -316,7 +316,7 @@ fn decode_hex(hex: &str) -> Vec { (0..hex.len()) .step_by(2) .map(|i| u8::from_str_radix(&hex[i..i + 2], 16).unwrap()) - .inspect(|x| println!("item {:?}", x)) + .inspect(|x| println!("item {x:?}")) .collect() } @@ -865,7 +865,7 @@ fn quit_err(why: &str) -> ! { } fn handle_err(opts: &Options, err: Error) -> ! { - println!("TLS error: {:?}", err); + println!("TLS error: {err:?}"); thread::sleep(time::Duration::from_millis(100)); match err { @@ -990,7 +990,7 @@ fn handle_err(opts: &Options, err: Error) -> ! { quit(":CANNOT_PARSE_LEAF_CERT:") } Error::InvalidCertificate(CertificateError::BadSignature) => quit(":BAD_SIGNATURE:"), - Error::InvalidCertificate(e) => quit(&format!(":BAD_CERT: ({:?})", e)), + Error::InvalidCertificate(e) => quit(&format!(":BAD_CERT: ({e:?})")), Error::PeerSentOversizedRecord => quit(":DATA_LENGTH_TOO_LONG:"), _ => { println_err!("unhandled error: {:?}", err); @@ -1002,7 +1002,7 @@ fn handle_err(opts: &Options, err: Error) -> ! { fn flush(sess: &mut Connection, conn: &mut net::TcpStream) { while sess.wants_write() { if let Err(err) = sess.write_tls(conn) { - println!("IO error: {:?}", err); + println!("IO error: {err:?}"); process::exit(0); } } @@ -1033,12 +1033,12 @@ fn read_n_bytes(opts: &Options, sess: &mut Connection, conn: &mut net::TcpStream let mut bytes = [0u8; MAX_MESSAGE_SIZE]; match conn.read(&mut bytes[..n]) { Ok(count) => { - println!("read {:?} bytes", count); + println!("read {count:?} bytes"); sess.read_tls(&mut io::Cursor::new(&mut bytes[..count])) .expect("read_tls not expected to fail reading from buffer"); } Err(err) if err.kind() == io::ErrorKind::ConnectionReset => {} - Err(err) => panic!("invalid read: {}", err), + Err(err) => panic!("invalid read: {err}"), }; after_read(opts, sess, conn); @@ -1048,7 +1048,7 @@ fn read_all_bytes(opts: &Options, sess: &mut Connection, conn: &mut net::TcpStre match sess.read_tls(conn) { Ok(_) => {} Err(err) if err.kind() == io::ErrorKind::ConnectionReset => {} - Err(err) => panic!("invalid read: {}", err), + Err(err) => panic!("invalid read: {err}"), }; after_read(opts, sess, conn); @@ -1269,7 +1269,7 @@ fn exec(opts: &Options, mut sess: Connection, count: usize) { println!("EOF (tcp)"); return; } - Err(err) => panic!("unhandled read error {:?}", err), + Err(err) => panic!("unhandled read error {err:?}"), }; if opts.shut_down_after_handshake && !sent_shutdown && !sess.is_handshaking() { @@ -1278,7 +1278,7 @@ fn exec(opts: &Options, mut sess: Connection, count: usize) { } if quench_writes && len > 0 { - println!("unquenching writes after {:?}", len); + println!("unquenching writes after {len:?}"); quench_writes = false; } @@ -1302,7 +1302,7 @@ pub fn main() { println!("No"); process::exit(0); } - println!("options: {:?}", args); + println!("options: {args:?}"); let mut opts = Options::new(); @@ -1355,7 +1355,7 @@ pub fn main() { "-tls13-variant" => { let variant = args.remove(0).parse::().unwrap(); if variant != 1 { - println!("NYI TLS1.3 variant selection: {:?} {:?}", arg, variant); + println!("NYI TLS1.3 variant selection: {arg:?} {variant:?}"); process::exit(BOGO_NACK); } } @@ -1426,7 +1426,7 @@ pub fn main() { "-expect-tls13-downgrade" | "-enable-signed-cert-timestamps" | "-expect-session-id" => { - println!("not checking {}; NYI", arg); + println!("not checking {arg}; NYI"); } "-key-update" => { @@ -1541,7 +1541,7 @@ pub fn main() { opts.expect_reject_early_data = true; } _ => { - println!("NYI early data reason: {}", reason); + println!("NYI early data reason: {reason}"); process::exit(1); } } @@ -1706,7 +1706,7 @@ pub fn main() { "-expect-resumable-across-names" | "-expect-not-resumable-across-names" | "-use-custom-verify-callback" => { - println!("NYI option {:?}", arg); + println!("NYI option {arg:?}"); process::exit(BOGO_NACK); } @@ -1718,13 +1718,13 @@ pub fn main() { } _ => { - println!("unhandled option {:?}", arg); + println!("unhandled option {arg:?}"); process::exit(1); } } } - println!("opts {:?}", opts); + println!("opts {opts:?}"); #[cfg(unix)] if opts.wait_for_debugger { diff --git a/ci-bench/src/util.rs b/ci-bench/src/util.rs index 177663bc963..b76e213637e 100644 --- a/ci-bench/src/util.rs +++ b/ci-bench/src/util.rs @@ -11,9 +11,9 @@ pub enum KeyType { impl KeyType { pub(crate) fn path_for(&self, part: &str) -> String { match self { - Self::Rsa2048 => format!("../test-ca/rsa-2048/{}", part), - Self::EcdsaP256 => format!("../test-ca/ecdsa-p256/{}", part), - Self::EcdsaP384 => format!("../test-ca/ecdsa-p384/{}", part), + Self::Rsa2048 => format!("../test-ca/rsa-2048/{part}"), + Self::EcdsaP256 => format!("../test-ca/ecdsa-p256/{part}"), + Self::EcdsaP384 => format!("../test-ca/ecdsa-p384/{part}"), } } @@ -290,8 +290,7 @@ pub mod async_io { fn poll(mut self: Pin<&mut Self>, _: &mut task::Context<'_>) -> Poll { if !self.writer.inner.open.get() { - return Poll::Ready(Err(io::Error::new( - io::ErrorKind::Other, + return Poll::Ready(Err(io::Error::other( "channel was closed", ))); } diff --git a/connect-tests/tests/common/mod.rs b/connect-tests/tests/common/mod.rs index 145e7e9219f..148482f784e 100644 --- a/connect-tests/tests/common/mod.rs +++ b/connect-tests/tests/common/mod.rs @@ -153,7 +153,7 @@ impl TlsClient { .args(&args) .env("SSLKEYLOGFILE", "./sslkeylogfile.txt") .output() - .unwrap_or_else(|e| panic!("failed to execute: {}", e)); + .unwrap_or_else(|e| panic!("failed to execute: {e}")); let stdout_str = String::from_utf8_lossy(&output.stdout); let stderr_str = String::from_utf8_lossy(&output.stderr); @@ -161,8 +161,8 @@ impl TlsClient { for expect in &self.expect_output { let re = Regex::new(expect).unwrap(); if re.find(&stdout_str).is_none() { - println!("We expected to find '{}' in the following output:", expect); - println!("{:?}", output); + println!("We expected to find '{expect}' in the following output:"); + println!("{output:?}"); panic!("Test failed"); } } @@ -170,8 +170,8 @@ impl TlsClient { for expect in &self.expect_log { let re = Regex::new(expect).unwrap(); if re.find(&stderr_str).is_none() { - println!("We expected to find '{}' in the following output:", expect); - println!("{:?}", output); + println!("We expected to find '{expect}' in the following output:"); + println!("{output:?}"); panic!("Test failed"); } } diff --git a/examples/src/bin/simple_0rtt_client.rs b/examples/src/bin/simple_0rtt_client.rs index 5ffbeb6ce88..7e875a83fb9 100644 --- a/examples/src/bin/simple_0rtt_client.rs +++ b/examples/src/bin/simple_0rtt_client.rs @@ -28,15 +28,14 @@ fn start_connection(config: &Arc, domain_name: &str, port: .expect("invalid DNS name") .to_owned(); let mut conn = rustls::ClientConnection::new(Arc::clone(config), server_name).unwrap(); - let mut sock = TcpStream::connect(format!("{}:{}", domain_name, port)).unwrap(); + let mut sock = TcpStream::connect(format!("{domain_name}:{port}")).unwrap(); sock.set_nodelay(true).unwrap(); let request = format!( "GET / HTTP/1.1\r\n\ - Host: {}\r\n\ + Host: {domain_name}\r\n\ Connection: close\r\n\ Accept-Encoding: identity\r\n\ - \r\n", - domain_name + \r\n" ); // If early data is available with this server, then early_data() @@ -69,7 +68,7 @@ fn start_connection(config: &Arc, domain_name: &str, port: BufReader::new(stream) .read_line(&mut first_response_line) .unwrap(); - println!(" * Server response: {:?}", first_response_line); + println!(" * Server response: {first_response_line:?}"); } fn main() { diff --git a/examples/src/bin/simple_0rtt_server.rs b/examples/src/bin/simple_0rtt_server.rs index fcdf799abb7..047345f3646 100644 --- a/examples/src/bin/simple_0rtt_server.rs +++ b/examples/src/bin/simple_0rtt_server.rs @@ -91,7 +91,7 @@ fn main() -> Result<(), Box> { .unwrap(); if bytes_read != 0 { - println!("Early data from client: {:?}", buf); + println!("Early data from client: {buf:?}"); } } } diff --git a/examples/src/bin/tlsclient-mio.rs b/examples/src/bin/tlsclient-mio.rs index cc8e2de4b79..ea35b55b30a 100644 --- a/examples/src/bin/tlsclient-mio.rs +++ b/examples/src/bin/tlsclient-mio.rs @@ -93,7 +93,7 @@ impl TlsClient { if error.kind() == io::ErrorKind::WouldBlock { return; } - println!("TLS read error: {:?}", error); + println!("TLS read error: {error:?}"); self.closing = true; return; } @@ -291,7 +291,7 @@ fn lookup_suites(suites: &[String]) -> Vec { let scs = find_suite(csname); match scs { Some(s) => out.push(s), - None => panic!("cannot look up ciphersuite '{}'", csname), + None => panic!("cannot look up ciphersuite '{csname}'"), } } @@ -307,8 +307,7 @@ fn lookup_versions(versions: &[String]) -> Vec<&'static rustls::SupportedProtoco "1.2" => &rustls::version::TLS12, "1.3" => &rustls::version::TLS13, _ => panic!( - "cannot look up version '{}', valid are '1.2' and '1.3'", - vname + "cannot look up version '{vname}', valid are '1.2' and '1.3'" ), }; out.push(version); @@ -526,7 +525,7 @@ fn main() { // Polling can be interrupted (e.g. by a debugger) - retry if so. Err(e) if e.kind() == io::ErrorKind::Interrupted => continue, Err(e) => { - panic!("poll failed: {:?}", e) + panic!("poll failed: {e:?}") } } diff --git a/examples/src/bin/tlsserver-mio.rs b/examples/src/bin/tlsserver-mio.rs index 6478b55710c..3421a4e0a89 100644 --- a/examples/src/bin/tlsserver-mio.rs +++ b/examples/src/bin/tlsserver-mio.rs @@ -76,7 +76,7 @@ impl TlsServer { loop { match self.server.accept() { Ok((socket, addr)) => { - debug!("Accepting new connection from {:?}", addr); + debug!("Accepting new connection from {addr:?}"); let tls_conn = rustls::ServerConnection::new(Arc::clone(&self.tls_config)).unwrap(); @@ -93,8 +93,7 @@ impl TlsServer { Err(err) if err.kind() == io::ErrorKind::WouldBlock => return Ok(()), Err(err) => { println!( - "encountered error while accepting connection; err={:?}", - err + "encountered error while accepting connection; err={err:?}" ); return Err(err); } @@ -224,7 +223,7 @@ impl OpenConnection { return; } - error!("read error {:?}", err); + error!("read error {err:?}"); self.closing = true; return; } @@ -238,7 +237,7 @@ impl OpenConnection { // Process newly-received TLS messages. if let Err(err) = self.tls_conn.process_new_packets() { - error!("cannot process packet: {:?}", err); + error!("cannot process packet: {err:?}"); // last gasp write to send any alerts self.do_tls_write_and_handle_error(); @@ -288,7 +287,7 @@ impl OpenConnection { let rc = try_read(back.read(&mut buf)); if rc.is_err() { - error!("backend read failed: {:?}", rc); + error!("backend read failed: {rc:?}"); self.closing = true; return; } @@ -355,7 +354,7 @@ impl OpenConnection { fn do_tls_write_and_handle_error(&mut self) { let rc = self.tls_write(); if rc.is_err() { - error!("write failed {:?}", rc); + error!("write failed {rc:?}"); self.closing = true; } } @@ -494,7 +493,7 @@ fn lookup_suites(suites: &[String]) -> Vec { let scs = find_suite(csname); match scs { Some(s) => out.push(s), - None => panic!("cannot look up ciphersuite '{}'", csname), + None => panic!("cannot look up ciphersuite '{csname}'"), } } @@ -510,8 +509,7 @@ fn lookup_versions(versions: &[String]) -> Vec<&'static rustls::SupportedProtoco "1.2" => &rustls::version::TLS12, "1.3" => &rustls::version::TLS13, _ => panic!( - "cannot look up version '{}', valid are '1.2' and '1.3'", - vname + "cannot look up version '{vname}', valid are '1.2' and '1.3'" ), }; out.push(version); @@ -669,7 +667,7 @@ fn main() { // Polling can be interrupted (e.g. by a debugger) - retry if so. Err(e) if e.kind() == io::ErrorKind::Interrupted => continue, Err(e) => { - panic!("poll failed: {:?}", e) + panic!("poll failed: {e:?}") } } diff --git a/openssl-tests/src/raw_key_openssl_interop.rs b/openssl-tests/src/raw_key_openssl_interop.rs index 589e4a08bb6..c6857330d69 100644 --- a/openssl-tests/src/raw_key_openssl_interop.rs +++ b/openssl-tests/src/raw_key_openssl_interop.rs @@ -64,7 +64,7 @@ mod client { pub(super) fn run_client(config: ClientConfig, port: u16) -> Result { let server_name = "0.0.0.0".try_into().unwrap(); let mut conn = ClientConnection::new(Arc::new(config), server_name).unwrap(); - let mut sock = TcpStream::connect(format!("[::]:{}", port)).unwrap(); + let mut sock = TcpStream::connect(format!("[::]:{port}")).unwrap(); let mut tls = Stream::new(&mut conn, &mut sock); let mut buf = vec![0; 128]; @@ -368,7 +368,7 @@ mod tests { assert_eq!(server_message, "Hello from the server"); } Err(e) => { - panic!("Client failed to communicate with the server: {:?}", e); + panic!("Client failed to communicate with the server: {e:?}"); } } @@ -383,7 +383,7 @@ mod tests { assert_eq!(client_message, "Hello from the client"); } Err(e) => { - panic!("Server failed to communicate with the client: {:?}", e); + panic!("Server failed to communicate with the client: {e:?}"); } } } @@ -415,7 +415,7 @@ mod tests { let mut openssl_client = Command::new("openssl") .arg("s_client") .arg("-connect") - .arg(format!("[::]:{:?}", port)) + .arg(format!("[::]:{port:?}")) .arg("-enable_client_rpk") .arg("-key") .arg(CLIENT_PRIV_KEY_FILE) @@ -457,7 +457,7 @@ mod tests { let mut openssl_client = Command::new("openssl") .arg("s_client") .arg("-connect") - .arg(format!("[::]:{:?}", port)) + .arg(format!("[::]:{port:?}")) .arg("-enable_server_rpk") .arg("-enable_client_rpk") .arg("-key") @@ -552,7 +552,7 @@ mod tests { } } Err(e) => { - panic!("Error reading from OpenSSL stdout: {:?}", e); + panic!("Error reading from OpenSSL stdout: {e:?}"); } } } diff --git a/rustls-bench/src/main.rs b/rustls-bench/src/main.rs index 8bbc155c0e2..73385f74f7f 100644 --- a/rustls-bench/src/main.rs +++ b/rustls-bench/src/main.rs @@ -483,7 +483,7 @@ fn report_timings( for t in thread_timings.iter() { let rate = work_per_thread / which(t); total_rate += rate; - print!("{:.2}\t", rate); + print!("{rate:.2}\t"); } println!( @@ -681,7 +681,7 @@ fn lookup_matching_benches( .collect(); if r.is_empty() { - panic!("unknown suite {:?}", ciphersuite_name); + panic!("unknown suite {ciphersuite_name:?}"); } r @@ -1047,10 +1047,10 @@ enum KeyType { impl KeyType { fn path_for(&self, part: &str) -> String { match self { - Self::Rsa2048 => format!("test-ca/rsa-2048/{}", part), - Self::EcdsaP256 => format!("test-ca/ecdsa-p256/{}", part), - Self::EcdsaP384 => format!("test-ca/ecdsa-p384/{}", part), - Self::Ed25519 => format!("test-ca/eddsa/{}", part), + Self::Rsa2048 => format!("test-ca/rsa-2048/{part}"), + Self::EcdsaP256 => format!("test-ca/ecdsa-p256/{part}"), + Self::EcdsaP384 => format!("test-ca/ecdsa-p384/{part}"), + Self::Ed25519 => format!("test-ca/eddsa/{part}"), } } @@ -1389,7 +1389,7 @@ where offs += read; } Err(err) => { - panic!("error on transfer {}..{}: {}", offs, sz, err); + panic!("error on transfer {offs}..{sz}: {err}"); } } @@ -1398,7 +1398,7 @@ where let sz = match right.reader().read(&mut [0u8; 16_384]) { Ok(sz) => sz, Err(err) if err.kind() == io::ErrorKind::WouldBlock => break, - Err(err) => panic!("failed to read data: {}", err), + Err(err) => panic!("failed to read data: {err}"), }; *left -= sz; diff --git a/rustls/.clippy.toml b/rustls/.clippy.toml new file mode 100644 index 00000000000..8b79eddd64c --- /dev/null +++ b/rustls/.clippy.toml @@ -0,0 +1,6 @@ +upper-case-acronyms-aggressive = true + +disallowed-types = [ + { path = "std::sync::Arc", reason = "must use Arc from sync module to support downstream forks targeting architectures without atomic ptrs" }, + { path = "std::sync::Weak", reason = "must use Weak from sync module to support downstream forks targeting architectures without atomic ptrs" }, +] diff --git a/rustls/build.rs b/rustls/build.rs index 9c73252a655..8c0bd2aa64b 100644 --- a/rustls/build.rs +++ b/rustls/build.rs @@ -1,7 +1,7 @@ -/// This build script allows us to enable the `read_buf` language feature only -/// for Rust Nightly. -/// -/// See the comment in lib.rs to understand why we need this. +//! This build script allows us to enable the `read_buf` language feature only +//! for Rust Nightly. +//! +//! See the comment in lib.rs to understand why we need this. #[cfg_attr(feature = "read_buf", rustversion::not(nightly))] fn main() {} diff --git a/rustls/src/bs_debug.rs b/rustls/src/bs_debug.rs index 06c723605dc..eac4149f9e6 100644 --- a/rustls/src/bs_debug.rs +++ b/rustls/src/bs_debug.rs @@ -31,7 +31,7 @@ impl fmt::Debug for BsDebug<'_> { } else if (0x20..0x7f).contains(&c) { write!(fmt, "{}", c as char)?; } else { - write!(fmt, "\\x{:02x}", c)?; + write!(fmt, "\\x{c:02x}")?; } } write!(fmt, "\"")?; diff --git a/rustls/src/builder.rs b/rustls/src/builder.rs index 342e3633600..f8ff61405b1 100644 --- a/rustls/src/builder.rs +++ b/rustls/src/builder.rs @@ -183,7 +183,7 @@ impl fmt::Debug for ConfigBuilder", name,)) + f.debug_struct(&format!("ConfigBuilder<{name}, _>",)) .field("state", &self.state) .finish() } diff --git a/rustls/src/client/common.rs b/rustls/src/client/common.rs index 74803a866e9..214fe07a2ec 100644 --- a/rustls/src/client/common.rs +++ b/rustls/src/client/common.rs @@ -60,7 +60,7 @@ impl ClientHelloDetails { let ext_type = ext.ext_type(); if !self.sent_extensions.contains(&ext_type) && !allowed_unsolicited.contains(&ext_type) { - trace!("Unsolicited extension {:?}", ext_type); + trace!("Unsolicited extension {ext_type:?}"); return true; } } diff --git a/rustls/src/client/ech.rs b/rustls/src/client/ech.rs index dec0f6ef821..e50e11018fe 100644 --- a/rustls/src/client/ech.rs +++ b/rustls/src/client/ech.rs @@ -685,7 +685,7 @@ impl EchState { }; } - trace!("ECH Inner Hello: {:#?}", inner_hello); + trace!("ECH Inner Hello: {inner_hello:#?}"); // Encode the inner hello according to the rules required for ECH. This differs // from the standard encoding in several ways. Notably this is where we will diff --git a/rustls/src/client/hs.rs b/rustls/src/client/hs.rs index 5e10682c589..e1ce25454cb 100644 --- a/rustls/src/client/hs.rs +++ b/rustls/src/client/hs.rs @@ -85,7 +85,7 @@ fn find_session( } }) .or_else(|| { - debug!("No cached session for {:?}", server_name); + debug!("No cached session for {server_name:?}"); None }); @@ -553,7 +553,7 @@ fn emit_client_hello_for_retry( tls13::emit_fake_ccs(&mut input.sent_tls13_fake_ccs, cx.common); } - trace!("Sending ClientHello {:#?}", ch); + trace!("Sending ClientHello {ch:#?}"); transcript_buffer.add_message(&ch); cx.common.send_msg(ch, false); @@ -752,7 +752,7 @@ impl State for ExpectServerHello { { let server_hello = require_handshake_msg!(m, HandshakeType::ServerHello, HandshakePayload::ServerHello)?; - trace!("We got ServerHello {:#?}", server_hello); + trace!("We got ServerHello {server_hello:#?}"); use crate::ProtocolVersion::{TLSv1_2, TLSv1_3}; let config = &self.input.config; @@ -878,7 +878,7 @@ impl State for ExpectServerHello { }); } _ => { - debug!("Using ciphersuite {:?}", suite); + debug!("Using ciphersuite {suite:?}"); self.suite = Some(suite); cx.common.suite = Some(suite); } @@ -983,7 +983,7 @@ impl ExpectServerHelloOrHelloRetryRequest { HandshakeType::HelloRetryRequest, HandshakePayload::HelloRetryRequest )?; - trace!("Got HRR {:?}", hrr); + trace!("Got HRR {hrr:?}"); cx.common.check_aligned_handshake()?; diff --git a/rustls/src/client/tls12.rs b/rustls/src/client/tls12.rs index 914ad526f92..8c24d9598d7 100644 --- a/rustls/src/client/tls12.rs +++ b/rustls/src/client/tls12.rs @@ -733,7 +733,7 @@ impl State for ExpectCertificateRequest<'_> { HandshakePayload::CertificateRequest )?; self.transcript.add_message(&m); - debug!("Got CertificateRequest {:?}", certreq); + debug!("Got CertificateRequest {certreq:?}"); // The RFC jovially describes the design here as 'somewhat complicated' // and 'somewhat underspecified'. So thanks for that. diff --git a/rustls/src/client/tls13.rs b/rustls/src/client/tls13.rs index 11830a7f3ea..90ce762cc93 100644 --- a/rustls/src/client/tls13.rs +++ b/rustls/src/client/tls13.rs @@ -470,7 +470,7 @@ impl State for ExpectEncryptedExtensions { HandshakeType::EncryptedExtensions, HandshakePayload::EncryptedExtensions )?; - debug!("TLS1.3 encrypted extensions: {:?}", exts); + debug!("TLS1.3 encrypted extensions: {exts:?}"); self.transcript.add_message(&m); validate_encrypted_extensions(cx.common, &self.hello, exts)?; @@ -854,7 +854,7 @@ impl State for ExpectCertificateRequest { HandshakePayload::CertificateRequestTls13 )?; self.transcript.add_message(&m); - debug!("Got CertificateRequest {:?}", certreq); + debug!("Got CertificateRequest {certreq:?}"); // Fortunately the problems here in TLS1.2 and prior are corrected in // TLS1.3. diff --git a/rustls/src/common_state.rs b/rustls/src/common_state.rs index 156eb0824cf..171767aff4b 100644 --- a/rustls/src/common_state.rs +++ b/rustls/src/common_state.rs @@ -503,7 +503,7 @@ impl CommonState { } fn send_warning_alert(&mut self, desc: AlertDescription) { - warn!("Sending warning alert {:?}", desc); + warn!("Sending warning alert {desc:?}"); self.send_warning_alert_no_log(desc); } diff --git a/rustls/src/conn/unbuffered.rs b/rustls/src/conn/unbuffered.rs index 59c5a51fb52..84fe3f0941a 100644 --- a/rustls/src/conn/unbuffered.rs +++ b/rustls/src/conn/unbuffered.rs @@ -564,8 +564,7 @@ impl fmt::Display for EncodeError { match self { Self::InsufficientSize(InsufficientSizeError { required_size }) => write!( f, - "cannot encode due to insufficient size, {} bytes are required", - required_size + "cannot encode due to insufficient size, {required_size} bytes are required" ), Self::AlreadyEncoded => "cannot encode, data has already been encoded".fmt(f), } diff --git a/rustls/src/crypto/aws_lc_rs/sign.rs b/rustls/src/crypto/aws_lc_rs/sign.rs index 4139906a226..ae3a21c2b99 100644 --- a/rustls/src/crypto/aws_lc_rs/sign.rs +++ b/rustls/src/crypto/aws_lc_rs/sign.rs @@ -117,7 +117,7 @@ impl RsaSigningKey { } } .map_err(|key_rejected| { - Error::General(format!("failed to parse RSA private key: {}", key_rejected)) + Error::General(format!("failed to parse RSA private key: {key_rejected}")) })?; Ok(Self { @@ -428,7 +428,7 @@ mod tests { )); let k = any_supported_type(&key).unwrap(); - assert_eq!(format!("{:?}", k), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); assert!( @@ -443,7 +443,7 @@ mod tests { .choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) .unwrap(); assert_eq!( - format!("{:?}", s), + format!("{s:?}"), "EcdsaSigner { scheme: ECDSA_NISTP256_SHA256 }" ); assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP256_SHA256); @@ -481,7 +481,7 @@ mod tests { )); let k = any_supported_type(&key).unwrap(); - assert_eq!(format!("{:?}", k), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); assert!( @@ -496,7 +496,7 @@ mod tests { .choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) .unwrap(); assert_eq!( - format!("{:?}", s), + format!("{s:?}"), "EcdsaSigner { scheme: ECDSA_NISTP384_SHA384 }" ); assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP384_SHA384); @@ -534,7 +534,7 @@ mod tests { )); let k = any_supported_type(&key).unwrap(); - assert_eq!(format!("{:?}", k), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); assert!( @@ -553,7 +553,7 @@ mod tests { .choose_scheme(&[SignatureScheme::ECDSA_NISTP521_SHA512]) .unwrap(); assert_eq!( - format!("{:?}", s), + format!("{s:?}"), "EcdsaSigner { scheme: ECDSA_NISTP521_SHA512 }" ); assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP521_SHA512); @@ -580,7 +580,7 @@ mod tests { let k = any_eddsa_type(&key).unwrap(); assert_eq!( - format!("{:?}", k), + format!("{k:?}"), "Ed25519SigningKey { algorithm: ED25519 }" ); assert_eq!(k.algorithm(), SignatureAlgorithm::ED25519); @@ -596,7 +596,7 @@ mod tests { let s = k .choose_scheme(&[SignatureScheme::ED25519]) .unwrap(); - assert_eq!(format!("{:?}", s), "Ed25519Signer { scheme: ED25519 }"); + assert_eq!(format!("{s:?}"), "Ed25519Signer { scheme: ED25519 }"); assert_eq!(s.scheme(), SignatureScheme::ED25519); assert_eq!(s.sign(b"hello").unwrap().len(), 64); } @@ -627,7 +627,7 @@ mod tests { )); let k = any_supported_type(&key).unwrap(); - assert_eq!(format!("{:?}", k), "RsaSigningKey { algorithm: RSA }"); + assert_eq!(format!("{k:?}"), "RsaSigningKey { algorithm: RSA }"); assert_eq!(k.algorithm(), SignatureAlgorithm::RSA); assert!( @@ -642,7 +642,7 @@ mod tests { let s = k .choose_scheme(&[SignatureScheme::RSA_PSS_SHA256]) .unwrap(); - assert_eq!(format!("{:?}", s), "RsaSigner { scheme: RSA_PSS_SHA256 }"); + assert_eq!(format!("{s:?}"), "RsaSigner { scheme: RSA_PSS_SHA256 }"); assert_eq!(s.scheme(), SignatureScheme::RSA_PSS_SHA256); assert_eq!(s.sign(b"hello").unwrap().len(), 256); diff --git a/rustls/src/crypto/aws_lc_rs/ticketer.rs b/rustls/src/crypto/aws_lc_rs/ticketer.rs index 31d94bf38bf..b1b245495a2 100644 --- a/rustls/src/crypto/aws_lc_rs/ticketer.rs +++ b/rustls/src/crypto/aws_lc_rs/ticketer.rs @@ -404,7 +404,7 @@ mod tests { let t = make_ticket_generator().unwrap(); - assert_eq!(format!("{:?}", t), "Rfc5077Ticketer { lifetime: 43200 }"); + assert_eq!(format!("{t:?}"), "Rfc5077Ticketer { lifetime: 43200 }"); assert!(t.enabled()); assert_eq!(t.lifetime(), 43200); } diff --git a/rustls/src/crypto/ring/sign.rs b/rustls/src/crypto/ring/sign.rs index 91b753a1cae..3486f93f913 100644 --- a/rustls/src/crypto/ring/sign.rs +++ b/rustls/src/crypto/ring/sign.rs @@ -110,7 +110,7 @@ impl RsaSigningKey { } } .map_err(|key_rejected| { - Error::General(format!("failed to parse RSA private key: {}", key_rejected)) + Error::General(format!("failed to parse RSA private key: {key_rejected}")) })?; Ok(Self { @@ -461,7 +461,7 @@ mod tests { )); let k = any_supported_type(&key).unwrap(); - assert_eq!(format!("{:?}", k), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); assert!( @@ -476,7 +476,7 @@ mod tests { .choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) .unwrap(); assert_eq!( - format!("{:?}", s), + format!("{s:?}"), "EcdsaSigner { scheme: ECDSA_NISTP256_SHA256 }" ); assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP256_SHA256); @@ -514,7 +514,7 @@ mod tests { )); let k = any_supported_type(&key).unwrap(); - assert_eq!(format!("{:?}", k), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); assert!( @@ -529,7 +529,7 @@ mod tests { .choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) .unwrap(); assert_eq!( - format!("{:?}", s), + format!("{s:?}"), "EcdsaSigner { scheme: ECDSA_NISTP384_SHA384 }" ); assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP384_SHA384); @@ -556,7 +556,7 @@ mod tests { let k = any_eddsa_type(&key).unwrap(); assert_eq!( - format!("{:?}", k), + format!("{k:?}"), "Ed25519SigningKey { algorithm: ED25519 }" ); assert_eq!(k.algorithm(), SignatureAlgorithm::ED25519); @@ -572,7 +572,7 @@ mod tests { let s = k .choose_scheme(&[SignatureScheme::ED25519]) .unwrap(); - assert_eq!(format!("{:?}", s), "Ed25519Signer { scheme: ED25519 }"); + assert_eq!(format!("{s:?}"), "Ed25519Signer { scheme: ED25519 }"); assert_eq!(s.scheme(), SignatureScheme::ED25519); assert_eq!(s.sign(b"hello").unwrap().len(), 64); } @@ -603,7 +603,7 @@ mod tests { )); let k = any_supported_type(&key).unwrap(); - assert_eq!(format!("{:?}", k), "RsaSigningKey { algorithm: RSA }"); + assert_eq!(format!("{k:?}"), "RsaSigningKey { algorithm: RSA }"); assert_eq!(k.algorithm(), SignatureAlgorithm::RSA); assert!( @@ -618,7 +618,7 @@ mod tests { let s = k .choose_scheme(&[SignatureScheme::RSA_PSS_SHA256]) .unwrap(); - assert_eq!(format!("{:?}", s), "RsaSigner { scheme: RSA_PSS_SHA256 }"); + assert_eq!(format!("{s:?}"), "RsaSigner { scheme: RSA_PSS_SHA256 }"); assert_eq!(s.scheme(), SignatureScheme::RSA_PSS_SHA256); assert_eq!(s.sign(b"hello").unwrap().len(), 256); diff --git a/rustls/src/crypto/ring/ticketer.rs b/rustls/src/crypto/ring/ticketer.rs index 95793f6223d..45fe5db8a53 100644 --- a/rustls/src/crypto/ring/ticketer.rs +++ b/rustls/src/crypto/ring/ticketer.rs @@ -370,7 +370,7 @@ mod tests { let t = make_ticket_generator().unwrap(); let expect = format!("AeadTicketer {{ alg: {TICKETER_AEAD:?}, lifetime: 43200 }}"); - assert_eq!(format!("{:?}", t), expect); + assert_eq!(format!("{t:?}"), expect); assert!(t.enabled()); assert_eq!(t.lifetime(), 43200); } diff --git a/rustls/src/error.rs b/rustls/src/error.rs index 09a4244ed4a..76569c1d4f8 100644 --- a/rustls/src/error.rs +++ b/rustls/src/error.rs @@ -591,7 +591,7 @@ impl fmt::Display for CertificateError { f, "is not valid for any names (according to its subjectAltName extension)" ), - [one] => write!(f, "is only valid for {}", one), + [one] => write!(f, "is only valid for {one}"), many => { write!(f, "is only valid for ")?; @@ -600,12 +600,12 @@ impl fmt::Display for CertificateError { let last = &many[n - 1]; for (i, name) in all_but_last.iter().enumerate() { - write!(f, "{}", name)?; + write!(f, "{name}")?; if i < n - 2 { write!(f, ", ")?; } } - write!(f, " or {}", last) + write!(f, " or {last}") } } } @@ -662,7 +662,7 @@ impl fmt::Display for CertificateError { Ok(()) } - other => write!(f, "{:?}", other), + other => write!(f, "{other:?}"), } } } @@ -812,7 +812,7 @@ impl From for Error { fn join(items: &[T]) -> String { items .iter() - .map(|x| format!("{:?}", x)) + .map(|x| format!("{x:?}")) .collect::>() .join(" or ") } @@ -839,22 +839,22 @@ impl fmt::Display for Error { join::(expect_types) ), Self::InvalidMessage(typ) => { - write!(f, "received corrupt message of type {:?}", typ) + write!(f, "received corrupt message of type {typ:?}") } - Self::PeerIncompatible(why) => write!(f, "peer is incompatible: {:?}", why), - Self::PeerMisbehaved(why) => write!(f, "peer misbehaved: {:?}", why), - Self::AlertReceived(alert) => write!(f, "received fatal alert: {:?}", alert), + Self::PeerIncompatible(why) => write!(f, "peer is incompatible: {why:?}"), + Self::PeerMisbehaved(why) => write!(f, "peer misbehaved: {why:?}"), + Self::AlertReceived(alert) => write!(f, "received fatal alert: {alert:?}"), Self::InvalidCertificate(err) => { - write!(f, "invalid peer certificate: {}", err) + write!(f, "invalid peer certificate: {err}") } Self::InvalidCertRevocationList(err) => { - write!(f, "invalid certificate revocation list: {:?}", err) + write!(f, "invalid certificate revocation list: {err:?}") } Self::NoCertificatesPresented => write!(f, "peer sent no certificates"), Self::UnsupportedNameType => write!(f, "presented server name type wasn't supported"), Self::DecryptError => write!(f, "cannot decrypt peer's message"), Self::InvalidEncryptedClientHello(err) => { - write!(f, "encrypted client hello failure: {:?}", err) + write!(f, "encrypted client hello failure: {err:?}") } Self::EncryptError => write!(f, "cannot encrypt message"), Self::PeerSentOversizedRecord => write!(f, "peer sent excess record size"), @@ -866,10 +866,10 @@ impl fmt::Display for Error { write!(f, "the supplied max_fragment_size was too small or large") } Self::InconsistentKeys(why) => { - write!(f, "keys may not be consistent: {:?}", why) + write!(f, "keys may not be consistent: {why:?}") } - Self::General(err) => write!(f, "unexpected error: {}", err), - Self::Other(err) => write!(f, "other error: {}", err), + Self::General(err) => write!(f, "unexpected error: {err}"), + Self::Other(err) => write!(f, "other error: {err}"), } } } @@ -1174,8 +1174,8 @@ mod tests { ]; for err in all { - println!("{:?}:", err); - println!(" fmt '{}'", err); + println!("{err:?}:"); + println!(" fmt '{err}'"); } } diff --git a/rustls/src/key_log_file.rs b/rustls/src/key_log_file.rs index c79771a62a8..e12b596565e 100644 --- a/rustls/src/key_log_file.rs +++ b/rustls/src/key_log_file.rs @@ -33,7 +33,7 @@ impl KeyLogFileInner { { Ok(f) => Some(f), Err(e) => { - warn!("unable to create key log file {:?}: {}", path, e); + warn!("unable to create key log file {path:?}: {e}"); None } }; @@ -53,13 +53,13 @@ impl KeyLogFileInner { }; self.buf.truncate(0); - write!(self.buf, "{} ", label)?; + write!(self.buf, "{label} ")?; for b in client_random.iter() { - write!(self.buf, "{:02x}", b)?; + write!(self.buf, "{b:02x}")?; } write!(self.buf, " ")?; for b in secret.iter() { - write!(self.buf, "{:02x}", b)?; + write!(self.buf, "{b:02x}")?; } writeln!(self.buf)?; file.write_all(&self.buf) @@ -105,7 +105,7 @@ impl KeyLog for KeyLogFile { { Ok(()) => {} Err(e) => { - warn!("error writing to key log file: {}", e); + warn!("error writing to key log file: {e}"); } } } @@ -114,7 +114,7 @@ impl KeyLog for KeyLogFile { impl Debug for KeyLogFile { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { match self.0.try_lock() { - Ok(key_log_file) => write!(f, "{:?}", key_log_file), + Ok(key_log_file) => write!(f, "{key_log_file:?}"), Err(_) => write!(f, "KeyLogFile {{ }}"), } } diff --git a/rustls/src/msgs/base.rs b/rustls/src/msgs/base.rs index 3a1b43f4981..38eb3ede32e 100644 --- a/rustls/src/msgs/base.rs +++ b/rustls/src/msgs/base.rs @@ -232,7 +232,7 @@ pub(super) fn hex<'a>( payload: impl IntoIterator, ) -> fmt::Result { for b in payload { - write!(f, "{:02x}", b)?; + write!(f, "{b:02x}")?; } Ok(()) } diff --git a/rustls/src/msgs/handshake.rs b/rustls/src/msgs/handshake.rs index 6c3cb4027f5..2926c85807b 100644 --- a/rustls/src/msgs/handshake.rs +++ b/rustls/src/msgs/handshake.rs @@ -310,8 +310,7 @@ impl<'a> Codec<'a> for ServerNamePayload<'a> { HostNamePayload::IpAddress(_invalid) => { warn!( - "Illegal SNI extension: ignoring IP address presented as hostname ({:?})", - _invalid + "Illegal SNI extension: ignoring IP address presented as hostname ({_invalid:?})" ); Some(Self::IpAddress) } diff --git a/rustls/src/msgs/handshake_test.rs b/rustls/src/msgs/handshake_test.rs index 30b07dd0c3f..f5cb1ae6332 100644 --- a/rustls/src/msgs/handshake_test.rs +++ b/rustls/src/msgs/handshake_test.rs @@ -41,7 +41,7 @@ fn reads_random() { let bytes = [0x01; 32]; let mut rd = Reader::init(&bytes); let rnd = Random::read(&mut rd).unwrap(); - println!("{:?}", rnd); + println!("{rnd:?}"); assert!(!rd.any_left()); } @@ -80,7 +80,7 @@ fn accepts_short_session_id() { let bytes = [1; 2]; let mut rd = Reader::init(&bytes); let sess = SessionId::read(&mut rd).unwrap(); - println!("{:?}", sess); + println!("{sess:?}"); #[cfg(feature = "tls12")] assert!(!sess.is_empty()); @@ -93,7 +93,7 @@ fn accepts_empty_session_id() { let bytes = [0; 1]; let mut rd = Reader::init(&bytes); let sess = SessionId::read(&mut rd).unwrap(); - println!("{:?}", sess); + println!("{sess:?}"); #[cfg(feature = "tls12")] assert!(sess.is_empty()); @@ -111,7 +111,7 @@ fn debug_session_id() { let sess = SessionId::read(&mut rd).unwrap(); assert_eq!( "0101010101010101010101010101010101010101010101010101010101010101", - format!("{:?}", sess) + format!("{sess:?}") ); } @@ -121,7 +121,7 @@ fn can_round_trip_unknown_client_ext() { let mut rd = Reader::init(&bytes); let ext = ClientExtension::read(&mut rd).unwrap(); - println!("{:?}", ext); + println!("{ext:?}"); assert_eq!(ext.ext_type(), ExtensionType::Unknown(0x1234)); assert_eq!(bytes.to_vec(), ext.get_encoding()); } @@ -173,7 +173,7 @@ fn can_round_trip_single_sni() { let bytes = [0, 0, 0, 7, 0, 5, 0, 0, 2, 0x6c, 0x6f]; let mut rd = Reader::init(&bytes); let ext = ClientExtension::read(&mut rd).unwrap(); - println!("{:?}", ext); + println!("{ext:?}"); assert_eq!(ext.ext_type(), ExtensionType::ServerName); assert_eq!(bytes.to_vec(), ext.get_encoding()); @@ -184,7 +184,7 @@ fn can_round_trip_mixed_case_sni() { let bytes = [0, 0, 0, 7, 0, 5, 0, 0, 2, 0x4c, 0x6f]; let mut rd = Reader::init(&bytes); let ext = ClientExtension::read(&mut rd).unwrap(); - println!("{:?}", ext); + println!("{ext:?}"); assert_eq!(ext.ext_type(), ExtensionType::ServerName); assert_eq!(bytes.to_vec(), ext.get_encoding()); @@ -195,7 +195,7 @@ fn single_hostname_returns_none_for_other_sni_name_types() { let bytes = [0, 0, 0, 7, 0, 5, 1, 0, 2, 0x6c, 0x6f]; let mut rd = Reader::init(&bytes); let ext = ClientExtension::read(&mut rd).unwrap(); - println!("{:?}", ext); + println!("{ext:?}"); assert_eq!(ext.ext_type(), ExtensionType::ServerName); assert!(matches!( @@ -232,13 +232,13 @@ fn rejects_truncated_sni() { fn can_round_trip_psk_identity() { let bytes = [0, 1, 0x99, 0x11, 0x22, 0x33, 0x44]; let psk_id = PresharedKeyIdentity::read(&mut Reader::init(&bytes)).unwrap(); - println!("{:?}", psk_id); + println!("{psk_id:?}"); assert_eq!(psk_id.obfuscated_ticket_age, 0x11223344); assert_eq!(psk_id.get_encoding(), bytes.to_vec()); let bytes = [0, 5, 0x1, 0x2, 0x3, 0x4, 0x5, 0x11, 0x22, 0x33, 0x44]; let psk_id = PresharedKeyIdentity::read(&mut Reader::init(&bytes)).unwrap(); - println!("{:?}", psk_id); + println!("{psk_id:?}"); assert_eq!(psk_id.identity.0, vec![0x1, 0x2, 0x3, 0x4, 0x5]); assert_eq!(psk_id.obfuscated_ticket_age, 0x11223344); assert_eq!(psk_id.get_encoding(), bytes.to_vec()); @@ -250,7 +250,7 @@ fn can_round_trip_psk_offer() { 0, 7, 0, 1, 0x99, 0x11, 0x22, 0x33, 0x44, 0, 4, 3, 0x01, 0x02, 0x3, ]; let psko = PresharedKeyOffer::read(&mut Reader::init(&bytes)).unwrap(); - println!("{:?}", psko); + println!("{psko:?}"); assert_eq!(psko.identities.len(), 1); assert_eq!(psko.identities[0].identity.0, vec![0x99]); @@ -263,7 +263,7 @@ fn can_round_trip_psk_offer() { #[test] fn can_round_trip_cert_status_req_for_ocsp() { let ext = ClientExtension::CertificateStatusRequest(CertificateStatusRequest::build_ocsp()); - println!("{:?}", ext); + println!("{ext:?}"); let bytes = [ 0, 5, // CertificateStatusRequest @@ -272,7 +272,7 @@ fn can_round_trip_cert_status_req_for_ocsp() { ]; let csr = ClientExtension::read(&mut Reader::init(&bytes)).unwrap(); - println!("{:?}", csr); + println!("{csr:?}"); assert_eq!(csr.get_encoding(), bytes.to_vec()); } @@ -285,7 +285,7 @@ fn can_round_trip_cert_status_req_for_other() { ]; let csr = ClientExtension::read(&mut Reader::init(&bytes)).unwrap(); - println!("{:?}", csr); + println!("{csr:?}"); assert_eq!(csr.get_encoding(), bytes.to_vec()); } @@ -294,7 +294,7 @@ fn can_round_trip_multi_proto() { let bytes = [0, 16, 0, 8, 0, 6, 2, 0x68, 0x69, 2, 0x6c, 0x6f]; let mut rd = Reader::init(&bytes); let ext = ClientExtension::read(&mut rd).unwrap(); - println!("{:?}", ext); + println!("{ext:?}"); assert_eq!(ext.ext_type(), ExtensionType::ALProtocolNegotiation); assert_eq!(ext.get_encoding(), bytes.to_vec()); @@ -317,7 +317,7 @@ fn can_round_trip_single_proto() { let bytes = [0, 16, 0, 5, 0, 3, 2, 0x68, 0x69]; let mut rd = Reader::init(&bytes); let ext = ClientExtension::read(&mut rd).unwrap(); - println!("{:?}", ext); + println!("{ext:?}"); assert_eq!(ext.ext_type(), ExtensionType::ALProtocolNegotiation); assert_eq!(bytes.to_vec(), ext.get_encoding()); @@ -367,7 +367,7 @@ fn test_truncated_psk_offer() { }); let mut enc = ext.get_encoding(); - println!("testing {:?} enc {:?}", ext, enc); + println!("testing {ext:?} enc {enc:?}"); for l in 0..enc.len() { if l == 9 { continue; @@ -382,7 +382,7 @@ fn test_truncated_psk_offer() { fn test_truncated_client_hello_is_detected() { let ch = sample_client_hello_payload(); let enc = ch.get_encoding(); - println!("testing {:?} enc {:?}", ch, enc); + println!("testing {ch:?} enc {enc:?}"); for l in 0..enc.len() { println!("len {:?} enc {:?}", l, &enc[..l]); @@ -399,7 +399,7 @@ fn test_truncated_client_extension_is_detected() { for ext in &chp.extensions { let mut enc = ext.get_encoding(); - println!("testing {:?} enc {:?}", ext, enc); + println!("testing {ext:?} enc {enc:?}"); // "outer" truncation, i.e., where the extension-level length is longer than // the input @@ -419,7 +419,7 @@ fn test_truncated_client_extension_is_detected() { // length, but isn't long enough for the type of extension for l in 0..(enc.len() - 4) { put_u16(l as u16, &mut enc[2..]); - println!(" encoding {:?} len {:?}", enc, l); + println!(" encoding {enc:?} len {l:?}"); assert!(ClientExtension::read_bytes(&enc).is_err()); } } @@ -533,7 +533,7 @@ fn test_truncated_hello_retry_extension_is_detected() { for ext in &hrr.extensions { let mut enc = ext.get_encoding(); - println!("testing {:?} enc {:?}", ext, enc); + println!("testing {ext:?} enc {enc:?}"); // "outer" truncation, i.e., where the extension-level length is longer than // the input @@ -550,7 +550,7 @@ fn test_truncated_hello_retry_extension_is_detected() { // length, but isn't long enough for the type of extension for l in 0..(enc.len() - 4) { put_u16(l as u16, &mut enc[2..]); - println!(" encoding {:?} len {:?}", enc, l); + println!(" encoding {enc:?} len {l:?}"); assert!(HelloRetryExtension::read_bytes(&enc).is_err()); } } @@ -599,7 +599,7 @@ fn test_truncated_server_extension_is_detected() { for ext in &shp.extensions { let mut enc = ext.get_encoding(); - println!("testing {:?} enc {:?}", ext, enc); + println!("testing {ext:?} enc {enc:?}"); // "outer" truncation, i.e., where the extension-level length is longer than // the input @@ -619,7 +619,7 @@ fn test_truncated_server_extension_is_detected() { // length, but isn't long enough for the type of extension for l in 0..(enc.len() - 4) { put_u16(l as u16, &mut enc[2..]); - println!(" encoding {:?} len {:?}", enc, l); + println!(" encoding {enc:?} len {l:?}"); assert!(ServerExtension::read_bytes(&enc).is_err()); } } @@ -728,8 +728,8 @@ fn can_round_trip_all_tls12_handshake_payloads() { assert!(!rd.any_left()); assert_eq!(hm.get_encoding(), other.get_encoding()); - println!("{:?}", hm); - println!("{:?}", other); + println!("{hm:?}"); + println!("{other:?}"); } } @@ -748,7 +748,7 @@ fn can_into_owned_all_tls12_handshake_payloads() { fn can_detect_truncation_of_all_tls12_handshake_payloads() { for hm in all_tls12_handshake_payloads().iter() { let mut enc = hm.get_encoding(); - println!("test {:?} enc {:?}", hm, enc); + println!("test {hm:?} enc {enc:?}"); // outer truncation for l in 0..enc.len() { @@ -758,7 +758,7 @@ fn can_detect_truncation_of_all_tls12_handshake_payloads() { // inner truncation for l in 0..enc.len() - 4 { put_u24(l as u32, &mut enc[1..]); - println!(" check len {:?} enc {:?}", l, enc); + println!(" check len {l:?} enc {enc:?}"); match (hm.typ, l) { (HandshakeType::ClientHello, 41) @@ -794,8 +794,8 @@ fn can_round_trip_all_tls13_handshake_payloads() { assert!(!rd.any_left()); assert_eq!(hm.get_encoding(), other.get_encoding()); - println!("{:?}", hm); - println!("{:?}", other); + println!("{hm:?}"); + println!("{other:?}"); } } @@ -814,7 +814,7 @@ fn can_into_owned_all_tls13_handshake_payloads() { fn can_detect_truncation_of_all_tls13_handshake_payloads() { for hm in all_tls13_handshake_payloads().iter() { let mut enc = hm.get_encoding(); - println!("test {:?} enc {:?}", hm, enc); + println!("test {hm:?} enc {enc:?}"); // outer truncation for l in 0..enc.len() { @@ -824,7 +824,7 @@ fn can_detect_truncation_of_all_tls13_handshake_payloads() { // inner truncation for l in 0..enc.len() - 4 { put_u24(l as u32, &mut enc[1..]); - println!(" check len {:?} enc {:?}", l, enc); + println!(" check len {l:?} enc {enc:?}"); match (hm.typ, l) { (HandshakeType::ClientHello, 41) @@ -859,7 +859,7 @@ fn cannot_read_message_hash_from_network() { typ: HandshakeType::MessageHash, payload: HandshakePayload::MessageHash(Payload::new(vec![1, 2, 3])), }; - println!("mh {:?}", mh); + println!("mh {mh:?}"); let enc = mh.get_encoding(); assert!(HandshakeMessagePayload::read_bytes(&enc).is_err()); } @@ -898,7 +898,7 @@ fn can_decode_server_hello_from_api_devicecheck_apple_com() { let data = include_bytes!("../testdata/hello-api.devicecheck.apple.com.bin"); let mut r = Reader::init(data); let hm = HandshakeMessagePayload::read(&mut r).unwrap(); - println!("msg: {:?}", hm); + println!("msg: {hm:?}"); } #[test] diff --git a/rustls/src/msgs/message/outbound.rs b/rustls/src/msgs/message/outbound.rs index 7345e54b37e..810c066cb5c 100644 --- a/rustls/src/msgs/message/outbound.rs +++ b/rustls/src/msgs/message/outbound.rs @@ -318,7 +318,7 @@ mod tests { let borrowed_payload = OutboundChunks::Single(owner); let (before, after) = borrowed_payload.split_at(6); - println!("before:{:?}\nafter:{:?}", before, after); + println!("before:{before:?}\nafter:{after:?}"); assert_eq!(before.to_vec(), &[0, 1, 2, 3, 4, 5]); assert_eq!(after.to_vec(), &[6, 7]); } @@ -329,17 +329,17 @@ mod tests { let borrowed_payload = OutboundChunks::new(&owner); let (before, after) = borrowed_payload.split_at(3); - println!("before:{:?}\nafter:{:?}", before, after); + println!("before:{before:?}\nafter:{after:?}"); assert_eq!(before.to_vec(), &[0, 1, 2]); assert_eq!(after.to_vec(), &[3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); let (before, after) = borrowed_payload.split_at(8); - println!("before:{:?}\nafter:{:?}", before, after); + println!("before:{before:?}\nafter:{after:?}"); assert_eq!(before.to_vec(), &[0, 1, 2, 3, 4, 5, 6, 7]); assert_eq!(after.to_vec(), &[8, 9, 10, 11, 12]); let (before, after) = borrowed_payload.split_at(11); - println!("before:{:?}\nafter:{:?}", before, after); + println!("before:{before:?}\nafter:{after:?}"); assert_eq!(before.to_vec(), &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); assert_eq!(after.to_vec(), &[11, 12]); } @@ -350,19 +350,19 @@ mod tests { let single_payload = OutboundChunks::Single(owner[0]); let (before, after) = single_payload.split_at(17); - println!("before:{:?}\nafter:{:?}", before, after); + println!("before:{before:?}\nafter:{after:?}"); assert_eq!(before.to_vec(), &[0, 1, 2, 3]); assert!(after.is_empty()); let multiple_payload = OutboundChunks::new(&owner); let (before, after) = multiple_payload.split_at(17); - println!("before:{:?}\nafter:{:?}", before, after); + println!("before:{before:?}\nafter:{after:?}"); assert_eq!(before.to_vec(), &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); assert!(after.is_empty()); let empty_payload = OutboundChunks::new_empty(); let (before, after) = empty_payload.split_at(17); - println!("before:{:?}\nafter:{:?}", before, after); + println!("before:{before:?}\nafter:{after:?}"); assert!(before.is_empty()); assert!(after.is_empty()); } @@ -393,7 +393,7 @@ mod tests { let payload = OutboundChunks::new(&slices); assert_eq!(payload.to_vec(), owner); - println!("{:#?}", payload); + println!("{payload:#?}"); for start in 0..128 { for end in start..128 { diff --git a/rustls/src/msgs/message_test.rs b/rustls/src/msgs/message_test.rs index c52fde58575..013f41eb565 100644 --- a/rustls/src/msgs/message_test.rs +++ b/rustls/src/msgs/message_test.rs @@ -32,7 +32,7 @@ fn test_read_fuzz_corpus() { let msg = OutboundOpaqueMessage::read(&mut rd) .unwrap() .into_plain_message(); - println!("{:?}", msg); + println!("{msg:?}"); let Ok(msg) = Message::try_from(msg) else { continue; @@ -70,7 +70,7 @@ fn can_read_safari_client_hello_with_ip_address_in_sni_extension() { \x01\x00\x00\x0a\x00\x0a\x00\x08\x00\x1d\x00\x17\x00\x18\x00\x19"; let mut rd = Reader::init(bytes); let m = OutboundOpaqueMessage::read(&mut rd).unwrap(); - println!("m = {:?}", m); + println!("m = {m:?}"); Message::try_from(m.into_plain_message()).unwrap(); } @@ -91,9 +91,9 @@ fn construct_all_types() { ]; for &bytes in samples.iter() { let m = OutboundOpaqueMessage::read(&mut Reader::init(bytes)).unwrap(); - println!("m = {:?}", m); + println!("m = {m:?}"); let m = Message::try_from(m.into_plain_message()); - println!("m' = {:?}", m); + println!("m' = {m:?}"); } } diff --git a/rustls/src/msgs/persist.rs b/rustls/src/msgs/persist.rs index 9179eedfd52..8ddec1699c9 100644 --- a/rustls/src/msgs/persist.rs +++ b/rustls/src/msgs/persist.rs @@ -435,11 +435,7 @@ impl ServerSessionValue { .saturating_sub(self.creation_time_sec) as u32) .saturating_mul(1000); - let age_difference = if client_age_ms < server_age_ms { - server_age_ms - client_age_ms - } else { - client_age_ms - server_age_ms - }; + let age_difference = server_age_ms.abs_diff(client_age_ms); self.freshness = Some(age_difference <= MAX_FRESHNESS_SKEW_MS); self @@ -469,7 +465,7 @@ mod tests { UnixTime::now(), 0x12345678, ); - println!("{:?}", ssv); + println!("{ssv:?}"); } #[test] diff --git a/rustls/src/server/hs.rs b/rustls/src/server/hs.rs index f426cff870c..b3c0e9a1b27 100644 --- a/rustls/src/server/hs.rs +++ b/rustls/src/server/hs.rs @@ -91,7 +91,7 @@ impl ExtensionProcessing { }) .cloned(); if let Some(selected_protocol) = &cx.common.alpn_protocol { - debug!("Chosen ALPN protocol {:?}", selected_protocol); + debug!("Chosen ALPN protocol {selected_protocol:?}"); self.exts .push(ServerExtension::Protocols(SingleProtocolName::new( selected_protocol.clone(), @@ -449,7 +449,7 @@ impl ExpectClientHello { .send_fatal_alert(AlertDescription::HandshakeFailure, incompat) })?; - debug!("decided upon suite {:?}", suite); + debug!("decided upon suite {suite:?}"); cx.common.suite = Some(suite); cx.common.kx_state = KxState::Start(skxg); @@ -672,7 +672,7 @@ pub(super) fn process_client_hello<'m>( ) -> Result<(&'m ClientHelloPayload, Vec), Error> { let client_hello = require_handshake_msg!(m, HandshakeType::ClientHello, HandshakePayload::ClientHello)?; - trace!("we got a clienthello {:?}", client_hello); + trace!("we got a clienthello {client_hello:?}"); if !client_hello .compression_methods diff --git a/rustls/src/server/tls12.rs b/rustls/src/server/tls12.rs index 8fc46de7382..c0c403c6eea 100644 --- a/rustls/src/server/tls12.rs +++ b/rustls/src/server/tls12.rs @@ -91,7 +91,7 @@ mod client_hello { .ecpoints_extension() .unwrap_or(&[ECPointFormat::Uncompressed]); - trace!("ecpoints {:?}", ecpoints_ext); + trace!("ecpoints {ecpoints_ext:?}"); if !ecpoints_ext.contains(&ECPointFormat::Uncompressed) { return Err(cx.common.send_fatal_alert( @@ -358,7 +358,7 @@ mod client_hello { extensions: ep.exts, }), }; - trace!("sending server hello {:?}", sh); + trace!("sending server hello {sh:?}"); flight.add(sh); Ok(ep.send_ticket) @@ -445,7 +445,7 @@ mod client_hello { payload: HandshakePayload::CertificateRequest(cr), }; - trace!("Sending CertificateRequest {:?}", creq); + trace!("Sending CertificateRequest {creq:?}"); flight.add(creq); Ok(true) } @@ -492,7 +492,7 @@ impl State for ExpectCertificate { .verifier .client_auth_mandatory(); - trace!("certs {:?}", cert_chain); + trace!("certs {cert_chain:?}"); let client_cert = match cert_chain.split_first() { None if mandatory => { diff --git a/rustls/src/server/tls13.rs b/rustls/src/server/tls13.rs index 4af77ddb611..5e55dff9e09 100644 --- a/rustls/src/server/tls13.rs +++ b/rustls/src/server/tls13.rs @@ -532,7 +532,7 @@ mod client_hello { let client_hello_hash = transcript.hash_given(&[]); - trace!("sending server hello {:?}", sh); + trace!("sending server hello {sh:?}"); transcript.add_message(&sh); cx.common.send_msg(sh, false); @@ -605,7 +605,7 @@ mod client_hello { }), }; - trace!("Requesting retry {:?}", m); + trace!("Requesting retry {m:?}"); transcript.rollup_for_hrr(); transcript.add_message(&m); common.send_msg(m, false); @@ -691,7 +691,7 @@ mod client_hello { payload: HandshakePayload::EncryptedExtensions(ep.exts), }; - trace!("sending encrypted extensions {:?}", ee); + trace!("sending encrypted extensions {ee:?}"); flight.add(ee); Ok(early_data) } @@ -737,7 +737,7 @@ mod client_hello { payload: HandshakePayload::CertificateRequestTls13(cr), }; - trace!("Sending CertificateRequest {:?}", creq); + trace!("Sending CertificateRequest {creq:?}"); flight.add(creq); Ok(true) } @@ -755,7 +755,7 @@ mod client_hello { )), }; - trace!("sending certificate {:?}", cert); + trace!("sending certificate {cert:?}"); flight.add(cert); } @@ -780,7 +780,7 @@ mod client_hello { payload: HandshakePayload::CompressedCertificate(entry.compressed_cert_payload()), }; - trace!("sending compressed certificate {:?}", c); + trace!("sending compressed certificate {c:?}"); flight.add(c); } @@ -811,7 +811,7 @@ mod client_hello { payload: HandshakePayload::CertificateVerify(cv), }; - trace!("sending certificate-verify {:?}", cv); + trace!("sending certificate-verify {cv:?}"); flight.add(cv); Ok(()) } @@ -832,7 +832,7 @@ mod client_hello { payload: HandshakePayload::Finished(verify_data_payload), }; - trace!("sending finished {:?}", fin); + trace!("sending finished {fin:?}"); flight.add(fin); let hash_at_server_fin = flight.transcript.current_hash(); flight.finish(cx.common); @@ -1344,7 +1344,7 @@ impl ExpectFinished { typ: HandshakeType::NewSessionTicket, payload: HandshakePayload::NewSessionTicketTls13(payload), }; - trace!("sending new ticket {:?} (stateless: {})", t, stateless); + trace!("sending new ticket {t:?} (stateless: {stateless})"); flight.add(t); Ok(()) diff --git a/rustls/src/webpki/anchors.rs b/rustls/src/webpki/anchors.rs index e4558db889b..b526ed252ab 100644 --- a/rustls/src/webpki/anchors.rs +++ b/rustls/src/webpki/anchors.rs @@ -45,15 +45,14 @@ impl RootCertStore { } Err(err) => { trace!("invalid cert der {:?}", der_cert.as_ref()); - debug!("certificate parsing failed: {:?}", err); + debug!("certificate parsing failed: {err:?}"); invalid_count += 1; } }; } debug!( - "add_parsable_certificates processed {} valid and {} invalid certs", - valid_count, invalid_count + "add_parsable_certificates processed {valid_count} valid and {invalid_count} invalid certs" ); (valid_count, invalid_count) @@ -138,7 +137,7 @@ fn root_cert_store_debug() { let store = RootCertStore::from_iter(iter::repeat(ta).take(138)); assert_eq!( - format!("{:?}", store), + format!("{store:?}"), "RootCertStore { roots: \"(138 roots)\" }" ); } diff --git a/rustls/src/webpki/client_verifier.rs b/rustls/src/webpki/client_verifier.rs index a69264bcb0c..78bb7720ed0 100644 --- a/rustls/src/webpki/client_verifier.rs +++ b/rustls/src/webpki/client_verifier.rs @@ -488,7 +488,7 @@ mod tests { provider::default_provider().into(), ); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -502,7 +502,7 @@ mod tests { ) .allow_unauthenticated(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -516,7 +516,7 @@ mod tests { provider::default_provider().into(), ); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -530,7 +530,7 @@ mod tests { ) .allow_unauthenticated(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -564,7 +564,7 @@ mod tests { // There should be the expected number of crls. assert_eq!(builder.crls.len(), initial_crls.len() + extra_crls.len()); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -578,7 +578,7 @@ mod tests { ) .with_crls(test_crls()); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -593,7 +593,7 @@ mod tests { .with_crls(test_crls()) .allow_unauthenticated(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -607,7 +607,7 @@ mod tests { .with_crls(test_crls()) .only_check_end_entity_revocation(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -621,7 +621,7 @@ mod tests { .with_crls(test_crls()) .allow_unknown_revocation_status(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -635,7 +635,7 @@ mod tests { .with_crls(test_crls()) .enforce_revocation_expiration(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -658,8 +658,8 @@ mod tests { ]; for err in all { - let _ = format!("{:?}", err); - let _ = format!("{}", err); + let _ = format!("{err:?}"); + let _ = format!("{err}"); } } } diff --git a/rustls/src/webpki/mod.rs b/rustls/src/webpki/mod.rs index c6c40916a7a..2c7e5a17171 100644 --- a/rustls/src/webpki/mod.rs +++ b/rustls/src/webpki/mod.rs @@ -48,7 +48,7 @@ impl fmt::Display for VerifierBuilderError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::NoRootAnchors => write!(f, "no root trust anchors were provided"), - Self::InvalidCrl(e) => write!(f, "provided CRL could not be parsed: {:?}", e), + Self::InvalidCrl(e) => write!(f, "provided CRL could not be parsed: {e:?}"), } } } diff --git a/rustls/src/webpki/server_verifier.rs b/rustls/src/webpki/server_verifier.rs index 5c54e7fe660..9405c123a23 100644 --- a/rustls/src/webpki/server_verifier.rs +++ b/rustls/src/webpki/server_verifier.rs @@ -375,7 +375,7 @@ mod tests { // There should be the expected number of crls. assert_eq!(builder.crls.len(), initial_crls.len() + extra_crls.len()); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -399,7 +399,7 @@ mod tests { ) .only_check_end_entity_revocation(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -413,7 +413,7 @@ mod tests { ) .allow_unknown_revocation_status(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -428,7 +428,7 @@ mod tests { .allow_unknown_revocation_status() .only_check_end_entity_revocation(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } @@ -442,7 +442,7 @@ mod tests { ) .enforce_revocation_expiration(); // The builder should be Debug. - println!("{:?}", builder); + println!("{builder:?}"); builder.build().unwrap(); } } diff --git a/rustls/tests/api.rs b/rustls/tests/api.rs index 95bc0cbf642..b6b10bc080c 100644 --- a/rustls/tests/api.rs +++ b/rustls/tests/api.rs @@ -562,8 +562,7 @@ fn version_test( let server_config = make_server_config_with_versions(KeyType::Rsa2048, server_versions); println!( - "version {:?} {:?} -> {:?}", - client_versions, server_versions, result + "version {client_versions:?} {server_versions:?} -> {result:?}" ); let (mut client, mut server) = make_pair_for_configs(client_config, server_config); @@ -1090,11 +1089,11 @@ fn test_config_builders_debug() { } .into(), ); - let _ = format!("{:?}", b); + let _ = format!("{b:?}"); let b = server_config_builder_with_versions(&[&rustls::version::TLS13]); - let _ = format!("{:?}", b); + let _ = format!("{b:?}"); let b = b.with_no_client_auth(); - let _ = format!("{:?}", b); + let _ = format!("{b:?}"); let b = ClientConfig::builder_with_provider( CryptoProvider { @@ -1104,9 +1103,9 @@ fn test_config_builders_debug() { } .into(), ); - let _ = format!("{:?}", b); + let _ = format!("{b:?}"); let b = client_config_builder_with_versions(&[&rustls::version::TLS13]); - let _ = format!("{:?}", b); + let _ = format!("{b:?}"); } /// Test that the server handles combination of `offer_client_auth()` returning true @@ -2762,7 +2761,7 @@ fn client_fill_buf_returns_wouldblock_when_no_data() { fn new_server_returns_initial_io_state() { let (_, mut server) = make_pair(KeyType::Rsa2048); let io_state = server.process_new_packets().unwrap(); - println!("IoState is Debug {:?}", io_state); + println!("IoState is Debug {io_state:?}"); assert_eq!(io_state.plaintext_bytes_to_read(), 0); assert!(!io_state.peer_has_closed()); assert_eq!(io_state.tls_bytes_to_write(), 0); @@ -2772,7 +2771,7 @@ fn new_server_returns_initial_io_state() { fn new_client_returns_initial_io_state() { let (mut client, _) = make_pair(KeyType::Rsa2048); let io_state = client.process_new_packets().unwrap(); - println!("IoState is Debug {:?}", io_state); + println!("IoState is Debug {io_state:?}"); assert_eq!(io_state.plaintext_bytes_to_read(), 0); assert!(!io_state.peer_has_closed()); assert!(io_state.tls_bytes_to_write() > 200); @@ -3259,7 +3258,7 @@ fn stream_write_swallows_underlying_io_error_after_plaintext_processed() { .unwrap(); let mut client_stream = Stream::new(&mut client, &mut pipe); let rc = client_stream.write(b"world"); - assert_eq!(format!("{:?}", rc), "Ok(5)"); + assert_eq!(format!("{rc:?}"), "Ok(5)"); } fn make_disjoint_suite_configs() -> (ClientConfig, ServerConfig) { @@ -3300,13 +3299,13 @@ fn client_stream_handshake_error() { let rc = client_stream.write(b"hello"); assert!(rc.is_err()); assert_eq!( - format!("{:?}", rc), + format!("{rc:?}"), "Err(Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) })" ); let rc = client_stream.write(b"hello"); assert!(rc.is_err()); assert_eq!( - format!("{:?}", rc), + format!("{rc:?}"), "Err(Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) })" ); } @@ -3322,13 +3321,13 @@ fn client_streamowned_handshake_error() { let rc = client_stream.write(b"hello"); assert!(rc.is_err()); assert_eq!( - format!("{:?}", rc), + format!("{rc:?}"), "Err(Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) })" ); let rc = client_stream.write(b"hello"); assert!(rc.is_err()); assert_eq!( - format!("{:?}", rc), + format!("{rc:?}"), "Err(Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) })" ); @@ -3352,7 +3351,7 @@ fn server_stream_handshake_error() { let rc = server_stream.read(&mut bytes); assert!(rc.is_err()); assert_eq!( - format!("{:?}", rc), + format!("{rc:?}"), "Err(Custom { kind: InvalidData, error: PeerIncompatible(NoCipherSuitesInCommon) })" ); } @@ -3374,7 +3373,7 @@ fn server_streamowned_handshake_error() { let rc = server_stream.read(&mut bytes); assert!(rc.is_err()); assert_eq!( - format!("{:?}", rc), + format!("{rc:?}"), "Err(Custom { kind: InvalidData, error: PeerIncompatible(NoCipherSuitesInCommon) })" ); } @@ -3392,13 +3391,13 @@ fn client_config_is_clone() { #[test] fn client_connection_is_debug() { let (client, _) = make_pair(KeyType::Rsa2048); - println!("{:?}", client); + println!("{client:?}"); } #[test] fn server_connection_is_debug() { let (_, server) = make_pair(KeyType::Rsa2048); - println!("{:?}", server); + println!("{server:?}"); } #[test] @@ -5350,7 +5349,7 @@ mod test_quic { ]; for &(size, ok) in cases.iter() { - println!("early data size case: {:?}", size); + println!("early data size case: {size:?}"); if let Some(new) = size { server_config.max_early_data_size = new; } @@ -5929,7 +5928,7 @@ fn test_client_attempts_to_use_unsupported_kx_group() { do_handshake_until_error(&mut client_1, &mut server).unwrap(); let ops = shared_storage.ops(); - println!("storage {:#?}", ops); + println!("storage {ops:#?}"); assert_eq!(ops.len(), 7); assert!(matches!( ops[3], @@ -5985,7 +5984,7 @@ fn test_client_sends_share_for_less_preferred_group() { do_handshake_until_error(&mut client_1, &mut server).unwrap(); let ops = shared_storage.ops(); - println!("storage {:#?}", ops); + println!("storage {ops:#?}"); assert_eq!(ops.len(), 7); assert!(matches!( ops[3], @@ -6003,9 +6002,9 @@ fn test_client_sends_share_for_less_preferred_group() { assert_eq!(keyshares.len(), 1); assert_eq!(keyshares[0].group(), rustls::NamedGroup::secp384r1); } - _ => panic!("unexpected handshake message {:?}", parsed), + _ => panic!("unexpected handshake message {parsed:?}"), }, - _ => panic!("unexpected non-handshake message {:?}", msg), + _ => panic!("unexpected non-handshake message {msg:?}"), }; Altered::InPlace }; @@ -6017,10 +6016,10 @@ fn test_client_sends_share_for_less_preferred_group() { let group = hrr.requested_key_share_group(); assert_eq!(group, Some(rustls::NamedGroup::X25519)); } - _ => panic!("unexpected handshake message {:?}", parsed), + _ => panic!("unexpected handshake message {parsed:?}"), }, MessagePayload::ChangeCipherSpec(_) => (), - _ => panic!("unexpected non-handshake message {:?}", msg), + _ => panic!("unexpected non-handshake message {msg:?}"), }; Altered::InPlace }; @@ -6059,7 +6058,7 @@ fn test_tls13_client_resumption_does_not_reuse_tickets() { do_handshake_until_error(&mut client, &mut server).unwrap(); let ops = shared_storage.ops_and_reset(); - println!("storage {:#?}", ops); + println!("storage {ops:#?}"); assert_eq!(ops.len(), 10); assert!(matches!(ops[5], ClientStorageOp::InsertTls13Ticket(_))); assert!(matches!(ops[6], ClientStorageOp::InsertTls13Ticket(_))); @@ -6090,7 +6089,7 @@ fn test_tls13_client_resumption_does_not_reuse_tickets() { server.process_new_packets().unwrap(); let ops = shared_storage.ops_and_reset(); - println!("last {:?}", ops); + println!("last {ops:?}"); assert!(matches!(ops[0], ClientStorageOp::TakeTls13Ticket(_, false))); } @@ -6134,7 +6133,7 @@ fn test_client_mtu_reduction() { let mut client = ClientConnection::new(Arc::new(client_config), server_name("localhost")).unwrap(); let writes = collect_write_lengths(&mut client); - println!("writes at mtu=64: {:?}", writes); + println!("writes at mtu=64: {writes:?}"); assert!(writes.iter().all(|x| *x <= 64)); assert!(writes.len() > 1); } @@ -6250,7 +6249,7 @@ fn handshakes_complete_and_data_flows_with_gratuitious_max_fragment_sizes() { fn assert_lt(left: usize, right: usize) { if left >= right { - panic!("expected {} < {}", left, right); + panic!("expected {left} < {right}"); } } @@ -6395,7 +6394,7 @@ fn test_server_rejects_clients_without_any_kx_group_overlap() { fn test_client_rejects_illegal_tls13_ccs() { fn corrupt_ccs(msg: &mut Message) -> Altered { if let MessagePayload::ChangeCipherSpec(_) = &mut msg.payload { - println!("seen CCS {:?}", msg); + println!("seen CCS {msg:?}"); return Altered::Raw(encoding::message_framing( ContentType::ChangeCipherSpec, ProtocolVersion::TLSv1_2, diff --git a/rustls/tests/common/mod.rs b/rustls/tests/common/mod.rs index 41fdc01e337..3af0a4d8436 100644 --- a/rustls/tests/common/mod.rs +++ b/rustls/tests/common/mod.rs @@ -1084,8 +1084,7 @@ impl ServerCertVerifier for MockServerVerifier { now: UnixTime, ) -> Result { println!( - "verify_server_cert({:?}, {:?}, {:?}, {:?}, {:?})", - end_entity, intermediates, server_name, ocsp_response, now + "verify_server_cert({end_entity:?}, {intermediates:?}, {server_name:?}, {ocsp_response:?}, {now:?})" ); if let Some(expected_ocsp) = &self.expected_ocsp_response { assert_eq!(expected_ocsp, ocsp_response); @@ -1103,8 +1102,7 @@ impl ServerCertVerifier for MockServerVerifier { dss: &DigitallySignedStruct, ) -> Result { println!( - "verify_tls12_signature({:?}, {:?}, {:?})", - message, cert, dss + "verify_tls12_signature({message:?}, {cert:?}, {dss:?})" ); match &self.tls12_signature_error { Some(error) => Err(error.clone()), @@ -1119,8 +1117,7 @@ impl ServerCertVerifier for MockServerVerifier { dss: &DigitallySignedStruct, ) -> Result { println!( - "verify_tls13_signature({:?}, {:?}, {:?})", - message, cert, dss + "verify_tls13_signature({message:?}, {cert:?}, {dss:?})" ); match &self.tls13_signature_error { Some(error) => Err(error.clone()), diff --git a/rustls/tests/unbuffered.rs b/rustls/tests/unbuffered.rs index bb5292ae71b..706f7e16e98 100644 --- a/rustls/tests/unbuffered.rs +++ b/rustls/tests/unbuffered.rs @@ -1107,7 +1107,7 @@ fn advance_client( let UnbufferedStatus { discard, state } = conn.process_tls_records(buffers.incoming.filled()); let state = state.unwrap(); - transcript.push(format!("{:?}", state)); + transcript.push(format!("{state:?}")); let state = match state { ConnectionState::TransmitTlsData(mut state) => { @@ -1152,7 +1152,7 @@ fn advance_server( let UnbufferedStatus { discard, state } = conn.process_tls_records(buffers.incoming.filled()); let state = state.unwrap(); - transcript.push(format!("{:?}", state)); + transcript.push(format!("{state:?}")); let state = match state { ConnectionState::ReadEarlyData(mut state) => { @@ -1424,7 +1424,7 @@ fn server_receives_handshake_byte_by_byte() { _ => panic!("unexpected first client event"), }; - println!("client hello: {:?}", client_hello_buffer); + println!("client hello: {client_hello_buffer:?}"); for prefix in 0..client_hello_buffer.len() - 1 { let UnbufferedStatus { discard, state } = pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy