Skip to content

Commit 0127e5b

Browse files
authored
Merge pull request #388 from halvko/f-fix-warnings
Fix clippy warnings
2 parents bcf1103 + bd1d4a6 commit 0127e5b

File tree

12 files changed

+26
-22
lines changed

12 files changed

+26
-22
lines changed

src/auth/authentication_scheme.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl FromStr for AuthenticationScheme {
5353
// NOTE(yosh): matching here is lowercase as specified by RFC2617#section-1.2
5454
// > [...] case-insensitive token to identify the authentication scheme [...]
5555
// https://tools.ietf.org/html/rfc2617#section-1.2
56+
#[allow(clippy::match_str_case_mismatch)]
5657
match s.to_lowercase().as_str() {
5758
"basic" => Ok(Self::Basic),
5859
"bearer" => Ok(Self::Bearer),

src/body.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,13 @@ impl<'a> From<&'a [u8]> for Body {
565565
}
566566

567567
impl AsyncRead for Body {
568-
#[allow(missing_doc_code_examples)]
568+
#[allow(rustdoc::missing_doc_code_examples)]
569569
fn poll_read(
570570
mut self: Pin<&mut Self>,
571571
cx: &mut Context<'_>,
572572
buf: &mut [u8],
573573
) -> Poll<io::Result<usize>> {
574-
let mut buf = match self.length {
574+
let buf = match self.length {
575575
None => buf,
576576
Some(length) if length == self.bytes_read => return Poll::Ready(Ok(0)),
577577
Some(length) => {
@@ -582,14 +582,14 @@ impl AsyncRead for Body {
582582
}
583583
};
584584

585-
let bytes = ready!(Pin::new(&mut self.reader).poll_read(cx, &mut buf))?;
585+
let bytes = ready!(Pin::new(&mut self.reader).poll_read(cx, buf))?;
586586
self.bytes_read += bytes as u64;
587587
Poll::Ready(Ok(bytes))
588588
}
589589
}
590590

591591
impl AsyncBufRead for Body {
592-
#[allow(missing_doc_code_examples)]
592+
#[allow(rustdoc::missing_doc_code_examples)]
593593
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&'_ [u8]>> {
594594
self.project().reader.poll_fill_buf(cx)
595595
}
@@ -632,6 +632,7 @@ mod test {
632632
#[derive(Debug, Deserialize)]
633633
#[serde(crate = "serde_crate")]
634634
struct Foo {
635+
#[allow(dead_code)]
635636
inner: String,
636637
}
637638
let body = Body::empty();
@@ -644,6 +645,7 @@ mod test {
644645
#[derive(Debug, Deserialize)]
645646
#[serde(crate = "serde_crate")]
646647
struct Foo {
648+
#[allow(dead_code)]
647649
inner: String,
648650
}
649651
let body = Body::empty();

src/cache/cache_control/cache_directive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl CacheDirective {
8888
return Ok(None);
8989
}
9090

91-
s.to_lowercase();
91+
let s = s.to_lowercase();
9292
let mut parts = s.split('=');
9393
let next = parts.next().unwrap();
9494

src/cache/clear_site_data/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ impl Header for ClearSiteData {
220220
let mut output = String::new();
221221
for (n, etag) in self.entries.iter().enumerate() {
222222
match n {
223-
0 => write!(output, "{}", etag.to_string()).unwrap(),
224-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
223+
0 => write!(output, "{}", etag).unwrap(),
224+
_ => write!(output, ", {}", etag).unwrap(),
225225
};
226226
}
227227

src/conditional/if_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ impl Header for IfMatch {
111111
let mut output = String::new();
112112
for (n, etag) in self.entries.iter().enumerate() {
113113
match n {
114-
0 => write!(output, "{}", etag.to_string()).unwrap(),
115-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
114+
0 => write!(output, "{}", etag).unwrap(),
115+
_ => write!(output, ", {}", etag).unwrap(),
116116
};
117117
}
118118

src/conditional/if_none_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ impl Header for IfNoneMatch {
117117
let mut output = String::new();
118118
for (n, etag) in self.entries.iter().enumerate() {
119119
match n {
120-
0 => write!(output, "{}", etag.to_string()).unwrap(),
121-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
120+
0 => write!(output, "{}", etag).unwrap(),
121+
_ => write!(output, ", {}", etag).unwrap(),
122122
};
123123
}
124124

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl Error {
159159

160160
/// Retrieves a reference to the type name of the error, if available.
161161
pub fn type_name(&self) -> Option<&str> {
162-
self.type_name.as_deref()
162+
self.type_name
163163
}
164164

165165
/// Converts anything which implements `Display` into an `http_types::Error`.

src/hyperium_http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl TryFrom<HeaderName> for http::header::HeaderName {
6868

6969
fn try_from(name: HeaderName) -> Result<Self, Self::Error> {
7070
let name = name.as_str().as_bytes();
71-
http::header::HeaderName::from_bytes(name).map_err(|e| Error::new_adhoc(e))
71+
http::header::HeaderName::from_bytes(name).map_err(Error::new_adhoc)
7272
}
7373
}
7474

@@ -86,7 +86,7 @@ impl TryFrom<HeaderValue> for http::header::HeaderValue {
8686

8787
fn try_from(value: HeaderValue) -> Result<Self, Self::Error> {
8888
let value = value.as_str().as_bytes();
89-
http::header::HeaderValue::from_bytes(value).map_err(|e| Error::new_adhoc(e))
89+
http::header::HeaderValue::from_bytes(value).map_err(Error::new_adhoc)
9090
}
9191
}
9292

src/method.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ impl FromStr for Method {
413413
type Err = crate::Error;
414414

415415
fn from_str(s: &str) -> Result<Self, Self::Err> {
416+
#[allow(clippy::match_str_case_mismatch)]
416417
match &*s.to_ascii_uppercase() {
417418
"ACL" => Ok(Self::Acl),
418419
"BASELINE-CONTROL" => Ok(Self::BaselineControl),

src/request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ impl Clone for Request {
899899
}
900900

901901
impl AsyncRead for Request {
902-
#[allow(missing_doc_code_examples)]
902+
#[allow(rustdoc::missing_doc_code_examples)]
903903
fn poll_read(
904904
mut self: Pin<&mut Self>,
905905
cx: &mut Context<'_>,
@@ -910,7 +910,7 @@ impl AsyncRead for Request {
910910
}
911911

912912
impl AsyncBufRead for Request {
913-
#[allow(missing_doc_code_examples)]
913+
#[allow(rustdoc::missing_doc_code_examples)]
914914
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&'_ [u8]>> {
915915
let this = self.project();
916916
this.body.poll_fill_buf(cx)

src/response.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl Clone for Response {
599599
}
600600

601601
impl AsyncRead for Response {
602-
#[allow(missing_doc_code_examples)]
602+
#[allow(rustdoc::missing_doc_code_examples)]
603603
fn poll_read(
604604
mut self: Pin<&mut Self>,
605605
cx: &mut Context<'_>,
@@ -610,7 +610,7 @@ impl AsyncRead for Response {
610610
}
611611

612612
impl AsyncBufRead for Response {
613-
#[allow(missing_doc_code_examples)]
613+
#[allow(rustdoc::missing_doc_code_examples)]
614614
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&'_ [u8]>> {
615615
let this = self.project();
616616
this.body.poll_fill_buf(cx)

src/utils/date.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ impl From<SystemTime> for HttpDate {
218218
.expect("all times should be after the epoch");
219219
let secs_since_epoch = dur.as_secs();
220220

221-
if secs_since_epoch >= YEAR_9999_SECONDS {
222-
// year 9999
223-
panic!("date must be before year 9999");
224-
}
221+
assert!(
222+
secs_since_epoch < YEAR_9999_SECONDS,
223+
"date must be before year 9999"
224+
);
225225

226226
/* 2000-03-01 (mod 400 year, immediately after feb29 */
227227
const LEAPOCH: i64 = 11017;

0 commit comments

Comments
 (0)