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

Make clippy happy + a few more cleanups #285

Merged
merged 5 commits into from
Dec 23, 2022
Merged

Commits on Dec 13, 2021

  1. Make clippy happy + a few more cleanups

    Following up from rust-lang#283
    * Address all remaining clippy issues
    * Switch `assert!(a==b)` to `assert_eq!(a, b)`
    * `MAX` instead of `max_value()`
    
    > warning: this seems like a manual implementation of the non-exhaustive pattern
    >    --> src/mem.rs:46:1
    >     |
    >  46 |   pub enum FlushCompress {
    >     |   ^---------------------
    >     |   |
    >     |  _help: add the attribute: `#[non_exhaustive] pub enum FlushCompress`
    >     | |
    >  47 | |     /// A typical parameter for passing to compression/decompression functions,
    >  48 | |     /// this indicates that the underlying stream to decide how much data to
    >  49 | |     /// accumulate before producing output in order to maximize compression.
    >  ...  |
    >  85 | |     _Nonexhaustive,
    >  86 | | }
    >     | |_^
    >     |
    >     = note: `#[warn(clippy::manual_non_exhaustive)]` on by default
    >  help: remove this variant
    >    --> src/mem.rs:85:5
    >     |
    >  85 |     _Nonexhaustive,
    >     |     ^^^^^^^^^^^^^^
    >     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
    >
    >  warning: this seems like a manual implementation of the non-exhaustive pattern
    >     --> src/mem.rs:91:1
    >      |
    >  91  |   pub enum FlushDecompress {
    >      |   ^-----------------------
    >      |   |
    >      |  _help: add the attribute: `#[non_exhaustive] pub enum FlushDecompress`
    >      | |
    >  92  | |     /// A typical parameter for passing to compression/decompression functions,
    >  93  | |     /// this indicates that the underlying stream to decide how much data to
    >  94  | |     /// accumulate before producing output in order to maximize compression.
    >  ...   |
    >  113 | |     _Nonexhaustive,
    >  114 | | }
    >      | |_^
    >      |
    >  help: remove this variant
    >     --> src/mem.rs:113:5
    >      |
    >  113 |     _Nonexhaustive,
    >      |     ^^^^^^^^^^^^^^
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
    >
    >  warning: the operation is ineffective. Consider reducing it to `(header[4] as u32)`
    >    --> src/gz/bufread.rs:58:39
    >     |
    >  58 |                 r.part.header.mtime = ((header[4] as u32) << 0)
    >     |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^
    >     |
    >     = note: `#[warn(clippy::identity_op)]` on by default
    >     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
    >     --> src/gz/bufread.rs:197:13
    >      |
    >  197 |         let ref arr = [
    >      |             ^^^^^^^
    >      |
    >      = note: `#[warn(clippy::toplevel_ref_arg)]` on by default
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg
    >  help: try
    >      |
    >  197 ~         let arr = &[
    >  198 +             (crc.sum() >> 0) as u8,
    >  199 +             (crc.sum() >> 8) as u8,
    >  200 +             (crc.sum() >> 16) as u8,
    >  201 +             (crc.sum() >> 24) as u8,
    >  202 +             (crc.amount() >> 0) as u8,
    >    ...
    >
    >  warning: the operation is ineffective. Consider reducing it to `crc.sum()`
    >     --> src/gz/bufread.rs:198:13
    >      |
    >  198 |             (crc.sum() >> 0) as u8,
    >      |             ^^^^^^^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: the operation is ineffective. Consider reducing it to `crc.amount()`
    >     --> src/gz/bufread.rs:202:13
    >      |
    >  202 |             (crc.amount() >> 0) as u8,
    >      |             ^^^^^^^^^^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: the operation is ineffective. Consider reducing it to `(buf[0] as u32)`
    >     --> src/gz/bufread.rs:233:15
    >      |
    >  233 |     let crc = ((buf[0] as u32) << 0)
    >      |               ^^^^^^^^^^^^^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: the operation is ineffective. Consider reducing it to `(buf[4] as u32)`
    >     --> src/gz/bufread.rs:237:15
    >      |
    >  237 |     let amt = ((buf[4] as u32) << 0)
    >      |               ^^^^^^^^^^^^^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: the operation is ineffective. Consider reducing it to `sum`
    >     --> src/gz/write.rs:102:17
    >      |
    >  102 |                 (sum >> 0) as u8,
    >      |                 ^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: the operation is ineffective. Consider reducing it to `amt`
    >     --> src/gz/write.rs:106:17
    >      |
    >  106 |                 (amt >> 0) as u8,
    >      |                 ^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: the operation is ineffective. Consider reducing it to `(self.crc_bytes[0] as u32)`
    >     --> src/gz/write.rs:307:19
    >      |
    >  307 |         let crc = ((self.crc_bytes[0] as u32) << 0)
    >      |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: the operation is ineffective. Consider reducing it to `(self.crc_bytes[4] as u32)`
    >     --> src/gz/write.rs:311:19
    >      |
    >  311 |         let amt = ((self.crc_bytes[4] as u32) << 0)
    >      |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: the operation is ineffective. Consider reducing it to `v.len()`
    >     --> src/gz/mod.rs:215:25
    >      |
    >  215 |             header.push((v.len() >> 0) as u8);
    >      |                         ^^^^^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: you are using an explicit closure for copying elements
    >     --> src/gz/mod.rs:221:27
    >      |
    >  221 |             header.extend(filename.as_bytes_with_nul().iter().map(|x| *x));
    >      |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `filename.as_bytes_with_nul().iter().copied()`
    >      |
    >      = note: `#[warn(clippy::map_clone)]` on by default
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
    >
    >  warning: you are using an explicit closure for copying elements
    >     --> src/gz/mod.rs:225:27
    >      |
    >  225 |             header.extend(comment.as_bytes_with_nul().iter().map(|x| *x));
    >      |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `comment.as_bytes_with_nul().iter().copied()`
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
    >
    >  warning: the operation is ineffective. Consider reducing it to `mtime`
    >     --> src/gz/mod.rs:231:21
    >      |
    >  231 |         header[4] = (mtime >> 0) as u8;
    >      |                     ^^^^^^^^^^^^
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
    >
    >  warning: use of `offset` with a `usize` casted to an `isize`
    >     --> src/mem.rs:365:27
    >      |
    >  365 |                 let ptr = output.as_mut_ptr().offset(len as isize);
    >      |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `output.as_mut_ptr().add(len)`
    >      |
    >      = 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: use of `offset` with a `usize` casted to an `isize`
    >     --> src/mem.rs:506:27
    >      |
    >  506 |                 let ptr = output.as_mut_ptr().offset(len as isize);
    >      |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `output.as_mut_ptr().add(len)`
    >      |
    >      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
    >
    >  warning: `flate2` (lib) generated 18 warnings
    >      Finished dev [unoptimized + debuginfo] target(s) in 0.02s
    nyurik committed Dec 13, 2021
    Configuration menu
    Copy the full SHA
    ea89049 View commit details
    Browse the repository at this point in the history

Commits on Dec 14, 2021

  1. Configuration menu
    Copy the full SHA
    f361ad7 View commit details
    Browse the repository at this point in the history

Commits on Dec 22, 2022

  1. Configuration menu
    Copy the full SHA
    4a08387 View commit details
    Browse the repository at this point in the history
  2. Address PR review feedback

    nyurik committed Dec 22, 2022
    Configuration menu
    Copy the full SHA
    2665fab View commit details
    Browse the repository at this point in the history
  3. A few more minor lints

    nyurik committed Dec 22, 2022
    Configuration menu
    Copy the full SHA
    183d413 View commit details
    Browse the repository at this point in the history