Skip to content

Commit c2c78de

Browse files
authored
solve remaining clippy warnings and add it to CI (#487)
1 parent 306e909 commit c2c78de

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

.github/workflows/main.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ jobs:
5353
fi
5454
if: matrix.build == 'stable'
5555
56-
rustfmt:
57-
name: Rustfmt & Docs
56+
rustfmt_docs_clippy:
57+
name: Rustfmt, Docs and Clippy
5858
runs-on: ubuntu-latest
5959
steps:
6060
- uses: actions/checkout@v4
6161
- name: Install Rust
62-
run: rustup update stable && rustup default stable && rustup component add rustfmt
62+
run: rustup update stable && rustup default stable && rustup component add rustfmt && rustup component add clippy
6363
- run: cargo fmt -- --check
6464
- run: cargo doc --all-features
65+
- run: cargo clippy --all-features -- -D warnings
6566

6667
wasm:
6768
name: WebAssembly

src/ffi/c.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ impl InflateBackend for Inflate {
287287
MZ_OK => Ok(Status::Ok),
288288
MZ_BUF_ERROR => Ok(Status::BufError),
289289
MZ_STREAM_END => Ok(Status::StreamEnd),
290+
#[allow(clippy::unnecessary_cast)]
290291
MZ_NEED_DICT => mem::decompress_need_dict((*raw).adler as u32),
291292
c => panic!("unknown return code: {}", c),
292293
}
@@ -465,11 +466,11 @@ mod c_backend {
465466
pub const MZ_DEFAULT_WINDOW_BITS: c_int = 15;
466467

467468
#[cfg(feature = "zlib-ng")]
468-
const ZLIB_VERSION: &'static str = "2.1.0.devel\0";
469+
const ZLIB_VERSION: &str = "2.1.0.devel\0";
469470
#[cfg(all(not(feature = "zlib-ng"), feature = "zlib-rs"))]
470-
const ZLIB_VERSION: &'static str = "1.3.0-zlib-rs-0.5.0\0";
471+
const ZLIB_VERSION: &str = "1.3.0-zlib-rs-0.5.0\0";
471472
#[cfg(not(any(feature = "zlib-ng", feature = "zlib-rs")))]
472-
const ZLIB_VERSION: &'static str = "1.2.8\0";
473+
const ZLIB_VERSION: &str = "1.2.8\0";
473474

474475
pub unsafe extern "C" fn mz_deflateInit2(
475476
stream: *mut mz_stream,

src/gz/bufread.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<R: BufRead> GzEncoder<R> {
8686
calced_crc_bytes[1],
8787
calced_crc_bytes[2],
8888
calced_crc_bytes[3],
89-
(crc.amount() >> 0) as u8,
89+
crc.amount() as u8,
9090
(crc.amount() >> 8) as u8,
9191
(crc.amount() >> 16) as u8,
9292
(crc.amount() >> 24) as u8,
@@ -117,11 +117,11 @@ impl<R> GzEncoder<R> {
117117

118118
#[inline]
119119
fn finish(buf: &[u8; 8]) -> (u32, u32) {
120-
let crc = ((buf[0] as u32) << 0)
120+
let crc = (buf[0] as u32)
121121
| ((buf[1] as u32) << 8)
122122
| ((buf[2] as u32) << 16)
123123
| ((buf[3] as u32) << 24);
124-
let amt = ((buf[4] as u32) << 0)
124+
let amt = (buf[4] as u32)
125125
| ((buf[5] as u32) << 8)
126126
| ((buf[6] as u32) << 16)
127127
| ((buf[7] as u32) << 24);

src/gz/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl GzHeaderParser {
135135
if self.flags & FRESERVED != 0 {
136136
return Err(bad_header());
137137
}
138-
self.header.mtime = ((buffer[4] as u32) << 0)
138+
self.header.mtime = (buffer[4] as u32)
139139
| ((buffer[5] as u32) << 8)
140140
| ((buffer[6] as u32) << 16)
141141
| ((buffer[7] as u32) << 24);
@@ -417,7 +417,7 @@ impl GzBuilder {
417417
header[1] = 0x8b;
418418
header[2] = 8;
419419
header[3] = flg;
420-
header[4] = (mtime >> 0) as u8;
420+
header[4] = mtime as u8;
421421
header[5] = (mtime >> 8) as u8;
422422
header[6] = (mtime >> 16) as u8;
423423
header[7] = (mtime >> 24) as u8;

src/gz/write.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ impl<W: Write> GzEncoder<W> {
9393
while self.crc_bytes_written < 8 {
9494
let (sum, amt) = (self.crc.sum(), self.crc.amount());
9595
let buf = [
96-
(sum >> 0) as u8,
96+
sum as u8,
9797
(sum >> 8) as u8,
9898
(sum >> 16) as u8,
9999
(sum >> 24) as u8,
100-
(amt >> 0) as u8,
100+
amt as u8,
101101
(amt >> 8) as u8,
102102
(amt >> 16) as u8,
103103
(amt >> 24) as u8,
@@ -294,11 +294,11 @@ impl<W: Write> GzDecoder<W> {
294294
return Err(corrupt());
295295
}
296296

297-
let crc = ((self.crc_bytes[0] as u32) << 0)
297+
let crc = (self.crc_bytes[0] as u32)
298298
| ((self.crc_bytes[1] as u32) << 8)
299299
| ((self.crc_bytes[2] as u32) << 16)
300300
| ((self.crc_bytes[3] as u32) << 24);
301-
let amt = ((self.crc_bytes[4] as u32) << 0)
301+
let amt = (self.crc_bytes[4] as u32)
302302
| ((self.crc_bytes[5] as u32) << 8)
303303
| ((self.crc_bytes[6] as u32) << 16)
304304
| ((self.crc_bytes[7] as u32) << 24);

src/mem.rs

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct Decompress {
4343
/// in-memory data.
4444
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
4545
#[non_exhaustive]
46+
#[allow(clippy::unnecessary_cast)]
4647
pub enum FlushCompress {
4748
/// A typical parameter for passing to compression/decompression functions,
4849
/// this indicates that the underlying stream to decide how much data to
@@ -86,6 +87,7 @@ pub enum FlushCompress {
8687
/// decompressing in-memory data.
8788
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
8889
#[non_exhaustive]
90+
#[allow(clippy::unnecessary_cast)]
8991
pub enum FlushDecompress {
9092
/// A typical parameter for passing to compression/decompression functions,
9193
/// this indicates that the underlying stream to decide how much data to
@@ -277,6 +279,7 @@ impl Compress {
277279

278280
match rc {
279281
ffi::MZ_STREAM_ERROR => compress_failed(self.inner.inner.msg()),
282+
#[allow(clippy::unnecessary_cast)]
280283
ffi::MZ_OK => Ok(unsafe { (*stream).adler } as u32),
281284
c => panic!("unknown return code: {}", c),
282285
}
@@ -493,6 +496,7 @@ impl Decompress {
493496
ffi::inflateSetDictionary(stream, dictionary.as_ptr(), dictionary.len() as ffi::uInt)
494497
};
495498

499+
#[allow(clippy::unnecessary_cast)]
496500
match rc {
497501
ffi::MZ_STREAM_ERROR => decompress_failed(self.inner.inner.msg()),
498502
ffi::MZ_DATA_ERROR => decompress_need_dict(unsafe { (*stream).adler } as u32),

0 commit comments

Comments
 (0)