Skip to content

Commit 2cf35b2

Browse files
committed
Update MSRV from 1.36 to 1.47 also in clippy.toml. Fix related clippy issues.
1 parent 390a6d3 commit 2cf35b2

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.36"
1+
msrv = "1.47"

src/iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'a> Bytes<'a> {
155155
}
156156
}
157157

158-
impl<'a> AsRef<[u8]> for Bytes<'a> {
158+
impl AsRef<[u8]> for Bytes<'_> {
159159
#[inline]
160160
fn as_ref(&self) -> &[u8] {
161161
// SAFETY: not moving position at all, so it's safe
@@ -172,7 +172,7 @@ unsafe fn slice_from_ptr_range<'a>(start: *const u8, end: *const u8) -> &'a [u8]
172172
core::slice::from_raw_parts(start, end as usize - start as usize)
173173
}
174174

175-
impl<'a> Iterator for Bytes<'a> {
175+
impl Iterator for Bytes<'_> {
176176
type Item = u8;
177177

178178
#[inline]

src/lib.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! `-C target_cpu=native` allows the detection to become compile time checks,
2626
//! making it *even* faster.
2727
28-
use core::{fmt, result, str};
28+
use core::{fmt, mem, result, str};
2929
use core::mem::MaybeUninit;
3030

3131
use crate::iter::Bytes;
@@ -375,7 +375,7 @@ impl ParserConfig {
375375
/// let result = httparse::ParserConfig::default()
376376
/// .allow_space_before_first_header_name(true)
377377
/// .parse_response(&mut response, buf);
378-
378+
///
379379
/// assert_eq!(result, Ok(httparse::Status::Complete(buf.len())));
380380
/// assert_eq!(response.version.unwrap(), 1);
381381
/// assert_eq!(response.code.unwrap(), 200);
@@ -580,7 +580,7 @@ impl<'h, 'b> Request<'h, 'b> {
580580
}
581581

582582
fn parse_with_config(&mut self, buf: &'b [u8], config: &ParserConfig) -> Result<usize> {
583-
let headers = core::mem::replace(&mut self.headers, &mut []);
583+
let headers = mem::take(&mut self.headers);
584584

585585
/* SAFETY: see `parse_headers_iter_uninit` guarantees */
586586
unsafe {
@@ -683,7 +683,7 @@ impl<'h, 'b> Response<'h, 'b> {
683683
}
684684

685685
fn parse_with_config(&mut self, buf: &'b [u8], config: &ParserConfig) -> Result<usize> {
686-
let headers = core::mem::replace(&mut self.headers, &mut []);
686+
let headers = mem::take(&mut self.headers);
687687

688688
// SAFETY: see guarantees of [`parse_headers_iter_uninit`], which leaves no uninitialized
689689
// headers around. On failure, the original headers are restored.
@@ -779,7 +779,7 @@ pub struct Header<'a> {
779779
pub value: &'a [u8],
780780
}
781781

782-
impl<'a> fmt::Debug for Header<'a> {
782+
impl fmt::Debug for Header<'_> {
783783
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
784784
let mut f = f.debug_struct("Header");
785785
f.field("name", &self.name);
@@ -967,10 +967,10 @@ pub fn parse_uri<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
967967
return Err(Error::Token);
968968
}
969969

970-
return Ok(Status::Complete(
970+
Ok(Status::Complete(
971971
// SAFETY: all bytes up till `i` must have been `is_method_token` and therefore also utf-8.
972972
unsafe { str::from_utf8_unchecked(bytes.slice_skip(1)) },
973-
));
973+
))
974974
} else {
975975
Err(Error::Token)
976976
}
@@ -1071,9 +1071,9 @@ fn parse_headers_iter_uninit<'a>(
10711071
num_headers: usize,
10721072
}
10731073

1074-
impl<'r1, 'r2, 'a> Drop for ShrinkOnDrop<'r1, 'r2, 'a> {
1074+
impl Drop for ShrinkOnDrop<'_, '_, '_> {
10751075
fn drop(&mut self) {
1076-
let headers = core::mem::replace(self.headers, &mut []);
1076+
let headers = mem::take(self.headers);
10771077

10781078
/* SAFETY: num_headers is the number of initialized headers */
10791079
let headers = unsafe { headers.get_unchecked_mut(..self.num_headers) };
@@ -1323,7 +1323,7 @@ pub fn parse_chunk_size(buf: &[u8])
13231323
return Err(InvalidChunkSize);
13241324
}
13251325
count += 1;
1326-
if cfg!(debug_assertions) && size > (core::u64::MAX / RADIX) {
1326+
if cfg!(debug_assertions) && size > (u64::MAX / RADIX) {
13271327
// actually unreachable!(), because count stops the loop at 15 digits before
13281328
// we can reach u64::MAX / RADIX == 0xfffffffffffffff, which requires 15 hex
13291329
// digits. This stops mirai reporting a false alarm regarding the `size *=
@@ -1338,7 +1338,7 @@ pub fn parse_chunk_size(buf: &[u8])
13381338
return Err(InvalidChunkSize);
13391339
}
13401340
count += 1;
1341-
if cfg!(debug_assertions) && size > (core::u64::MAX / RADIX) {
1341+
if cfg!(debug_assertions) && size > (u64::MAX / RADIX) {
13421342
return Err(InvalidChunkSize);
13431343
}
13441344
size *= RADIX;
@@ -1349,7 +1349,7 @@ pub fn parse_chunk_size(buf: &[u8])
13491349
return Err(InvalidChunkSize);
13501350
}
13511351
count += 1;
1352-
if cfg!(debug_assertions) && size > (core::u64::MAX / RADIX) {
1352+
if cfg!(debug_assertions) && size > (u64::MAX / RADIX) {
13531353
return Err(InvalidChunkSize);
13541354
}
13551355
size *= RADIX;
@@ -2057,7 +2057,7 @@ mod tests {
20572057
assert_eq!(parse_chunk_size(b"567f8a\rfoo"), Err(crate::InvalidChunkSize));
20582058
assert_eq!(parse_chunk_size(b"567f8a\rfoo"), Err(crate::InvalidChunkSize));
20592059
assert_eq!(parse_chunk_size(b"567xf8a\r\n"), Err(crate::InvalidChunkSize));
2060-
assert_eq!(parse_chunk_size(b"ffffffffffffffff\r\n"), Ok(Status::Complete((18, std::u64::MAX))));
2060+
assert_eq!(parse_chunk_size(b"ffffffffffffffff\r\n"), Ok(Status::Complete((18, u64::MAX))));
20612061
assert_eq!(parse_chunk_size(b"1ffffffffffffffff\r\n"), Err(crate::InvalidChunkSize));
20622062
assert_eq!(parse_chunk_size(b"Affffffffffffffff\r\n"), Err(crate::InvalidChunkSize));
20632063
assert_eq!(parse_chunk_size(b"fffffffffffffffff\r\n"), Err(crate::InvalidChunkSize));

0 commit comments

Comments
 (0)