flate2-rs icon indicating copy to clipboard operation
flate2-rs copied to clipboard

Make clippy happy + a few more cleanups

Open nyurik opened this issue 3 years ago • 0 comments
trafficstars

Following up from #283

  • Address all remaining clippy issues
  • Switch assert!(a==b) to assert_eq!(a, b)
  • MAX instead of max_value()
expand original clippy messages

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 avatar Dec 13 '21 19:12 nyurik