mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Change lint type to 'complexity'
This commit is contained in:
parent
5df84f2192
commit
9c39c02b75
4 changed files with 11 additions and 7 deletions
|
@ -657,7 +657,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
methods::OPTION_MAP_UNWRAP_OR,
|
||||
methods::OPTION_MAP_UNWRAP_OR_ELSE,
|
||||
methods::RESULT_MAP_UNWRAP_OR_ELSE,
|
||||
methods::SUSPICIOUS_MAP,
|
||||
misc::USED_UNDERSCORE_BINDING,
|
||||
misc_early::UNSEPARATED_LITERAL_SUFFIX,
|
||||
mut_mut::MUT_MUT,
|
||||
|
@ -801,6 +800,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
methods::SHOULD_IMPLEMENT_TRAIT,
|
||||
methods::SINGLE_CHAR_PATTERN,
|
||||
methods::STRING_EXTEND_CHARS,
|
||||
methods::SUSPICIOUS_MAP,
|
||||
methods::TEMPORARY_CSTRING_AS_PTR,
|
||||
methods::UNNECESSARY_FILTER_MAP,
|
||||
methods::UNNECESSARY_FOLD,
|
||||
|
@ -1034,6 +1034,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
methods::FILTER_NEXT,
|
||||
methods::FLAT_MAP_IDENTITY,
|
||||
methods::SEARCH_IS_SOME,
|
||||
methods::SUSPICIOUS_MAP,
|
||||
methods::UNNECESSARY_FILTER_MAP,
|
||||
methods::USELESS_ASREF,
|
||||
misc::SHORT_CIRCUIT_STATEMENT,
|
||||
|
|
|
@ -18,7 +18,6 @@ use syntax::ast;
|
|||
use syntax::source_map::Span;
|
||||
use syntax::symbol::LocalInternedString;
|
||||
|
||||
use crate::utils::paths;
|
||||
use crate::utils::sugg;
|
||||
use crate::utils::usage::mutated_variables;
|
||||
use crate::utils::{
|
||||
|
@ -28,6 +27,7 @@ use crate::utils::{
|
|||
snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint, span_lint_and_sugg,
|
||||
span_lint_and_then, span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth, SpanlessEq,
|
||||
};
|
||||
use crate::utils::{paths, span_help_and_lint};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for `.unwrap()` calls on `Option`s.
|
||||
|
@ -893,6 +893,7 @@ declare_clippy_lint! {
|
|||
/// **What it does:** Checks for calls to `map` followed by a `count`.
|
||||
///
|
||||
/// **Why is this bad?** It looks suspicious. Maybe `map` was confused with `filter`.
|
||||
/// If the `map` call is intentional, this should be rewritten.
|
||||
///
|
||||
/// **Known problems:** None
|
||||
///
|
||||
|
@ -902,7 +903,7 @@ declare_clippy_lint! {
|
|||
/// let _ = (0..3).map(|x| x + 2).count();
|
||||
/// ```
|
||||
pub SUSPICIOUS_MAP,
|
||||
pedantic,
|
||||
complexity,
|
||||
"suspicious usage of map"
|
||||
}
|
||||
|
||||
|
@ -2539,11 +2540,12 @@ fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: Ty<'_
|
|||
}
|
||||
|
||||
fn lint_suspicious_map(cx: &LateContext<'_, '_>, expr: &hir::Expr) {
|
||||
span_lint(
|
||||
span_help_and_lint(
|
||||
cx,
|
||||
SUSPICIOUS_MAP,
|
||||
expr.span,
|
||||
"Make sure you did not confuse `map` with `filter`.",
|
||||
"this call to `map()` won't have an effect on the call to `count()`",
|
||||
"make sure you did not confuse `map` with `filter`",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1738,7 +1738,7 @@ pub const ALL_LINTS: [Lint; 310] = [
|
|||
},
|
||||
Lint {
|
||||
name: "suspicious_map",
|
||||
group: "pedantic",
|
||||
group: "complexity",
|
||||
desc: "suspicious usage of map",
|
||||
deprecation: None,
|
||||
module: "methods",
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
error: Make sure you did not confuse `map` with `filter`.
|
||||
error: this call to `map()` won't have an effect on the call to `count()`
|
||||
--> $DIR/suspicious_map.rs:4:13
|
||||
|
|
||||
LL | let _ = (0..3).map(|x| x + 2).count();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::suspicious-map` implied by `-D warnings`
|
||||
= help: make sure you did not confuse `map` with `filter`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
Loading…
Reference in a new issue