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 lint errors #49

Merged
merged 4 commits into from Oct 14, 2023
Merged

Fix lint errors #49

merged 4 commits into from Oct 14, 2023

Conversation

tamird
Copy link
Contributor

@tamird tamird commented Oct 13, 2023

  • Remove useless assertion
  • Avoid single-match expression
  • Avoid slow zero-filling initialization
  • Avoid unnecessary cast

warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false
   --> src/decoding/ringbuffer.rs:271:24
    |
271 |         debug_assert!(!self.buf.as_ptr().is_null());
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(useless_ptr_null_checks)]` on by default
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
  --> src/tests/fuzz_regressions.rs:20:9
   |
20 | /         match frame_dec.reset(&mut f) {
21 | |             Ok(_) => {
22 | |                 let _ = frame_dec.decode_blocks(&mut f, frame_decoder::BlockDecodingStrategy::All);
23 | |                 /* ignore errors. It just should never panic on invalid input */
24 | |             }
25 | |             Err(_) => {} /* ignore errors. It just should never panic on invalid input */
26 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
   = note: `#[warn(clippy::single_match)]` on by default
warning: slow zero-filling initialization
   --> src/tests/mod.rs:355:5
    |
354 |     let mut result = Vec::new();
    |                      ---------- help: consider replacing this with: `vec![0; original.len()]`
355 |     result.resize(original.len(), 0);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
    = note: `#[warn(clippy::slow_vector_initialization)]` on by default
warning: casting to the same type is unnecessary (`u64` -> `u64`)
 --> benches/reversedbitreader_bench.rs:8:16
  |
8 |         sum += br.get_bits(*x).unwrap() as u64;
  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `br.get_bits(*x).unwrap()`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
  = note: `#[warn(clippy::unnecessary_cast)]` on by default
@KillingSpark
Copy link
Owner

Nice, can I ask how you got these lints? The CI only caught the redundant assertion. Did clippy get another update?

@KillingSpark KillingSpark merged commit e15eb1e into KillingSpark:master Oct 14, 2023
6 checks passed
@tamird tamird deleted the clippy branch October 14, 2023 14:31
@tamird
Copy link
Contributor Author

tamird commented Oct 14, 2023

Yeah I ran this on nightly (to exercise all features).

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.

None yet

2 participants