Skip to content

Commit 60a0537

Browse files
committed
move suspicious_map to its own module
1 parent 110dac7 commit 60a0537

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mod ok_expect;
1313
mod option_as_ref_deref;
1414
mod option_map_unwrap_or;
1515
mod skip_while_next;
16+
mod suspicious_map;
1617
mod unnecessary_filter_map;
1718
mod unnecessary_lazy_eval;
1819
mod unwrap_used;
@@ -1716,7 +1717,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
17161717
unnecessary_filter_map::lint(cx, expr, arg_lists[0]);
17171718
filter_map_identity::check(cx, expr, arg_lists[0], method_spans[0]);
17181719
},
1719-
["count", "map"] => lint_suspicious_map(cx, expr),
1720+
["count", "map"] => suspicious_map::check(cx, expr),
17201721
["assume_init"] => lint_maybe_uninit(cx, &arg_lists[0][0], expr),
17211722
["unwrap_or", arith @ ("checked_add" | "checked_sub" | "checked_mul")] => {
17221723
manual_saturating_arithmetic::lint(cx, expr, &arg_lists, &arith["checked_".len()..])
@@ -3574,17 +3575,6 @@ fn is_maybe_uninit_ty_valid(cx: &LateContext<'_>, ty: Ty<'_>) -> bool {
35743575
}
35753576
}
35763577

3577-
fn lint_suspicious_map(cx: &LateContext<'_>, expr: &hir::Expr<'_>) {
3578-
span_lint_and_help(
3579-
cx,
3580-
SUSPICIOUS_MAP,
3581-
expr.span,
3582-
"this call to `map()` won't have an effect on the call to `count()`",
3583-
None,
3584-
"make sure you did not confuse `map` with `filter` or `for_each`",
3585-
);
3586-
}
3587-
35883578
fn lint_map_collect(
35893579
cx: &LateContext<'_>,
35903580
expr: &hir::Expr<'_>,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use crate::utils::span_lint_and_help;
2+
use rustc_hir as hir;
3+
use rustc_lint::LateContext;
4+
5+
use super::SUSPICIOUS_MAP;
6+
7+
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>) {
8+
span_lint_and_help(
9+
cx,
10+
SUSPICIOUS_MAP,
11+
expr.span,
12+
"this call to `map()` won't have an effect on the call to `count()`",
13+
None,
14+
"make sure you did not confuse `map` with `filter` or `for_each`",
15+
);
16+
}

0 commit comments

Comments
 (0)