Skip to content

Commit ec91164

Browse files
committed
rename lint to needless_match
and change its lint group to "complexity"
1 parent 750204e commit ec91164

12 files changed

+27
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3327,6 +3327,7 @@ Released 2018-09-13
33273327
[`needless_for_each`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_for_each
33283328
[`needless_late_init`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
33293329
[`needless_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
3330+
[`needless_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_match
33303331
[`needless_option_as_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
33313332
[`needless_pass_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
33323333
[`needless_question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
@@ -3348,7 +3349,6 @@ Released 2018-09-13
33483349
[`nonminimal_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
33493350
[`nonsensical_open_options`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonsensical_open_options
33503351
[`nonstandard_macro_braces`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
3351-
[`nop_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#nop_match
33523352
[`not_unsafe_ptr_arg_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref
33533353
[`octal_escapes`]: https://rust-lang.github.io/rust-clippy/master/index.html#octal_escapes
33543354
[`ok_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#ok_expect

clippy_lints/src/lib.register_all.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
134134
LintId::of(matches::MATCH_OVERLAPPING_ARM),
135135
LintId::of(matches::MATCH_REF_PATS),
136136
LintId::of(matches::MATCH_SINGLE_BINDING),
137-
LintId::of(matches::NOP_MATCH),
137+
LintId::of(matches::NEEDLESS_MATCH),
138138
LintId::of(matches::REDUNDANT_PATTERN_MATCHING),
139139
LintId::of(matches::SINGLE_MATCH),
140140
LintId::of(matches::WILDCARD_IN_OR_PATTERNS),

clippy_lints/src/lib.register_complexity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
3030
LintId::of(map_unit_fn::RESULT_MAP_UNIT_FN),
3131
LintId::of(matches::MATCH_AS_REF),
3232
LintId::of(matches::MATCH_SINGLE_BINDING),
33+
LintId::of(matches::NEEDLESS_MATCH),
3334
LintId::of(matches::WILDCARD_IN_OR_PATTERNS),
3435
LintId::of(methods::BIND_INSTEAD_OF_MAP),
3536
LintId::of(methods::CLONE_ON_COPY),

clippy_lints/src/lib.register_correctness.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ store.register_group(true, "clippy::correctness", Some("clippy_correctness"), ve
3737
LintId::of(loops::NEVER_LOOP),
3838
LintId::of(loops::WHILE_IMMUTABLE_CONDITION),
3939
LintId::of(match_str_case_mismatch::MATCH_STR_CASE_MISMATCH),
40-
LintId::of(matches::NOP_MATCH),
4140
LintId::of(mem_replace::MEM_REPLACE_WITH_UNINIT),
4241
LintId::of(methods::CLONE_DOUBLE_REF),
4342
LintId::of(methods::ITERATOR_STEP_BY_ZERO),

clippy_lints/src/lib.register_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ store.register_lints(&[
253253
matches::MATCH_SINGLE_BINDING,
254254
matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
255255
matches::MATCH_WILD_ERR_ARM,
256-
matches::NOP_MATCH,
256+
matches::NEEDLESS_MATCH,
257257
matches::REDUNDANT_PATTERN_MATCHING,
258258
matches::REST_PAT_IN_FULLY_BOUND_STRUCTS,
259259
matches::SINGLE_MATCH,

clippy_lints/src/matches/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod match_same_arms;
1616
mod match_single_binding;
1717
mod match_wild_enum;
1818
mod match_wild_err_arm;
19-
mod nop_match;
19+
mod needless_match;
2020
mod overlapping_arms;
2121
mod redundant_pattern_match;
2222
mod rest_pat_in_fully_bound_struct;
@@ -605,8 +605,8 @@ declare_clippy_lint! {
605605
/// }
606606
/// ```
607607
#[clippy::version = "1.61.0"]
608-
pub NOP_MATCH,
609-
correctness,
608+
pub NEEDLESS_MATCH,
609+
complexity,
610610
"`match` or match-like `if let` that are unnecessary"
611611
}
612612

@@ -643,7 +643,7 @@ impl_lint_pass!(Matches => [
643643
REDUNDANT_PATTERN_MATCHING,
644644
MATCH_LIKE_MATCHES_MACRO,
645645
MATCH_SAME_ARMS,
646-
NOP_MATCH,
646+
NEEDLESS_MATCH,
647647
]);
648648

649649
impl<'tcx> LateLintPass<'tcx> for Matches {
@@ -667,7 +667,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
667667
overlapping_arms::check(cx, ex, arms);
668668
match_wild_enum::check(cx, ex, arms);
669669
match_as_ref::check(cx, ex, arms, expr);
670-
nop_match::check_match(cx, ex, arms);
670+
needless_match::check_match(cx, ex, arms);
671671

672672
if self.infallible_destructuring_match_linted {
673673
self.infallible_destructuring_match_linted = false;
@@ -686,7 +686,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
686686
match_like_matches::check(cx, expr);
687687
}
688688
redundant_pattern_match::check(cx, expr);
689-
nop_match::check(cx, expr);
689+
needless_match::check(cx, expr);
690690
}
691691
}
692692

clippy_lints/src/matches/nop_match.rs renamed to clippy_lints/src/matches/needless_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::NOP_MATCH;
1+
use super::NEEDLESS_MATCH;
22
use clippy_utils::diagnostics::span_lint_and_sugg;
33
use clippy_utils::source::snippet_with_applicability;
44
use clippy_utils::ty::is_type_diagnostic_item;
@@ -30,7 +30,7 @@ pub(crate) fn check_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
3030
let mut applicability = Applicability::MachineApplicable;
3131
span_lint_and_sugg(
3232
cx,
33-
NOP_MATCH,
33+
NEEDLESS_MATCH,
3434
match_expr.span,
3535
"this match expression is unnecessary",
3636
"replace it with",
@@ -68,7 +68,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>) {
6868
let mut applicability = Applicability::MachineApplicable;
6969
span_lint_and_sugg(
7070
cx,
71-
NOP_MATCH,
71+
NEEDLESS_MATCH,
7272
ex.span,
7373
"this if-let expression is unnecessary",
7474
"replace it with",

tests/ui/manual_map_option.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn main() {
148148

149149
// #7077
150150
let s = &String::new();
151-
#[allow(clippy::nop_match)]
151+
#[allow(clippy::needless_match)]
152152
let _: Option<&str> = match Some(s) {
153153
Some(s) => Some(s),
154154
None => None,

tests/ui/manual_map_option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn main() {
214214

215215
// #7077
216216
let s = &String::new();
217-
#[allow(clippy::nop_match)]
217+
#[allow(clippy::needless_match)]
218218
let _: Option<&str> = match Some(s) {
219219
Some(s) => Some(s),
220220
None => None,

tests/ui/nop_match.fixed renamed to tests/ui/needless_match.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![warn(clippy::nop_match)]
2+
#![warn(clippy::needless_match)]
33
#![allow(clippy::manual_map)]
44
#![allow(dead_code)]
55

tests/ui/nop_match.rs renamed to tests/ui/needless_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![warn(clippy::nop_match)]
2+
#![warn(clippy::needless_match)]
33
#![allow(clippy::manual_map)]
44
#![allow(dead_code)]
55

tests/ui/nop_match.stderr renamed to tests/ui/needless_match.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this match expression is unnecessary
2-
--> $DIR/nop_match.rs:15:18
2+
--> $DIR/needless_match.rs:15:18
33
|
44
LL | let _: i32 = match x {
55
| __________________^
@@ -10,10 +10,10 @@ LL | | _ => x,
1010
LL | | };
1111
| |_____^ help: replace it with: `x`
1212
|
13-
= note: `-D clippy::nop-match` implied by `-D warnings`
13+
= note: `-D clippy::needless-match` implied by `-D warnings`
1414

1515
error: this match expression is unnecessary
16-
--> $DIR/nop_match.rs:24:21
16+
--> $DIR/needless_match.rs:24:21
1717
|
1818
LL | let _: Choice = match se {
1919
| _____________________^
@@ -25,7 +25,7 @@ LL | | };
2525
| |_____^ help: replace it with: `se`
2626

2727
error: this match expression is unnecessary
28-
--> $DIR/nop_match.rs:46:26
28+
--> $DIR/needless_match.rs:46:26
2929
|
3030
LL | let _: Option<i32> = match x {
3131
| __________________________^
@@ -35,7 +35,7 @@ LL | | };
3535
| |_____^ help: replace it with: `x`
3636

3737
error: this match expression is unnecessary
38-
--> $DIR/nop_match.rs:62:31
38+
--> $DIR/needless_match.rs:62:31
3939
|
4040
LL | let _: Result<i32, i32> = match Ok(1) {
4141
| _______________________________^
@@ -45,7 +45,7 @@ LL | | };
4545
| |_____^ help: replace it with: `Ok(1)`
4646

4747
error: this match expression is unnecessary
48-
--> $DIR/nop_match.rs:66:31
48+
--> $DIR/needless_match.rs:66:31
4949
|
5050
LL | let _: Result<i32, i32> = match func_ret_err(0_i32) {
5151
| _______________________________^
@@ -55,25 +55,25 @@ LL | | };
5555
| |_____^ help: replace it with: `func_ret_err(0_i32)`
5656

5757
error: this if-let expression is unnecessary
58-
--> $DIR/nop_match.rs:73:5
58+
--> $DIR/needless_match.rs:73:5
5959
|
6060
LL | if let Some(a) = Some(1) { Some(a) } else { None }
6161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `Some(1)`
6262

6363
error: this if-let expression is unnecessary
64-
--> $DIR/nop_match.rs:77:30
64+
--> $DIR/needless_match.rs:77:30
6565
|
6666
LL | let _: Result<(), i32> = if let Err(e) = x { Err(e) } else { x };
6767
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x`
6868

6969
error: this if-let expression is unnecessary
70-
--> $DIR/nop_match.rs:78:30
70+
--> $DIR/needless_match.rs:78:30
7171
|
7272
LL | let _: Result<(), i32> = if let Ok(val) = x { Ok(val) } else { x };
7373
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x`
7474

7575
error: this if-let expression is unnecessary
76-
--> $DIR/nop_match.rs:84:21
76+
--> $DIR/needless_match.rs:84:21
7777
|
7878
LL | let _: Choice = if let Choice::A = x {
7979
| _____________________^

0 commit comments

Comments
 (0)