rename lint to needless_match

and change its lint group to "complexity"
This commit is contained in:
J-ZhengLi 2022-03-10 09:44:25 +08:00
parent 750204e3e3
commit ec9116412a
12 changed files with 27 additions and 27 deletions

View File

@ -3327,6 +3327,7 @@ Released 2018-09-13
[`needless_for_each`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_for_each
[`needless_late_init`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
[`needless_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
[`needless_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_match
[`needless_option_as_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
[`needless_pass_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
[`needless_question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
@ -3348,7 +3349,6 @@ Released 2018-09-13
[`nonminimal_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
[`nonsensical_open_options`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonsensical_open_options
[`nonstandard_macro_braces`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
[`nop_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#nop_match
[`not_unsafe_ptr_arg_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref
[`octal_escapes`]: https://rust-lang.github.io/rust-clippy/master/index.html#octal_escapes
[`ok_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#ok_expect

View File

@ -134,7 +134,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
LintId::of(matches::MATCH_OVERLAPPING_ARM),
LintId::of(matches::MATCH_REF_PATS),
LintId::of(matches::MATCH_SINGLE_BINDING),
LintId::of(matches::NOP_MATCH),
LintId::of(matches::NEEDLESS_MATCH),
LintId::of(matches::REDUNDANT_PATTERN_MATCHING),
LintId::of(matches::SINGLE_MATCH),
LintId::of(matches::WILDCARD_IN_OR_PATTERNS),

View File

@ -30,6 +30,7 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
LintId::of(map_unit_fn::RESULT_MAP_UNIT_FN),
LintId::of(matches::MATCH_AS_REF),
LintId::of(matches::MATCH_SINGLE_BINDING),
LintId::of(matches::NEEDLESS_MATCH),
LintId::of(matches::WILDCARD_IN_OR_PATTERNS),
LintId::of(methods::BIND_INSTEAD_OF_MAP),
LintId::of(methods::CLONE_ON_COPY),

View File

@ -37,7 +37,6 @@ store.register_group(true, "clippy::correctness", Some("clippy_correctness"), ve
LintId::of(loops::NEVER_LOOP),
LintId::of(loops::WHILE_IMMUTABLE_CONDITION),
LintId::of(match_str_case_mismatch::MATCH_STR_CASE_MISMATCH),
LintId::of(matches::NOP_MATCH),
LintId::of(mem_replace::MEM_REPLACE_WITH_UNINIT),
LintId::of(methods::CLONE_DOUBLE_REF),
LintId::of(methods::ITERATOR_STEP_BY_ZERO),

View File

@ -253,7 +253,7 @@ store.register_lints(&[
matches::MATCH_SINGLE_BINDING,
matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
matches::MATCH_WILD_ERR_ARM,
matches::NOP_MATCH,
matches::NEEDLESS_MATCH,
matches::REDUNDANT_PATTERN_MATCHING,
matches::REST_PAT_IN_FULLY_BOUND_STRUCTS,
matches::SINGLE_MATCH,

View File

@ -16,7 +16,7 @@ mod match_same_arms;
mod match_single_binding;
mod match_wild_enum;
mod match_wild_err_arm;
mod nop_match;
mod needless_match;
mod overlapping_arms;
mod redundant_pattern_match;
mod rest_pat_in_fully_bound_struct;
@ -605,8 +605,8 @@ declare_clippy_lint! {
/// }
/// ```
#[clippy::version = "1.61.0"]
pub NOP_MATCH,
correctness,
pub NEEDLESS_MATCH,
complexity,
"`match` or match-like `if let` that are unnecessary"
}
@ -643,7 +643,7 @@ impl_lint_pass!(Matches => [
REDUNDANT_PATTERN_MATCHING,
MATCH_LIKE_MATCHES_MACRO,
MATCH_SAME_ARMS,
NOP_MATCH,
NEEDLESS_MATCH,
]);
impl<'tcx> LateLintPass<'tcx> for Matches {
@ -667,7 +667,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
overlapping_arms::check(cx, ex, arms);
match_wild_enum::check(cx, ex, arms);
match_as_ref::check(cx, ex, arms, expr);
nop_match::check_match(cx, ex, arms);
needless_match::check_match(cx, ex, arms);
if self.infallible_destructuring_match_linted {
self.infallible_destructuring_match_linted = false;
@ -686,7 +686,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
match_like_matches::check(cx, expr);
}
redundant_pattern_match::check(cx, expr);
nop_match::check(cx, expr);
needless_match::check(cx, expr);
}
}

View File

@ -1,4 +1,4 @@
use super::NOP_MATCH;
use super::NEEDLESS_MATCH;
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_type_diagnostic_item;
@ -30,7 +30,7 @@ pub(crate) fn check_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
let mut applicability = Applicability::MachineApplicable;
span_lint_and_sugg(
cx,
NOP_MATCH,
NEEDLESS_MATCH,
match_expr.span,
"this match expression is unnecessary",
"replace it with",
@ -68,7 +68,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>) {
let mut applicability = Applicability::MachineApplicable;
span_lint_and_sugg(
cx,
NOP_MATCH,
NEEDLESS_MATCH,
ex.span,
"this if-let expression is unnecessary",
"replace it with",

View File

@ -148,7 +148,7 @@ fn main() {
// #7077
let s = &String::new();
#[allow(clippy::nop_match)]
#[allow(clippy::needless_match)]
let _: Option<&str> = match Some(s) {
Some(s) => Some(s),
None => None,

View File

@ -214,7 +214,7 @@ fn main() {
// #7077
let s = &String::new();
#[allow(clippy::nop_match)]
#[allow(clippy::needless_match)]
let _: Option<&str> = match Some(s) {
Some(s) => Some(s),
None => None,

View File

@ -1,5 +1,5 @@
// run-rustfix
#![warn(clippy::nop_match)]
#![warn(clippy::needless_match)]
#![allow(clippy::manual_map)]
#![allow(dead_code)]

View File

@ -1,5 +1,5 @@
// run-rustfix
#![warn(clippy::nop_match)]
#![warn(clippy::needless_match)]
#![allow(clippy::manual_map)]
#![allow(dead_code)]

View File

@ -1,5 +1,5 @@
error: this match expression is unnecessary
--> $DIR/nop_match.rs:15:18
--> $DIR/needless_match.rs:15:18
|
LL | let _: i32 = match x {
| __________________^
@ -10,10 +10,10 @@ LL | | _ => x,
LL | | };
| |_____^ help: replace it with: `x`
|
= note: `-D clippy::nop-match` implied by `-D warnings`
= note: `-D clippy::needless-match` implied by `-D warnings`
error: this match expression is unnecessary
--> $DIR/nop_match.rs:24:21
--> $DIR/needless_match.rs:24:21
|
LL | let _: Choice = match se {
| _____________________^
@ -25,7 +25,7 @@ LL | | };
| |_____^ help: replace it with: `se`
error: this match expression is unnecessary
--> $DIR/nop_match.rs:46:26
--> $DIR/needless_match.rs:46:26
|
LL | let _: Option<i32> = match x {
| __________________________^
@ -35,7 +35,7 @@ LL | | };
| |_____^ help: replace it with: `x`
error: this match expression is unnecessary
--> $DIR/nop_match.rs:62:31
--> $DIR/needless_match.rs:62:31
|
LL | let _: Result<i32, i32> = match Ok(1) {
| _______________________________^
@ -45,7 +45,7 @@ LL | | };
| |_____^ help: replace it with: `Ok(1)`
error: this match expression is unnecessary
--> $DIR/nop_match.rs:66:31
--> $DIR/needless_match.rs:66:31
|
LL | let _: Result<i32, i32> = match func_ret_err(0_i32) {
| _______________________________^
@ -55,25 +55,25 @@ LL | | };
| |_____^ help: replace it with: `func_ret_err(0_i32)`
error: this if-let expression is unnecessary
--> $DIR/nop_match.rs:73:5
--> $DIR/needless_match.rs:73:5
|
LL | if let Some(a) = Some(1) { Some(a) } else { None }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `Some(1)`
error: this if-let expression is unnecessary
--> $DIR/nop_match.rs:77:30
--> $DIR/needless_match.rs:77:30
|
LL | let _: Result<(), i32> = if let Err(e) = x { Err(e) } else { x };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x`
error: this if-let expression is unnecessary
--> $DIR/nop_match.rs:78:30
--> $DIR/needless_match.rs:78:30
|
LL | let _: Result<(), i32> = if let Ok(val) = x { Ok(val) } else { x };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x`
error: this if-let expression is unnecessary
--> $DIR/nop_match.rs:84:21
--> $DIR/needless_match.rs:84:21
|
LL | let _: Choice = if let Choice::A = x {
| _____________________^