From f843bc293a694ce4a4e2ae8e3c62824ce60ee428 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Sat, 10 Oct 2026 00:00:00 +0000 Subject: [PATCH] style(body,proto): enforce clippy::rest_pattern_accessible_field see https://github.com/hyperium/hyper/issues/4071. see . this lint disallows `..` patterns for accessible fields. this is helpful because it calls attention to locations that may need to be updated when the contents of a structure changes. allowances are left in place for simple accessors. because the lint_reason feature is not supported across the range of our MSRV, we use `/*reason: explanation*/` comments for now. an explicit allowance of `unneeded_field_pattern` is added, because these two lints conflict: we can either expect exhaustive matching, or we can expect that no fields are explicitly ignored. the former is more verbose, but draws attention to where logic may need to be updated as a type evolves over time. Signed-off-by: katelyn martin --- Cargo.toml | 2 +- src/body/incoming.rs | 24 ++++++++++++++++++++---- src/proto/h1/decode.rs | 7 ++++++- src/proto/h1/io.rs | 2 ++ src/proto/h2/server.rs | 5 ++++- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f7f7f1e6c4..6ccdec583f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,7 +137,6 @@ unwrap_in_result = "allow" wildcard_enum_match_arm = "allow" definition_in_module_root = "allow" unnecessary_rest_pattern = "allow" -rest_pattern_accessible_field = "allow" needless_bool = "allow" # explicitly allowed @@ -191,6 +190,7 @@ too_many_lines = "allow" # reconsider someday? type_complexity = "allow" # not helpful used_underscore_items = "allow" unnecessary_safety_comment = "allow" # more safety comments are a good thing +unneeded_field_pattern = "allow" # exhaustive matching is helpful unseparated_literal_suffix = "allow" # i don't like 0_u8 (do i?) [package.metadata.docs.rs] diff --git a/src/body/incoming.rs b/src/body/incoming.rs index b026a24d6b..ff9e3c02a3 100644 --- a/src/body/incoming.rs +++ b/src/body/incoming.rs @@ -235,9 +235,17 @@ impl Body for Incoming { match &self.kind { Kind::Empty => true, #[cfg(all(feature = "http1", any(feature = "client", feature = "server")))] - Kind::Chan { content_length, .. } => *content_length == DecodedLength::ZERO, + Kind::Chan { + content_length, + rx: _, + } => *content_length == DecodedLength::ZERO, #[cfg(all(feature = "http2", any(feature = "client", feature = "server")))] - Kind::H2 { recv: h2, .. } => h2.is_end_stream(), + Kind::H2 { + recv: h2, + content_length: _, + data_done: _, + ping: _, + } => h2.is_end_stream(), #[cfg(feature = "ffi")] Kind::Ffi(..) => false, } @@ -259,9 +267,17 @@ impl Body for Incoming { match self.kind { Kind::Empty => SizeHint::with_exact(0), #[cfg(all(feature = "http1", any(feature = "client", feature = "server")))] - Kind::Chan { content_length, .. } => opt_len(content_length), + Kind::Chan { + content_length, + rx: _, + } => opt_len(content_length), #[cfg(all(feature = "http2", any(feature = "client", feature = "server")))] - Kind::H2 { content_length, .. } => opt_len(content_length), + Kind::H2 { + content_length, + data_done: _, + ping: _, + recv: _, + } => opt_len(content_length), #[cfg(feature = "ffi")] Kind::Ffi(..) => SizeHint::default(), } diff --git a/src/proto/h1/decode.rs b/src/proto/h1/decode.rs index 9d8ed7f408..926dcb347c 100644 --- a/src/proto/h1/decode.rs +++ b/src/proto/h1/decode.rs @@ -135,7 +135,12 @@ impl Decoder { Length(0) | Chunked { state: ChunkedState::End, - .. + chunk_len: _, + extensions_cnt: _, + trailers_buf: _, + trailers_cnt: _, + h1_max_headers: _, + h1_max_header_size: _, } | Eof(true) ) diff --git a/src/proto/h1/io.rs b/src/proto/h1/io.rs index bcd0204d2f..92892a4b34 100644 --- a/src/proto/h1/io.rs +++ b/src/proto/h1/io.rs @@ -389,6 +389,7 @@ impl ReadStrategy { } } + #[allow(clippy::rest_pattern_accessible_field/*reason: this is an accessor*/)] fn next(&self) -> usize { match *self { ReadStrategy::Adaptive { next, .. } => next, @@ -397,6 +398,7 @@ impl ReadStrategy { } } + #[allow(clippy::rest_pattern_accessible_field/*reason: this is an accessor*/)] fn max(&self) -> usize { match *self { ReadStrategy::Adaptive { max, .. } => max, diff --git a/src/proto/h2/server.rs b/src/proto/h2/server.rs index 2098758d9e..6f05a32e4f 100644 --- a/src/proto/h2/server.rs +++ b/src/proto/h2/server.rs @@ -185,7 +185,10 @@ where pub(crate) fn graceful_shutdown(&mut self) { trace!("graceful_shutdown"); match &mut self.state { - State::Handshaking { .. } => { + State::Handshaking { + ping_config: _, + hs: _, + } => { self.close_pending = true; } State::Serving(srv) => {