Skip to content

Commit d853b05

Browse files
committed
Remove double negation, use starts_with
1 parent 647c07f commit d853b05

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

clippy_lints/src/decimal_bit_mask.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn check_bitwise_binary_expr(cx: &LateContext<'_>, expr: &Expr<'_>) {
4444
{
4545
for expr in [left, right] {
4646
if let ExprKind::Lit(lit) = &expr.kind
47-
&& !is_not_decimal_number(cx, lit.span)
47+
&& is_decimal_number(cx, lit.span)
4848
&& !is_power_of_twoish(lit)
4949
{
5050
emit_lint(cx, lit.span);
@@ -65,15 +65,17 @@ fn check_bitwise_assign_expr(cx: &LateContext<'_>, expr: &Expr<'_>) {
6565
..
6666
},
6767
) = &expr.kind
68+
&& is_decimal_number(cx, lit.span)
6869
&& !is_power_of_twoish(lit)
69-
&& !is_not_decimal_number(cx, lit.span)
7070
{
7171
emit_lint(cx, lit.span);
7272
}
7373
}
7474

75-
fn is_not_decimal_number(cx: &LateContext<'_>, span: Span) -> bool {
76-
span.check_source_text(cx, |src| src.contains("0b") || src.contains("0x") || src.contains("0o"))
75+
fn is_decimal_number(cx: &LateContext<'_>, span: Span) -> bool {
76+
span.check_source_text(cx, |src| {
77+
!(src.starts_with("0b") || src.starts_with("0x") || src.starts_with("0o"))
78+
})
7779
}
7880

7981
fn is_power_of_twoish(lit: &Spanned<LitKind>) -> bool {

0 commit comments

Comments
 (0)