Skip to content

Commit d7e20a9

Browse files
authored
docs: fix verbose-bit-mask example (#14055)
changelog: none `x & 15 == 0` is not equivalent to `x.trailing_zeros() > 4`, as `x = 0b10000` is true for the former and false for the latter. In fact, clippy itself suggests the following: ```rust pub fn src(x: i32) -> bool { x & 15 == 0 // ~error: bit mask could be simplified with a call to `trailing_zeros` ^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` } ```
2 parents 4b05f50 + a18b75a commit d7e20a9

File tree

1 file changed

+2
-2
lines changed
  • clippy_lints/src/operators

1 file changed

+2
-2
lines changed

clippy_lints/src/operators/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ declare_clippy_lint! {
262262
/// to `trailing_zeros`
263263
///
264264
/// ### Why is this bad?
265-
/// `x.trailing_zeros() > 4` is much clearer than `x & 15
265+
/// `x.trailing_zeros() >= 4` is much clearer than `x & 15
266266
/// == 0`
267267
///
268268
/// ### Known problems
@@ -278,7 +278,7 @@ declare_clippy_lint! {
278278
///
279279
/// ```no_run
280280
/// # let x: i32 = 1;
281-
/// if x.trailing_zeros() > 4 { }
281+
/// if x.trailing_zeros() >= 4 { }
282282
/// ```
283283
#[clippy::version = "pre 1.29.0"]
284284
pub VERBOSE_BIT_MASK,

0 commit comments

Comments
 (0)