diff --git a/src/frame/headers.rs b/src/frame/headers.rs index 8d9a579f..8a72f523 100644 --- a/src/frame/headers.rs +++ b/src/frame/headers.rs @@ -309,17 +309,20 @@ impl fmt::Debug for Headers { // ===== util ===== -pub fn parse_u64(src: &[u8]) -> Result { +#[derive(Debug)] +pub struct ParseU64Error; + +pub fn parse_u64(src: &[u8]) -> Result { if src.len() > 19 { // At danger for overflow... - return Err(()); + return Err(ParseU64Error); } let mut ret = 0; for &d in src { if !(b'0'..=b'9').contains(&d) { - return Err(()); + return Err(ParseU64Error); } ret *= 10; @@ -333,7 +336,7 @@ pub fn parse_u64(src: &[u8]) -> Result { #[derive(Debug)] pub enum PushPromiseHeaderError { - InvalidContentLength(Result), + InvalidContentLength(Result), NotSafeAndCacheable, } @@ -364,9 +367,9 @@ impl PushPromise { // A promised request "that indicates the presence of a request body // MUST reset the promised stream with a stream error" if let Some(content_length) = req.headers().get(header::CONTENT_LENGTH) { - let parsed_length = parse_u64(content_length.as_bytes()); - if parsed_length != Ok(0) { - return Err(InvalidContentLength(parsed_length)); + match parse_u64(content_length.as_bytes()) { + Ok(0) => (), + parsed => return Err(InvalidContentLength(parsed)), } } // "The server MUST include a method in the :method pseudo-header field diff --git a/src/proto/streams/mod.rs b/src/proto/streams/mod.rs index de2a2c85..0ff8131c 100644 --- a/src/proto/streams/mod.rs +++ b/src/proto/streams/mod.rs @@ -7,6 +7,7 @@ mod send; mod state; mod store; mod stream; +#[allow(clippy::module_inception)] mod streams; pub(crate) use self::prioritize::Prioritized; diff --git a/src/proto/streams/recv.rs b/src/proto/streams/recv.rs index c8c8c031..77474b81 100644 --- a/src/proto/streams/recv.rs +++ b/src/proto/streams/recv.rs @@ -178,7 +178,7 @@ impl Recv { if let Some(content_length) = frame.fields().get(header::CONTENT_LENGTH) { let content_length = match frame::parse_u64(content_length.as_bytes()) { Ok(v) => v, - Err(()) => { + Err(_) => { proto_err!(stream: "could not parse content-length; stream={:?}", stream.id); return Err(Error::library_reset(stream.id, Reason::PROTOCOL_ERROR).into()); } @@ -263,6 +263,7 @@ impl Recv { } /// Called by the client to get pushed response + #[allow(clippy::type_complexity)] pub fn poll_pushed( &mut self, cx: &Context, diff --git a/src/proto/streams/streams.rs b/src/proto/streams/streams.rs index 6ae440a8..9eae05cd 100644 --- a/src/proto/streams/streams.rs +++ b/src/proto/streams/streams.rs @@ -1267,6 +1267,7 @@ impl OpaqueStreamRef { me.actions.recv.poll_response(cx, &mut stream) } /// Called by a client to check for a pushed request. + #[allow(clippy::type_complexity)] pub fn poll_pushed( &mut self, cx: &Context, diff --git a/src/server.rs b/src/server.rs index e4098e08..f1e75812 100644 --- a/src/server.rs +++ b/src/server.rs @@ -407,6 +407,7 @@ where } #[doc(hidden)] + #[allow(clippy::type_complexity)] pub fn poll_accept( &mut self, cx: &mut Context<'_>,