//! calculate cognitive complexity and warn about overly complex functions
-use rustc::hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
-use rustc::hir::*;
-use rustc::impl_lint_pass;
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
-use rustc_session::declare_tool_lint;
-use syntax::ast::Attribute;
-use syntax::source_map::Span;
-use syntax_pos::BytePos;
+use rustc::hir::map::Map;
+use rustc_ast::ast::Attribute;
+use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
+use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId};
+use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_session::{declare_tool_lint, impl_lint_pass};
+use rustc_span::source_map::Span;
+use rustc_span::BytePos;
-use crate::utils::{match_type, paths, snippet_opt, span_help_and_lint, LimitStack};
+use crate::utils::{match_type, paths, snippet_opt, span_lint_and_help, LimitStack};
declare_clippy_lint! {
/// **What it does:** Checks for methods with high cognitive complexity.
&mut self,
cx: &'a LateContext<'a, 'tcx>,
kind: FnKind<'tcx>,
- decl: &'tcx FnDecl,
+ decl: &'tcx FnDecl<'_>,
body: &'tcx Body<'_>,
body_span: Span,
) {
},
};
- span_help_and_lint(
+ span_lint_and_help(
cx,
COGNITIVE_COMPLEXITY,
fn_span,
&mut self,
cx: &LateContext<'a, 'tcx>,
kind: FnKind<'tcx>,
- decl: &'tcx FnDecl,
+ decl: &'tcx FnDecl<'_>,
body: &'tcx Body<'_>,
span: Span,
hir_id: HirId,
}
impl<'tcx> Visitor<'tcx> for CCHelper {
+ type Map = Map<'tcx>;
+
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
walk_expr(self, e);
match e.kind {
_ => {},
}
}
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
}
}