Skip to content

Commit

Permalink
Fix incorrect uses of bitwise_bool in dogfood
Browse files Browse the repository at this point in the history
  • Loading branch information
arya-k committed Apr 25, 2021
1 parent 05c8fe5 commit 2c4e8b8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/needless_range_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub(super) fn check<'tcx>(
take_expr = left;
}

end_is_start_plus_val = start_equal_left | start_equal_right;
end_is_start_plus_val = start_equal_left || start_equal_right;
}
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/unnecessary_filter_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn check_expression<'tcx>(cx: &LateContext<'tcx>, arg_id: hir::HirId, expr: &'tc
hir::ExprKind::If(_, if_arm, Some(else_arm)) => {
let if_check = check_expression(cx, arg_id, if_arm);
let else_check = check_expression(cx, arg_id, else_arm);
(if_check.0 | else_check.0, if_check.1 | else_check.1)
(if_check.0 || else_check.0, if_check.1 || else_check.1)
},
hir::ExprKind::Path(path) if is_lang_ctor(cx, path, OptionNone) => (false, true),
_ => (true, true),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/needless_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolComparison {
)),
ignore_case,
Some((
|l: Sugg<'_>, r: Sugg<'_>| (!l).bit_and(&r),
|l: Sugg<'_>, r: Sugg<'_>| (!l).and(&r),
"order comparisons between booleans can be simplified",
)),
),
Expand All @@ -180,7 +180,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolComparison {
ignore_case,
Some((|h| h, "greater than checks against false are unnecessary")),
Some((
|l: Sugg<'_>, r: Sugg<'_>| l.bit_and(&(!r)),
|l: Sugg<'_>, r: Sugg<'_>| l.and(&(!r)),
"order comparisons between booleans can be simplified",
)),
),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
}

fn check_ty(&mut self, cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>) {
if in_macro(hir_ty.span) | in_impl(cx, hir_ty) | !meets_msrv(self.msrv.as_ref(), &USE_SELF_MSRV) {
if in_macro(hir_ty.span) || in_impl(cx, hir_ty) || !meets_msrv(self.msrv.as_ref(), &USE_SELF_MSRV) {
return;
}

Expand Down Expand Up @@ -288,7 +288,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
}
}

if in_macro(expr.span) | !meets_msrv(self.msrv.as_ref(), &USE_SELF_MSRV) {
if in_macro(expr.span) || !meets_msrv(self.msrv.as_ref(), &USE_SELF_MSRV) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/bool_comparison.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ fn main() {
"no"
};
let y = true;
if !x & y {
if !x && y {
"yes"
} else {
"no"
};
if x & !y {
if x && !y {
"yes"
} else {
"no"
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/bool_comparison.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ error: order comparisons between booleans can be simplified
--> $DIR/bool_comparison.rs:68:8
|
LL | if x < y {
| ^^^^^ help: try simplifying it as shown: `!x & y`
| ^^^^^ help: try simplifying it as shown: `!x && y`

error: order comparisons between booleans can be simplified
--> $DIR/bool_comparison.rs:73:8
|
LL | if x > y {
| ^^^^^ help: try simplifying it as shown: `x & !y`
| ^^^^^ help: try simplifying it as shown: `x && !y`

error: this comparison might be written more concisely
--> $DIR/bool_comparison.rs:121:8
Expand Down

0 comments on commit 2c4e8b8

Please sign in to comment.