Skip to content

Commit 7b16f4d

Browse files
author
Yury Krivopalov
committed
Clarify message for erasing_op lint
1 parent a5d2bfe commit 7b16f4d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

clippy_lints/src/erasing_op.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use utils::{in_macro, span_lint};
77
/// **What it does:** Checks for erasing operations, e.g. `x * 0`.
88
///
99
/// **Why is this bad?** The whole expression can be replaced by zero.
10-
/// Most likely mistake was made and code should be reviewed or simplified.
10+
/// This is most likely not the intended outcome and should probably be
11+
/// corrected
1112
///
1213
/// **Known problems:** None.
1314
///
@@ -55,7 +56,7 @@ fn check(cx: &LateContext, e: &Expr, span: Span) {
5556
cx,
5657
ERASING_OP,
5758
span,
58-
"the operation is ineffective. Consider reducing it to `0`",
59+
"this operation will always return zero. This is likely not the intended outcome",
5960
);
6061
}
6162
}

tests/ui/bit_masks.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ error: &-masking with zero
66
|
77
= note: `-D bad-bit-mask` implied by `-D warnings`
88

9-
error: the operation is ineffective. Consider reducing it to `0`
9+
error: this operation will always return zero. This is likely not the intended outcome
1010
--> $DIR/bit_masks.rs:12:5
1111
|
1212
12 | x & 0 == 0;
@@ -56,7 +56,7 @@ error: &-masking with zero
5656
35 | 0 & x == 0;
5757
| ^^^^^^^^^^
5858

59-
error: the operation is ineffective. Consider reducing it to `0`
59+
error: this operation will always return zero. This is likely not the intended outcome
6060
--> $DIR/bit_masks.rs:35:5
6161
|
6262
35 | 0 & x == 0;

tests/ui/erasing_op.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: the operation is ineffective. Consider reducing it to `0`
1+
error: this operation will always return zero. This is likely not the intended outcome
22
--> $DIR/erasing_op.rs:9:5
33
|
44
9 | x * 0;
55
| ^^^^^
66
|
77
= note: `-D erasing-op` implied by `-D warnings`
88

9-
error: the operation is ineffective. Consider reducing it to `0`
9+
error: this operation will always return zero. This is likely not the intended outcome
1010
--> $DIR/erasing_op.rs:10:5
1111
|
1212
10 | 0 & x;
1313
| ^^^^^
1414

15-
error: the operation is ineffective. Consider reducing it to `0`
15+
error: this operation will always return zero. This is likely not the intended outcome
1616
--> $DIR/erasing_op.rs:11:5
1717
|
1818
11 | 0 / x;

0 commit comments

Comments
 (0)