mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 14:38:46 +00:00
Merge pull request #1953 from mati865/master
Fix verbose_bit_mask off by one error
This commit is contained in:
commit
3ab06c1f77
3 changed files with 5 additions and 5 deletions
|
@ -126,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
|
|||
"bit mask could be simplified with a call to `trailing_zeros`",
|
||||
|db| {
|
||||
let sugg = Sugg::hir(cx, left1, "...").maybe_par();
|
||||
db.span_suggestion(e.span, "try", format!("{}.trailing_zeros() > {}", sugg, n.count_ones()));
|
||||
db.span_suggestion(e.span, "try", format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()));
|
||||
});
|
||||
}}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ error: bit mask could be simplified with a call to `trailing_zeros`
|
|||
--> $DIR/bit_masks.rs:12:5
|
||||
|
|
||||
12 | x & 0 == 0;
|
||||
| ^^^^^^^^^^ help: try: `x.trailing_zeros() > 0`
|
||||
| ^^^^^^^^^^ help: try: `x.trailing_zeros() >= 0`
|
||||
|
|
||||
= note: `-D verbose-bit-mask` implied by `-D warnings`
|
||||
|
||||
|
@ -18,7 +18,7 @@ error: bit mask could be simplified with a call to `trailing_zeros`
|
|||
--> $DIR/bit_masks.rs:14:5
|
||||
|
|
||||
14 | x & 1 == 0; //ok, compared with zero
|
||||
| ^^^^^^^^^^ help: try: `x.trailing_zeros() > 1`
|
||||
| ^^^^^^^^^^ help: try: `x.trailing_zeros() >= 1`
|
||||
|
||||
error: incompatible bit mask: `_ & 2` can never be equal to `1`
|
||||
--> $DIR/bit_masks.rs:15:5
|
||||
|
|
|
@ -2,7 +2,7 @@ error: bit mask could be simplified with a call to `trailing_zeros`
|
|||
--> $DIR/trailing_zeros.rs:7:31
|
||||
|
|
||||
7 | let _ = #[clippy(author)] (x & 0b1111 == 0); // suggest trailing_zeros
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() > 4`
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4`
|
||||
|
|
||||
= note: `-D verbose-bit-mask` implied by `-D warnings`
|
||||
|
||||
|
@ -10,7 +10,7 @@ error: bit mask could be simplified with a call to `trailing_zeros`
|
|||
--> $DIR/trailing_zeros.rs:8:13
|
||||
|
|
||||
8 | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() > 5`
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue