Skip to content

Commit 2ded953

Browse files
committed
Fix remaining clippy warnings
1 parent 251664e commit 2ded953

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

src/frame/headers.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,20 @@ impl fmt::Debug for Headers {
309309

310310
// ===== util =====
311311

312-
pub fn parse_u64(src: &[u8]) -> Result<u64, ()> {
312+
#[derive(Debug)]
313+
pub struct ParseU64Error;
314+
315+
pub fn parse_u64(src: &[u8]) -> Result<u64, ParseU64Error> {
313316
if src.len() > 19 {
314317
// At danger for overflow...
315-
return Err(());
318+
return Err(ParseU64Error);
316319
}
317320

318321
let mut ret = 0;
319322

320323
for &d in src {
321324
if !(b'0'..=b'9').contains(&d) {
322-
return Err(());
325+
return Err(ParseU64Error);
323326
}
324327

325328
ret *= 10;
@@ -333,7 +336,7 @@ pub fn parse_u64(src: &[u8]) -> Result<u64, ()> {
333336

334337
#[derive(Debug)]
335338
pub enum PushPromiseHeaderError {
336-
InvalidContentLength(Result<u64, ()>),
339+
InvalidContentLength(Result<u64, ParseU64Error>),
337340
NotSafeAndCacheable,
338341
}
339342

@@ -364,9 +367,9 @@ impl PushPromise {
364367
// A promised request "that indicates the presence of a request body
365368
// MUST reset the promised stream with a stream error"
366369
if let Some(content_length) = req.headers().get(header::CONTENT_LENGTH) {
367-
let parsed_length = parse_u64(content_length.as_bytes());
368-
if parsed_length != Ok(0) {
369-
return Err(InvalidContentLength(parsed_length));
370+
match parse_u64(content_length.as_bytes()) {
371+
Ok(0) => (),
372+
parsed => return Err(InvalidContentLength(parsed)),
370373
}
371374
}
372375
// "The server MUST include a method in the :method pseudo-header field

src/proto/streams/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod send;
77
mod state;
88
mod store;
99
mod stream;
10+
#[allow(clippy::module_inception)]
1011
mod streams;
1112

1213
pub(crate) use self::prioritize::Prioritized;

src/proto/streams/recv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl Recv {
178178
if let Some(content_length) = frame.fields().get(header::CONTENT_LENGTH) {
179179
let content_length = match frame::parse_u64(content_length.as_bytes()) {
180180
Ok(v) => v,
181-
Err(()) => {
181+
Err(_) => {
182182
proto_err!(stream: "could not parse content-length; stream={:?}", stream.id);
183183
return Err(Error::library_reset(stream.id, Reason::PROTOCOL_ERROR).into());
184184
}
@@ -263,6 +263,7 @@ impl Recv {
263263
}
264264

265265
/// Called by the client to get pushed response
266+
#[allow(clippy::type_complexity)]
266267
pub fn poll_pushed(
267268
&mut self,
268269
cx: &Context,

src/proto/streams/streams.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,7 @@ impl OpaqueStreamRef {
12671267
me.actions.recv.poll_response(cx, &mut stream)
12681268
}
12691269
/// Called by a client to check for a pushed request.
1270+
#[allow(clippy::type_complexity)]
12701271
pub fn poll_pushed(
12711272
&mut self,
12721273
cx: &Context,

src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ where
407407
}
408408

409409
#[doc(hidden)]
410+
#[allow(clippy::type_complexity)]
410411
pub fn poll_accept(
411412
&mut self,
412413
cx: &mut Context<'_>,

0 commit comments

Comments
 (0)