diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91da240b..6a7c6ef2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ name: CI jobs: tests: - name: Check + name: stable lint, test, build runs-on: ubuntu-latest steps: - name: Checkout sources @@ -14,16 +14,23 @@ jobs: uses: dtolnay/rust-toolchain@stable with: components: clippy - - name: Install cargo-hack + - name: Install cargo-hack and cargo-msrv uses: taiki-e/install-action@v2 with: - tool: cargo-hack - - run: cargo hack check --workspace --feature-powerset --exclude-features rustc-dep-of-std - - run: cargo hack clippy --workspace --feature-powerset --exclude-features rustc-dep-of-std - - run: cargo hack test --workspace --feature-powerset --exclude-features rustc-dep-of-std + tool: cargo-hack, cargo-msrv + - name: check + run: cargo hack check --workspace --feature-powerset --exclude-features rustc-dep-of-std + - name: cargo hack clippy + run: cargo hack clippy --workspace --feature-powerset --exclude-features rustc-dep-of-std + - name: cargo hack test + run: cargo hack test --workspace --feature-powerset --exclude-features rustc-dep-of-std + - name: Verify MSRV (cli) + run: cargo msrv verify --path cli/ + - name: Verify MSRV (lib) + run: cargo msrv verify --path ruzstd/ nightly-stuff: - name: nightly clippy, format and miri tests + name: nightly lint, miri runs-on: ubuntu-latest steps: - name: Checkout sources @@ -39,4 +46,3 @@ jobs: - run: cargo +nightly clippy --workspace -- -D warnings - run: cargo +nightly miri test ringbuffer - run: cargo +nightly miri test short_Writer - diff --git a/Changelog.md b/Changelog.md index 8ca8243d..644f8cbe 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ This document records the changes made between versions, starting with version 0.5.0 # After 0.8.2 (Current) +* Introduce the `rust-version` field # After 0.8.1 * The CLI has been refactored to use `clap` diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 93b03691..2fc340ba 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "ruzstd-cli" -version = "0.8.1" +version = "0.8.2" +rust-version = "1.87.0" authors = ["Moritz Borcherding "] edition = "2018" license = "MIT" @@ -26,4 +27,4 @@ ruzstd = { path = "../ruzstd", features = ["std"] } [dev-dependencies] criterion = "0.5" rand = { version = "0.8.5", features = ["small_rng"] } -zstd = "0.13.2" \ No newline at end of file +zstd = "0.13.2" diff --git a/cli/src/main.rs b/cli/src/main.rs index 6d20429e..fb336717 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -4,7 +4,6 @@ use progress::ProgressMonitor; use std::fs::File; use std::io::BufReader; -use std::os::unix::fs::MetadataExt; use std::path::Path; use std::path::PathBuf; @@ -134,7 +133,7 @@ fn compress(input: PathBuf, output: PathBuf, level: u8) -> color_eyre::Result<() fn decompress(input: PathBuf, output: PathBuf) -> color_eyre::Result<()> { info!("extracting {input:?} to {output:?}"); let source_file = File::open(input).wrap_err("failed to open input file")?; - let source_size = source_file.metadata()?.size() as usize; + let source_size = source_file.metadata()?.len() as usize; let buffered_source = BufReader::new(source_file); let decoder_input = ProgressMonitor::new(buffered_source, source_size); let mut output: File = diff --git a/ruzstd/Cargo.toml b/ruzstd/Cargo.toml index 53aac8fd..9e2e1e61 100644 --- a/ruzstd/Cargo.toml +++ b/ruzstd/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "ruzstd" -version = "0.8.2" +version = "0.8.3" +rust-version = "1.87" authors = ["Moritz Borcherding "] edition = "2018" license = "MIT" diff --git a/ruzstd/src/decoding/ringbuffer.rs b/ruzstd/src/decoding/ringbuffer.rs index 53796e51..cf25bc6f 100644 --- a/ruzstd/src/decoding/ringbuffer.rs +++ b/ruzstd/src/decoding/ringbuffer.rs @@ -154,7 +154,7 @@ impl RingBuffer { self.reserve(len); - debug_assert!(self.len() + len <= self.cap - 1); + debug_assert!(self.len() + len < self.cap); debug_assert!(self.free() >= len, "free: {} len: {}", self.free(), len); let ((f1_ptr, f1_len), (f2_ptr, f2_len)) = self.free_slice_parts(); diff --git a/ruzstd/src/decoding/sequence_section_decoder.rs b/ruzstd/src/decoding/sequence_section_decoder.rs index bc56a1f4..2753fe0c 100644 --- a/ruzstd/src/decoding/sequence_section_decoder.rs +++ b/ruzstd/src/decoding/sequence_section_decoder.rs @@ -71,18 +71,18 @@ fn decode_sequences_with_rle( for _seq_idx in 0..section.num_sequences { //get the codes from either the RLE byte or from the decoder - let ll_code = if scratch.ll_rle.is_some() { - scratch.ll_rle.unwrap() + let ll_code = if let Some(ll_rle) = scratch.ll_rle { + ll_rle } else { ll_dec.decode_symbol() }; - let ml_code = if scratch.ml_rle.is_some() { - scratch.ml_rle.unwrap() + let ml_code = if let Some(ml_rle) = scratch.ml_rle { + ml_rle } else { ml_dec.decode_symbol() }; - let of_code = if scratch.of_rle.is_some() { - scratch.of_rle.unwrap() + let of_code = if let Some(of_rle) = scratch.of_rle { + of_rle } else { of_dec.decode_symbol() }; diff --git a/ruzstd/src/fse/fse_encoder.rs b/ruzstd/src/fse/fse_encoder.rs index ad5e815f..974eecf5 100644 --- a/ruzstd/src/fse/fse_encoder.rs +++ b/ruzstd/src/fse/fse_encoder.rs @@ -369,7 +369,7 @@ pub(super) fn build_table_from_probabilities(probs: &[i32], acc_log: u8) -> FSET let state = &mut states[symbol]; // We process the states in their order in the table - state.states.sort_by(|l, r| l.index.cmp(&r.index)); + state.states.sort_by_key(|l| l.index); let prob_log = if prob.is_power_of_two() { prob.ilog2() @@ -401,7 +401,7 @@ pub(super) fn build_table_from_probabilities(probs: &[i32], acc_log: u8) -> FSET } // For encoding we use the states ordered by the indexes they target - state.states.sort_by(|l, r| l.baseline.cmp(&r.baseline)); + state.states.sort_by_key(|l| l.baseline); } FSETable { diff --git a/ruzstd/src/huff0/huff0_encoder.rs b/ruzstd/src/huff0/huff0_encoder.rs index f5eefc97..28b45ce4 100644 --- a/ruzstd/src/huff0/huff0_encoder.rs +++ b/ruzstd/src/huff0/huff0_encoder.rs @@ -179,7 +179,7 @@ impl HuffmanTable { weights.reverse(); let mut counts_sorted = counts.iter().enumerate().collect::>(); - counts_sorted.sort_by(|(_, c1), (_, c2)| c1.cmp(c2)); + counts_sorted.sort_by_key(|(_, c1)| *c1); let mut weights_distributed = alloc::vec![0; counts.len()]; for (idx, count) in counts_sorted {