Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings for Rust 1.59 #108

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

ameliabradley
Copy link
Contributor

For reference, this was the clippy output:

warning: redundant field names in struct initialization
  --> src/iter.rs:12:13
   |
12 |             slice: slice,
   |             ^^^^^^^^^^^^ help: replace it with: `slice`
   |
   = note: `#[warn(clippy::redundant_field_names)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

warning: unnecessary `>= y + 1` or `x - 1 >=`
  --> src/iter.rs:29:23
   |
29 |         debug_assert!(self.pos + 1 <= self.slice.len(), "overflow");
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change it to: `self.pos < self.slice.len()`
   |
   = note: `#[warn(clippy::int_plus_one)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#int_plus_one

warning: redundant field names in struct initialization
   --> src/iter.rs:140:13
    |
140 |             bytes: bytes,
    |             ^^^^^^^^^^^^ help: replace it with: `bytes`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

warning: digits of hex or binary literal not grouped by four
  --> src/simd/avx2.rs:62:13
   |
62 |     let r = 0xffffffff_00000000 | _mm256_movemask_epi8(v) as u64;
   |             ^^^^^^^^^^^^^^^^^^^ help: consider: `0xffff_ffff_0000_0000`
   |
   = note: `#[warn(clippy::unusual_byte_groupings)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings

warning: digits of hex or binary literal not grouped by four
   --> src/simd/avx2.rs:112:15
    |
112 |     let res = 0xffffffff_00000000 | _mm256_movemask_epi8(rev) as u64;
    |               ^^^^^^^^^^^^^^^^^^^ help: consider: `0xffff_ffff_0000_0000`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings

warning: redundant field names in struct initialization
   --> src/lib.rs:361:13
    |
361 |             headers: headers,
    |             ^^^^^^^^^^^^^^^^ help: replace it with: `headers`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

warning: redundant field names in struct initialization
   --> src/lib.rs:464:13
    |
464 |             headers: headers,
    |             ^^^^^^^^^^^^^^^^ help: replace it with: `headers`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

warning: use of `offset` with a `usize` casted to an `isize`
  --> src/iter.rs:59:42
   |
59 |         let tail = slice::from_raw_parts(ptr.offset(self.pos as isize), self.slice.len() - self.pos);
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(self.pos)`
   |
   = note: `#[warn(clippy::ptr_offset_with_cast)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast

warning: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
 --> src/simd/sse42.rs:3:1
  |
3 | pub unsafe fn parse_uri_batch_16<'a>(bytes: &mut Bytes<'a>) {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(clippy::needless_lifetimes)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

warning: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
  --> src/simd/avx2.rs:11:1
   |
11 | pub unsafe fn parse_uri_batch_32<'a>(bytes: &mut Bytes<'a>) -> Scan {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
   --> src/lib.rs:398:23
    |
398 |         let headers = mem::replace(&mut self.headers, &mut []);
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut self.headers)`
    |
    = note: `#[warn(clippy::mem_replace_with_default)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
   --> src/lib.rs:474:23
    |
474 |         let headers = mem::replace(&mut self.headers, &mut []);
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut self.headers)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: manual `RangeInclusive::contains` implementation
   --> src/lib.rs:653:47
    |
653 |         } else if !(b == 0x09 || b == b' ' || (b >= 0x21 && b <= 0x7E) || b >= 0x80) {
    |                                               ^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `(0x21..=0x7E).contains(&b)`
    |
    = note: `#[warn(clippy::manual_range_contains)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains

warning: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
   --> src/lib.rs:751:1
    |
751 | unsafe fn assume_init_slice<'a, T>(s: &'a mut [MaybeUninit<T>]) -> &'a mut [T] {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
   --> src/lib.rs:783:27
    |
783 |             let headers = mem::replace(self.headers, &mut []);
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(self.headers)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: `httparse` (lib) generated 15 warnings

@seanmonstar
Copy link
Owner

Hey, thanks for making these fixes! It looks like some of the things clippy suggests to do can't be done without requiring a newer rustc version. Hence, the Minimum Supported Rust Version (MSRV) test fails.

@ameliabradley
Copy link
Contributor Author

ameliabradley commented Feb 28, 2022

@seanmonstar Ah, I didn't see the minimum supported Rust version. That makes sense. Updated the changes to tell clippy to ignore those lines. Let me know if you'd like this addressed in some other manner.

@seanmonstar
Copy link
Owner

This is just my personal preference, but I prefer that code doesn't include attributes mentioning clippy. The rest of the cleanups look great, though!

@ameliabradley
Copy link
Contributor Author

@seanmonstar Cool! I've removed the clippy attributes.

Copy link
Owner

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much :D

@seanmonstar seanmonstar merged commit 8dbca74 into seanmonstar:master Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants