Skip to content

Commit 284c63e

Browse files
authored
Merge pull request #3281 from CYBAI/redundant-match
Add lint for redundant pattern matching for explicit return boolean
2 parents b0ab69f + 66ae3b1 commit 284c63e

10 files changed

+369
-145
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ All notable changes to this project will be documented in this file.
816816
[`redundant_closure_call`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#redundant_closure_call
817817
[`redundant_field_names`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#redundant_field_names
818818
[`redundant_pattern`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#redundant_pattern
819+
[`redundant_pattern_matching`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#redundant_pattern_matching
819820
[`ref_in_deref`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#ref_in_deref
820821
[`regex_macro`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#regex_macro
821822
[`replace_consts`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#replace_consts

clippy_lints/src/deprecated_lints.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ macro_rules! declare_deprecated_lint {
1616

1717
/// **What it does:** Nothing. This lint has been deprecated.
1818
///
19-
/// **Deprecation reason:** This used to check for `assert!(a == b)` and recommend
19+
/// **Deprecation reason:** This used to check for `assert!(a == b)` and recommend
2020
/// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011.
2121
declare_deprecated_lint! {
2222
pub SHOULD_ASSERT_EQ,
@@ -102,3 +102,13 @@ declare_deprecated_lint! {
102102
pub ASSIGN_OPS,
103103
"using compound assignment operators (e.g. `+=`) is harmless"
104104
}
105+
106+
/// **What it does:** Nothing. This lint has been deprecated.
107+
///
108+
/// **Deprecation reason:** The original rule will only lint for `if let`. After
109+
/// making it support to lint `match`, naming as `if let` is not suitable for it.
110+
/// So, this lint is deprecated.
111+
declare_deprecated_lint! {
112+
pub IF_LET_REDUNDANT_PATTERN_MATCHING,
113+
"this lint has been changed to redundant_pattern_matching"
114+
}

clippy_lints/src/if_let_redundant_pattern_matching.rs

Lines changed: 0 additions & 103 deletions
This file was deleted.

clippy_lints/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ pub mod formatting;
126126
pub mod functions;
127127
pub mod identity_conversion;
128128
pub mod identity_op;
129-
pub mod if_let_redundant_pattern_matching;
130129
pub mod if_not_else;
131130
pub mod indexing_slicing;
132131
pub mod infallible_destructuring_match;
@@ -180,6 +179,7 @@ pub mod ptr_offset_with_cast;
180179
pub mod question_mark;
181180
pub mod ranges;
182181
pub mod redundant_field_names;
182+
pub mod redundant_pattern_matching;
183183
pub mod reference;
184184
pub mod regex;
185185
pub mod replace_consts;
@@ -303,6 +303,10 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
303303
"assign_ops",
304304
"using compound assignment operators (e.g. `+=`) is harmless",
305305
);
306+
store.register_removed(
307+
"if_let_redundant_pattern_matching",
308+
"this lint has been changed to redundant_pattern_matching",
309+
);
306310
// end deprecated lints, do not remove this comment, it’s used in `update_lints`
307311

308312
reg.register_late_lint_pass(box serde_api::Serde);
@@ -402,7 +406,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
402406
reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
403407
reg.register_late_lint_pass(box missing_inline::MissingInline);
404408
reg.register_late_lint_pass(box ok_if_let::Pass);
405-
reg.register_late_lint_pass(box if_let_redundant_pattern_matching::Pass);
409+
reg.register_late_lint_pass(box redundant_pattern_matching::Pass);
406410
reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
407411
reg.register_early_lint_pass(box reference::Pass);
408412
reg.register_early_lint_pass(box reference::DerefPass);
@@ -565,7 +569,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
565569
functions::TOO_MANY_ARGUMENTS,
566570
identity_conversion::IDENTITY_CONVERSION,
567571
identity_op::IDENTITY_OP,
568-
if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
569572
indexing_slicing::OUT_OF_BOUNDS_INDEXING,
570573
infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
571574
infinite_iter::INFINITE_ITER,
@@ -680,6 +683,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
680683
ranges::RANGE_PLUS_ONE,
681684
ranges::RANGE_ZIP_WITH_LEN,
682685
redundant_field_names::REDUNDANT_FIELD_NAMES,
686+
redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
683687
reference::DEREF_ADDROF,
684688
reference::REF_IN_DEREF,
685689
regex::INVALID_REGEX,
@@ -749,7 +753,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
749753
excessive_precision::EXCESSIVE_PRECISION,
750754
formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
751755
formatting::SUSPICIOUS_ELSE_FORMATTING,
752-
if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
753756
infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
754757
len_zero::LEN_WITHOUT_IS_EMPTY,
755758
len_zero::LEN_ZERO,
@@ -800,6 +803,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
800803
ptr::PTR_ARG,
801804
question_mark::QUESTION_MARK,
802805
redundant_field_names::REDUNDANT_FIELD_NAMES,
806+
redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
803807
regex::REGEX_MACRO,
804808
regex::TRIVIAL_REGEX,
805809
returns::LET_AND_RETURN,

0 commit comments

Comments
 (0)