Skip to content

Commit 184694f

Browse files
committed
Deprecate find_map lint
1 parent 6dc6365 commit 184694f

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

clippy_lints/src/deprecated_lints.rs

+5
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,8 @@ declare_deprecated_lint! {
166166
pub PANIC_PARAMS,
167167
"this lint has been uplifted to rustc and is now called `panic_fmt`"
168168
}
169+
170+
declare_deprecated_lint! {
171+
pub FIND_MAP,
172+
"this lint is replaced by `manual_find_map`, a more specific lint"
173+
}

clippy_lints/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
504504
"clippy::panic_params",
505505
"this lint has been uplifted to rustc and is now called `panic_fmt`",
506506
);
507+
store.register_removed(
508+
"clippy::find_map",
509+
"this lint is replaced by `manual_find_map`, a more specific lint",
510+
);
507511
// end deprecated lints, do not remove this comment, it’s used in `update_lints`
508512

509513
// begin register lints, do not remove this comment, it’s used in `update_lints`
@@ -731,7 +735,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
731735
&methods::FILTER_MAP,
732736
&methods::FILTER_MAP_NEXT,
733737
&methods::FILTER_NEXT,
734-
&methods::FIND_MAP,
735738
&methods::FLAT_MAP_IDENTITY,
736739
&methods::FROM_ITER_INSTEAD_OF_COLLECT,
737740
&methods::GET_UNWRAP,
@@ -1329,7 +1332,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13291332
LintId::of(&matches::SINGLE_MATCH_ELSE),
13301333
LintId::of(&methods::FILTER_MAP),
13311334
LintId::of(&methods::FILTER_MAP_NEXT),
1332-
LintId::of(&methods::FIND_MAP),
13331335
LintId::of(&methods::INEFFICIENT_TO_STRING),
13341336
LintId::of(&methods::MAP_FLATTEN),
13351337
LintId::of(&methods::MAP_UNWRAP_OR),

clippy_lints/src/methods/mod.rs

-23
Original file line numberDiff line numberDiff line change
@@ -546,28 +546,6 @@ declare_clippy_lint! {
546546
"call to `flat_map` where `flatten` is sufficient"
547547
}
548548

549-
declare_clippy_lint! {
550-
/// **What it does:** Checks for usage of `_.find(_).map(_)`.
551-
///
552-
/// **Why is this bad?** Readability, this can be written more concisely as
553-
/// `_.find_map(_)`.
554-
///
555-
/// **Known problems:** Often requires a condition + Option/Iterator creation
556-
/// inside the closure.
557-
///
558-
/// **Example:**
559-
/// ```rust
560-
/// (0..3).find(|x| *x == 2).map(|x| x * 2);
561-
/// ```
562-
/// Can be written as
563-
/// ```rust
564-
/// (0..3).find_map(|x| if x == 2 { Some(x * 2) } else { None });
565-
/// ```
566-
pub FIND_MAP,
567-
pedantic,
568-
"using a combination of `find` and `map` can usually be written as a single method call"
569-
}
570-
571549
declare_clippy_lint! {
572550
/// **What it does:** Checks for an iterator or string search (such as `find()`,
573551
/// `position()`, or `rposition()`) followed by a call to `is_some()`.
@@ -1499,7 +1477,6 @@ impl_lint_pass!(Methods => [
14991477
MANUAL_FIND_MAP,
15001478
FILTER_MAP_NEXT,
15011479
FLAT_MAP_IDENTITY,
1502-
FIND_MAP,
15031480
MAP_FLATTEN,
15041481
ITERATOR_STEP_BY_ZERO,
15051482
ITER_NEXT_SLICE,

0 commit comments

Comments
 (0)