Skip to content

Commit 82bab19

Browse files
committed
Deprecate find_map lint
1 parent a22915b commit 82bab19

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
@@ -505,6 +505,10 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
505505
"clippy::panic_params",
506506
"this lint has been uplifted to rustc and is now called `panic_fmt`",
507507
);
508+
store.register_removed(
509+
"clippy::find_map",
510+
"this lint is replaced by `manual_find_map`, a more specific lint",
511+
);
508512
// end deprecated lints, do not remove this comment, it’s used in `update_lints`
509513

510514
// begin register lints, do not remove this comment, it’s used in `update_lints`
@@ -732,7 +736,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
732736
&methods::FILTER_MAP,
733737
&methods::FILTER_MAP_NEXT,
734738
&methods::FILTER_NEXT,
735-
&methods::FIND_MAP,
736739
&methods::FLAT_MAP_IDENTITY,
737740
&methods::FROM_ITER_INSTEAD_OF_COLLECT,
738741
&methods::GET_UNWRAP,
@@ -1333,7 +1336,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13331336
LintId::of(&matches::SINGLE_MATCH_ELSE),
13341337
LintId::of(&methods::FILTER_MAP),
13351338
LintId::of(&methods::FILTER_MAP_NEXT),
1336-
LintId::of(&methods::FIND_MAP),
13371339
LintId::of(&methods::INEFFICIENT_TO_STRING),
13381340
LintId::of(&methods::MAP_FLATTEN),
13391341
LintId::of(&methods::MAP_UNWRAP_OR),

clippy_lints/src/methods/mod.rs

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

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

0 commit comments

Comments
 (0)