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

clippy warnings (rust 1.70) #1677

Open
thatmarkenglishguy opened this issue Jul 27, 2023 · 0 comments
Open

clippy warnings (rust 1.70) #1677

thatmarkenglishguy opened this issue Jul 27, 2023 · 0 comments

Comments

@thatmarkenglishguy
Copy link
Contributor

thatmarkenglishguy commented Jul 27, 2023

  • Rust version : rustc 1.72.0 (5680fa18f 2023-08-23)
  • nom version : nom is at version 7.1.3 in crates.io. Compiling main (sha 8c68e22d9f2d0aadaa1770d980d59ea562dfb6a7)
  • nom compilation features used: cargo clippy and for later updates cargo clippy --all-targets

Original PR

Test case

git clone git@github.com:rust-bakery/nom.git
cd nom
git checkout 90d78d65a10821272ce8856570605b07a917a6c1
cargo clippy

Build output

warning: unneeded `return` statement
   --> src/multi/mod.rs:817:9
    |
817 | /         return Err(Err::Error(OM::Error::bind(move || {
818 | |           <F as Parser<I>>::Error::from_error_kind(input, ErrorKind::Many1Count)
819 | |         })))
    | |____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
    = help: remove `return`

error: using `clone` on a double-reference; this will copy the reference of type `&[u8]` instead of cloning the inner type
   --> src/traits.rs:336:28
    |
336 |         E::from_error_kind(self.clone(), e)
    |                            ^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
    = note: `#[deny(clippy::clone_double_ref)]` on by default
help: try dereferencing it
    |
336 |         E::from_error_kind(&(*self).clone(), e)
    |                            ~~~~~~~~~~~~~~~~
help: or try being explicit if you are sure, that you want to clone a reference
    |
336 |         E::from_error_kind(<&[u8]>::clone(self), e)
    |                            ~~~~~~~~~~~~~~~~~~~~

error: using `clone` on a double-reference; this will copy the reference of type `&[u8]` instead of cloning the inner type
   --> src/traits.rs:344:32
    |
344 |             E::from_error_kind(self.clone(), e)
    |                                ^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
help: try dereferencing it
    |
344 |             E::from_error_kind(&(*self).clone(), e)
    |                                ~~~~~~~~~~~~~~~~
help: or try being explicit if you are sure, that you want to clone a reference
    |
344 |             E::from_error_kind(<&[u8]>::clone(self), e)
    |                                ~~~~~~~~~~~~~~~~~~~~

error: using `clone` on a double-reference; this will copy the reference of type `&str` instead of cloning the inner type
   --> src/traits.rs:533:28
    |
533 |         E::from_error_kind(self.clone(), e)
    |                            ^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
help: try dereferencing it
    |
533 |         E::from_error_kind(&(*self).clone(), e)
    |                            ~~~~~~~~~~~~~~~~
help: or try being explicit if you are sure, that you want to clone a reference
    |
533 |         E::from_error_kind(<&str>::clone(self), e)
    |                            ~~~~~~~~~~~~~~~~~~~

warning: length comparison to zero
   --> src/traits.rs:545:19
    |
545 |         } else if self.len() == 0 {
    |                   ^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `self.is_empty()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
    = note: `#[warn(clippy::len_zero)]` on by default

error: using `clone` on a double-reference; this will copy the reference of type `&str` instead of cloning the inner type
   --> src/traits.rs:547:32
    |
547 |             E::from_error_kind(self.clone(), e)
    |                                ^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
help: try dereferencing it
    |
547 |             E::from_error_kind(&(*self).clone(), e)
    |                                ~~~~~~~~~~~~~~~~
help: or try being explicit if you are sure, that you want to clone a reference
    |
547 |             E::from_error_kind(<&str>::clone(self), e)
    |                                ~~~~~~~~~~~~~~~~~~~

warning: deref which would be done by auto-deref
   --> src/traits.rs:672:5
    |
672 |     *self
    |     ^^^^^ help: try this: `self`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
    = note: `#[warn(clippy::explicit_auto_deref)]` on by default

warning: this boolean expression can be simplified
    --> src/traits.rs:1457:5
     |
1457 |     !(self.start < self.end)
     |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.start >= self.end`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
     = note: `#[warn(clippy::nonminimal_bool)]` on by default

error: this range is empty so it will yield no values
    --> src/traits.rs:1462:7
     |
1462 |       1..0
     |       ^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
     = note: `#[deny(clippy::reversed_empty_ranges)]` on by default
help: consider using the following if you are attempting to iterate over this range in reverse
     |
1462 |       (0..1).rev()
     |

error: this range is empty so it will yield no values
    --> src/traits.rs:1470:7
     |
1470 |       1..0
     |       ^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
help: consider using the following if you are attempting to iterate over this range in reverse
     |
1470 |       (0..1).rev()
     |

error: this range is empty so it will yield no values
    --> src/traits.rs:1545:7
     |
1545 |       1..0
     |       ^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
help: consider using the following if you are attempting to iterate over this range in reverse
     |
1545 |       (0..1).rev()
     |

error: this range is empty so it will yield no values
    --> src/traits.rs:1553:7
     |
1553 |       1..0
     |       ^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
help: consider using the following if you are attempting to iterate over this range in reverse
     |
1553 |       (0..1).rev()
     |

warning: redundant clone
   --> src/bytes/mod.rs:958:18
    |
958 |     let i = input.clone();
    |                  ^^^^^^^^ help: remove this
    |
note: cloned value is neither consumed nor mutated
   --> src/bytes/mod.rs:958:13
    |
958 |     let i = input.clone();
    |             ^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
    = note: `#[warn(clippy::redundant_clone)]` on by default

warning: `nom` (lib) generated 5 warnings
error: could not compile `nom` (lib) due to 8 previous errors; 5 warnings emitted

Update 13/09/2023

More warnings generated by merging updated main branch and running:

cargo clippy --all-targets
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

No branches or pull requests

1 participant