Rename 'impossible_double_const_comparisons' -> 'impossible_comparisons' and 'ineffective_double_const_comparisons' -> 'redundant_comparisons', after discussion on Zulip

This commit is contained in:
Morten Lohne 2023-06-10 15:58:46 +02:00
parent b5ef66f442
commit 1d61fc1b0a
8 changed files with 54 additions and 54 deletions

View File

@ -4897,7 +4897,7 @@ Released 2018-09-13
[`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return
[`implicit_saturating_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_add
[`implicit_saturating_sub`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub
[`impossible_double_const_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#impossible_double_const_comparisons
[`impossible_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#impossible_comparisons
[`imprecise_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#imprecise_flops
[`inconsistent_digit_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping
[`inconsistent_struct_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor
@ -4906,7 +4906,6 @@ Released 2018-09-13
[`index_refutable_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice
[`indexing_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing
[`ineffective_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#ineffective_bit_mask
[`ineffective_double_const_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#ineffective_double_const_comparisons
[`inefficient_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#inefficient_to_string
[`infallible_destructuring_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#infallible_destructuring_match
[`infinite_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#infinite_iter
@ -5193,6 +5192,7 @@ Released 2018-09-13
[`redundant_closure`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
[`redundant_closure_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_call
[`redundant_closure_for_method_calls`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
[`redundant_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_comparisons
[`redundant_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else
[`redundant_feature_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_feature_names
[`redundant_field_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

View File

@ -518,9 +518,8 @@
crate::operators::FLOAT_CMP_CONST_INFO,
crate::operators::FLOAT_EQUALITY_WITHOUT_ABS_INFO,
crate::operators::IDENTITY_OP_INFO,
crate::operators::IMPOSSIBLE_DOUBLE_CONST_COMPARISONS_INFO,
crate::operators::IMPOSSIBLE_COMPARISONS_INFO,
crate::operators::INEFFECTIVE_BIT_MASK_INFO,
crate::operators::INEFFECTIVE_DOUBLE_CONST_COMPARISONS_INFO,
crate::operators::INTEGER_DIVISION_INFO,
crate::operators::MISREFACTORED_ASSIGN_OP_INFO,
crate::operators::MODULO_ARITHMETIC_INFO,
@ -528,6 +527,7 @@
crate::operators::NEEDLESS_BITWISE_BOOL_INFO,
crate::operators::OP_REF_INFO,
crate::operators::PTR_EQ_INFO,
crate::operators::REDUNDANT_COMPARISONS_INFO,
crate::operators::SELF_ASSIGNMENT_INFO,
crate::operators::VERBOSE_BIT_MASK_INFO,
crate::option_env_unwrap::OPTION_ENV_UNWRAP_INFO,

View File

@ -14,8 +14,8 @@
use clippy_utils::source::snippet;
use clippy_utils::SpanlessEq;
use super::IMPOSSIBLE_DOUBLE_CONST_COMPARISONS;
use super::INEFFECTIVE_DOUBLE_CONST_COMPARISONS;
use super::IMPOSSIBLE_COMPARISONS;
use super::REDUNDANT_COMPARISONS;
// Extract a comparison between a const and non-const
// Flip yoda conditionals, turnings expressions like `42 < x` into `x > 42`
@ -91,7 +91,7 @@ pub(super) fn check<'tcx>(
if left_side_is_useless(left_cmp_op, ordering) {
span_lint_and_note(
cx,
INEFFECTIVE_DOUBLE_CONST_COMPARISONS,
REDUNDANT_COMPARISONS,
span,
"left-hand side of `&&` operator has no effect",
Some(left_cond.span.until(right_cond.span)),
@ -100,7 +100,7 @@ pub(super) fn check<'tcx>(
} else {
span_lint_and_note(
cx,
INEFFECTIVE_DOUBLE_CONST_COMPARISONS,
REDUNDANT_COMPARISONS,
span,
"right-hand side of `&&` operator has no effect",
Some(and_op.span.to(right_cond.span)),
@ -121,7 +121,7 @@ pub(super) fn check<'tcx>(
};
span_lint_and_note(
cx,
IMPOSSIBLE_DOUBLE_CONST_COMPARISONS,
IMPOSSIBLE_COMPARISONS,
span,
"boolean expression will never evaluate to 'true'",
None,

View File

@ -2,8 +2,8 @@
mod assign_op_pattern;
mod bit_mask;
mod cmp_owned;
mod const_comparisons;
mod double_comparison;
mod double_const_comparison;
mod duration_subsec;
mod eq_op;
mod erasing_op;
@ -313,7 +313,7 @@
/// if status_code <= 400 && status_code > 500 {}
/// ```
#[clippy::version = "1.71.0"]
pub IMPOSSIBLE_DOUBLE_CONST_COMPARISONS,
pub IMPOSSIBLE_COMPARISONS,
correctness,
"double comparisons that will never evaluate to `true`"
}
@ -333,7 +333,7 @@
/// if status_code <= 400 && status_code < 500 {}
/// ```
#[clippy::version = "1.71.0"]
pub INEFFECTIVE_DOUBLE_CONST_COMPARISONS,
pub REDUNDANT_COMPARISONS,
correctness,
"double comparisons where one of them can be removed"
}
@ -782,8 +782,8 @@ pub struct Operators {
INEFFECTIVE_BIT_MASK,
VERBOSE_BIT_MASK,
DOUBLE_COMPARISONS,
IMPOSSIBLE_DOUBLE_CONST_COMPARISONS,
INEFFECTIVE_DOUBLE_CONST_COMPARISONS,
IMPOSSIBLE_COMPARISONS,
REDUNDANT_COMPARISONS,
DURATION_SUBSEC,
EQ_OP,
OP_REF,
@ -828,7 +828,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
bit_mask::check(cx, e, op.node, lhs, rhs);
verbose_bit_mask::check(cx, e, op.node, lhs, rhs, self.verbose_bit_mask_threshold);
double_comparison::check(cx, op.node, lhs, rhs, e.span);
double_const_comparison::check(cx, op, lhs, rhs, e.span);
const_comparisons::check(cx, op, lhs, rhs, e.span);
duration_subsec::check(cx, e, op.node, lhs, rhs);
float_equality_without_abs::check(cx, e, op.node, lhs, rhs);
integer_division::check(cx, e, op.node, lhs, rhs);

View File

@ -1,6 +1,6 @@
#![allow(unused)]
#![warn(clippy::impossible_double_const_comparisons)]
#![warn(clippy::ineffective_double_const_comparisons)]
#![warn(clippy::impossible_comparisons)]
#![warn(clippy::redundant_comparisons)]
#![allow(clippy::no_effect)]
#![allow(clippy::short_circuit_statement)]
#![allow(clippy::manual_range_contains)]

View File

@ -1,14 +1,14 @@
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:44:5
--> $DIR/const_comparisons.rs:44:5
|
LL | status_code <= 400 && status_code > 500;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: since `400` < `500`, the expression evaluates to false for any value of `status_code`
= note: `-D clippy::impossible-double-const-comparisons` implied by `-D warnings`
= note: `-D clippy::impossible-comparisons` implied by `-D warnings`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:45:5
--> $DIR/const_comparisons.rs:45:5
|
LL | status_code > 500 && status_code < 400;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -16,7 +16,7 @@ LL | status_code > 500 && status_code < 400;
= note: since `500` > `400`, the expression evaluates to false for any value of `status_code`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:46:5
--> $DIR/const_comparisons.rs:46:5
|
LL | status_code < 500 && status_code > 500;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL | status_code < 500 && status_code > 500;
= note: `status_code` cannot simultaneously be greater than and less than `500`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:49:5
--> $DIR/const_comparisons.rs:49:5
|
LL | status_code < { 400 } && status_code > { 500 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -32,7 +32,7 @@ LL | status_code < { 400 } && status_code > { 500 };
= note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status_code`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:50:5
--> $DIR/const_comparisons.rs:50:5
|
LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -40,7 +40,7 @@ LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR;
= note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:51:5
--> $DIR/const_comparisons.rs:51:5
|
LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -48,7 +48,7 @@ LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR;
= note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:52:5
--> $DIR/const_comparisons.rs:52:5
|
LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -56,7 +56,7 @@ LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR;
= note: `status_code` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:55:5
--> $DIR/const_comparisons.rs:55:5
|
LL | status < { 400 } && status > { 500 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -64,7 +64,7 @@ LL | status < { 400 } && status > { 500 };
= note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:56:5
--> $DIR/const_comparisons.rs:56:5
|
LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -72,7 +72,7 @@ LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR;
= note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:57:5
--> $DIR/const_comparisons.rs:57:5
|
LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -80,7 +80,7 @@ LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR;
= note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:58:5
--> $DIR/const_comparisons.rs:58:5
|
LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -88,7 +88,7 @@ LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR;
= note: `status` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:63:5
--> $DIR/const_comparisons.rs:63:5
|
LL | 500 >= status_code && 600 < status_code; // Incorrect
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -96,7 +96,7 @@ LL | 500 >= status_code && 600 < status_code; // Incorrect
= note: since `500` < `600`, the expression evaluates to false for any value of `status_code`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:64:5
--> $DIR/const_comparisons.rs:64:5
|
LL | 500 >= status_code && status_code > 600; // Incorrect
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -104,7 +104,7 @@ LL | 500 >= status_code && status_code > 600; // Incorrect
= note: since `500` < `600`, the expression evaluates to false for any value of `status_code`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:69:5
--> $DIR/const_comparisons.rs:69:5
|
LL | 500 >= status && 600 < status; // Incorrect
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -112,7 +112,7 @@ LL | 500 >= status && 600 < status; // Incorrect
= note: since `500` < `600`, the expression evaluates to false for any value of `status`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:70:5
--> $DIR/const_comparisons.rs:70:5
|
LL | 500 >= status && status > 600; // Incorrect
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -120,80 +120,80 @@ LL | 500 >= status && status > 600; // Incorrect
= note: since `500` < `600`, the expression evaluates to false for any value of `status`
error: right-hand side of `&&` operator has no effect
--> $DIR/double_const_comparisons.rs:73:5
--> $DIR/const_comparisons.rs:73:5
|
LL | status_code < 200 && status_code <= 299;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `if `status_code < 200` evaluates to true, status_code <= 299` will always evaluate to true as well
--> $DIR/double_const_comparisons.rs:73:23
--> $DIR/const_comparisons.rs:73:23
|
LL | status_code < 200 && status_code <= 299;
| ^^^^^^^^^^^^^^^^^^^^^
= note: `-D clippy::ineffective-double-const-comparisons` implied by `-D warnings`
= note: `-D clippy::redundant-comparisons` implied by `-D warnings`
error: left-hand side of `&&` operator has no effect
--> $DIR/double_const_comparisons.rs:74:5
--> $DIR/const_comparisons.rs:74:5
|
LL | status_code > 200 && status_code >= 299;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `if `status_code >= 299` evaluates to true, status_code > 200` will always evaluate to true as well
--> $DIR/double_const_comparisons.rs:74:5
--> $DIR/const_comparisons.rs:74:5
|
LL | status_code > 200 && status_code >= 299;
| ^^^^^^^^^^^^^^^^^^^^^
error: left-hand side of `&&` operator has no effect
--> $DIR/double_const_comparisons.rs:76:5
--> $DIR/const_comparisons.rs:76:5
|
LL | status_code >= 500 && status_code > 500; // Useless left
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well
--> $DIR/double_const_comparisons.rs:76:5
--> $DIR/const_comparisons.rs:76:5
|
LL | status_code >= 500 && status_code > 500; // Useless left
| ^^^^^^^^^^^^^^^^^^^^^^
error: right-hand side of `&&` operator has no effect
--> $DIR/double_const_comparisons.rs:77:5
--> $DIR/const_comparisons.rs:77:5
|
LL | status_code > 500 && status_code >= 500; // Useless right
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well
--> $DIR/double_const_comparisons.rs:77:23
--> $DIR/const_comparisons.rs:77:23
|
LL | status_code > 500 && status_code >= 500; // Useless right
| ^^^^^^^^^^^^^^^^^^^^^
error: left-hand side of `&&` operator has no effect
--> $DIR/double_const_comparisons.rs:78:5
--> $DIR/const_comparisons.rs:78:5
|
LL | status_code <= 500 && status_code < 500; // Useless left
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well
--> $DIR/double_const_comparisons.rs:78:5
--> $DIR/const_comparisons.rs:78:5
|
LL | status_code <= 500 && status_code < 500; // Useless left
| ^^^^^^^^^^^^^^^^^^^^^^
error: right-hand side of `&&` operator has no effect
--> $DIR/double_const_comparisons.rs:79:5
--> $DIR/const_comparisons.rs:79:5
|
LL | status_code < 500 && status_code <= 500; // Useless right
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well
--> $DIR/double_const_comparisons.rs:79:23
--> $DIR/const_comparisons.rs:79:23
|
LL | status_code < 500 && status_code <= 500; // Useless right
| ^^^^^^^^^^^^^^^^^^^^^
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:83:5
--> $DIR/const_comparisons.rs:83:5
|
LL | name < "Jennifer" && name > "Shannon";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -201,7 +201,7 @@ LL | name < "Jennifer" && name > "Shannon";
= note: since `"Jennifer"` < `"Shannon"`, the expression evaluates to false for any value of `name`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:86:5
--> $DIR/const_comparisons.rs:86:5
|
LL | numbers < [3, 4] && numbers > [5, 6];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -209,7 +209,7 @@ LL | numbers < [3, 4] && numbers > [5, 6];
= note: since `[3, 4]` < `[5, 6]`, the expression evaluates to false for any value of `numbers`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:89:5
--> $DIR/const_comparisons.rs:89:5
|
LL | letter < 'b' && letter > 'c';
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -217,7 +217,7 @@ LL | letter < 'b' && letter > 'c';
= note: since `'b'` < `'c'`, the expression evaluates to false for any value of `letter`
error: boolean expression will never evaluate to 'true'
--> $DIR/double_const_comparisons.rs:92:5
--> $DIR/const_comparisons.rs:92:5
|
LL | area < std::f32::consts::E && area > std::f32::consts::PI;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -5,8 +5,8 @@
#![allow(clippy::no_effect)]
#![allow(clippy::short_circuit_statement)]
#![allow(clippy::unnecessary_operation)]
#![allow(clippy::impossible_double_const_comparisons)]
#![allow(clippy::ineffective_double_const_comparisons)]
#![allow(clippy::impossible_comparisons)]
#![allow(clippy::redundant_comparisons)]
fn main() {
let x = 9_i32;

View File

@ -5,8 +5,8 @@
#![allow(clippy::no_effect)]
#![allow(clippy::short_circuit_statement)]
#![allow(clippy::unnecessary_operation)]
#![allow(clippy::impossible_double_const_comparisons)]
#![allow(clippy::ineffective_double_const_comparisons)]
#![allow(clippy::impossible_comparisons)]
#![allow(clippy::redundant_comparisons)]
fn main() {
let x = 9_i32;