Clarify message for erasing_op lint

This commit is contained in:
Yury Krivopalov 2017-10-15 10:32:47 +03:00
parent a5d2bfebc4
commit 7b16f4d7ff
3 changed files with 8 additions and 7 deletions

View File

@ -7,7 +7,8 @@ use utils::{in_macro, span_lint};
/// **What it does:** Checks for erasing operations, e.g. `x * 0`.
///
/// **Why is this bad?** The whole expression can be replaced by zero.
/// Most likely mistake was made and code should be reviewed or simplified.
/// This is most likely not the intended outcome and should probably be
/// corrected
///
/// **Known problems:** None.
///
@ -55,7 +56,7 @@ fn check(cx: &LateContext, e: &Expr, span: Span) {
cx,
ERASING_OP,
span,
"the operation is ineffective. Consider reducing it to `0`",
"this operation will always return zero. This is likely not the intended outcome",
);
}
}

View File

@ -6,7 +6,7 @@ error: &-masking with zero
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `0`
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/bit_masks.rs:12:5
|
12 | x & 0 == 0;
@ -56,7 +56,7 @@ error: &-masking with zero
35 | 0 & x == 0;
| ^^^^^^^^^^
error: the operation is ineffective. Consider reducing it to `0`
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/bit_masks.rs:35:5
|
35 | 0 & x == 0;

View File

@ -1,4 +1,4 @@
error: the operation is ineffective. Consider reducing it to `0`
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/erasing_op.rs:9:5
|
9 | x * 0;
@ -6,13 +6,13 @@ error: the operation is ineffective. Consider reducing it to `0`
|
= note: `-D erasing-op` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `0`
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/erasing_op.rs:10:5
|
10 | 0 & x;
| ^^^^^
error: the operation is ineffective. Consider reducing it to `0`
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/erasing_op.rs:11:5
|
11 | 0 / x;