Skip to content

Commit 9c39c02

Browse files
committed
Change lint type to 'complexity'
1 parent 5df84f2 commit 9c39c02

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

clippy_lints/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
657657
methods::OPTION_MAP_UNWRAP_OR,
658658
methods::OPTION_MAP_UNWRAP_OR_ELSE,
659659
methods::RESULT_MAP_UNWRAP_OR_ELSE,
660-
methods::SUSPICIOUS_MAP,
661660
misc::USED_UNDERSCORE_BINDING,
662661
misc_early::UNSEPARATED_LITERAL_SUFFIX,
663662
mut_mut::MUT_MUT,
@@ -801,6 +800,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
801800
methods::SHOULD_IMPLEMENT_TRAIT,
802801
methods::SINGLE_CHAR_PATTERN,
803802
methods::STRING_EXTEND_CHARS,
803+
methods::SUSPICIOUS_MAP,
804804
methods::TEMPORARY_CSTRING_AS_PTR,
805805
methods::UNNECESSARY_FILTER_MAP,
806806
methods::UNNECESSARY_FOLD,
@@ -1034,6 +1034,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
10341034
methods::FILTER_NEXT,
10351035
methods::FLAT_MAP_IDENTITY,
10361036
methods::SEARCH_IS_SOME,
1037+
methods::SUSPICIOUS_MAP,
10371038
methods::UNNECESSARY_FILTER_MAP,
10381039
methods::USELESS_ASREF,
10391040
misc::SHORT_CIRCUIT_STATEMENT,

clippy_lints/src/methods/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use syntax::ast;
1818
use syntax::source_map::Span;
1919
use syntax::symbol::LocalInternedString;
2020

21-
use crate::utils::paths;
2221
use crate::utils::sugg;
2322
use crate::utils::usage::mutated_variables;
2423
use crate::utils::{
@@ -28,6 +27,7 @@ use crate::utils::{
2827
snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint, span_lint_and_sugg,
2928
span_lint_and_then, span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth, SpanlessEq,
3029
};
30+
use crate::utils::{paths, span_help_and_lint};
3131

3232
declare_clippy_lint! {
3333
/// **What it does:** Checks for `.unwrap()` calls on `Option`s.
@@ -893,6 +893,7 @@ declare_clippy_lint! {
893893
/// **What it does:** Checks for calls to `map` followed by a `count`.
894894
///
895895
/// **Why is this bad?** It looks suspicious. Maybe `map` was confused with `filter`.
896+
/// If the `map` call is intentional, this should be rewritten.
896897
///
897898
/// **Known problems:** None
898899
///
@@ -902,7 +903,7 @@ declare_clippy_lint! {
902903
/// let _ = (0..3).map(|x| x + 2).count();
903904
/// ```
904905
pub SUSPICIOUS_MAP,
905-
pedantic,
906+
complexity,
906907
"suspicious usage of map"
907908
}
908909

@@ -2539,11 +2540,12 @@ fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: Ty<'_
25392540
}
25402541

25412542
fn lint_suspicious_map(cx: &LateContext<'_, '_>, expr: &hir::Expr) {
2542-
span_lint(
2543+
span_help_and_lint(
25432544
cx,
25442545
SUSPICIOUS_MAP,
25452546
expr.span,
2546-
"Make sure you did not confuse `map` with `filter`.",
2547+
"this call to `map()` won't have an effect on the call to `count()`",
2548+
"make sure you did not confuse `map` with `filter`",
25472549
);
25482550
}
25492551

src/lintlist/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ pub const ALL_LINTS: [Lint; 310] = [
17381738
},
17391739
Lint {
17401740
name: "suspicious_map",
1741-
group: "pedantic",
1741+
group: "complexity",
17421742
desc: "suspicious usage of map",
17431743
deprecation: None,
17441744
module: "methods",

tests/ui/suspicious_map.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
error: Make sure you did not confuse `map` with `filter`.
1+
error: this call to `map()` won't have an effect on the call to `count()`
22
--> $DIR/suspicious_map.rs:4:13
33
|
44
LL | let _ = (0..3).map(|x| x + 2).count();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::suspicious-map` implied by `-D warnings`
8+
= help: make sure you did not confuse `map` with `filter`
89

910
error: aborting due to previous error
1011

0 commit comments

Comments
 (0)