This commit is contained in:
Yuki Okushi 2020-01-09 16:13:22 +09:00
parent c24251b5fd
commit e58cfac458
34 changed files with 202 additions and 90 deletions

View File

@ -1,15 +1,15 @@
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_session::declare_tool_lint;
use crate::utils::{
get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, trait_ref_of_method, SpanlessEq,
};
use crate::utils::{higher, sugg};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc_session::declare_tool_lint;
declare_clippy_lint! {
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a`
@ -246,6 +246,8 @@ struct ExprVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(self.assignee, expr) {
self.counter += 1;
@ -253,7 +255,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -1,8 +1,9 @@
use crate::utils::*;
use matches::matches;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
@ -51,6 +52,8 @@ struct ExVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
if let ExprKind::Closure(_, _, eid, _, _) = expr.kind {
let body = self.cx.tcx.hir().body(eid);
@ -62,7 +65,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
}
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -4,10 +4,11 @@
};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit;
use rustc::hir::intravisit::*;
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc_errors::Applicability;
use rustc_hir::intravisit;
use rustc_hir::intravisit::*;
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;
@ -438,6 +439,8 @@ fn bool_expr(&self, e: &'tcx Expr<'_>) {
}
impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
if in_macro(e.span) {
return;
@ -456,7 +459,7 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
_ => walk_expr(self, e),
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -471,6 +474,8 @@ struct NotSimplificationVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if let ExprKind::Unary(UnOp::UnNot, inner) = &expr.kind {
if let Some(suggestion) = simplify_not(self.cx, inner) {
@ -488,7 +493,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -1,8 +1,9 @@
//! calculate cognitive complexity and warn about overly complex functions
use rustc::hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::impl_lint_pass;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;
@ -141,6 +142,8 @@ struct CCHelper {
}
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 {
@ -154,7 +157,7 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
_ => {},
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -3,9 +3,10 @@
use crate::utils::{snippet_with_applicability, span_lint_and_then, walk_ptrs_ty};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;
@ -136,6 +137,8 @@ struct InsertVisitor<'a, 'tcx, 'b> {
}
impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if_chain! {
if let ExprKind::MethodCall(ref path, _, ref params) = expr.kind;
@ -179,7 +182,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr);
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -1,8 +1,8 @@
use rustc::hir::intravisit as visit;
use rustc::impl_lint_pass;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty::layout::LayoutOf;
use rustc::ty::{self, Ty};
use rustc_hir::intravisit as visit;
use rustc_hir::HirIdSet;
use rustc_hir::{self, *};
use rustc_session::declare_tool_lint;

View File

@ -1,9 +1,10 @@
use crate::utils::{get_parent_expr, span_lint, span_note_and_lint};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty;
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
@ -124,6 +125,8 @@ fn report_diverging_sub_expr(&mut self, e: &Expr<'_>) {
}
impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
match e.kind {
ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e),
@ -156,7 +159,7 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
fn visit_block(&mut self, _: &'tcx Block<'_>) {
// don't continue over blocks, LateLintPass already does that
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -288,6 +291,8 @@ struct ReadVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if expr.hir_id == self.last_expr.hir_id {
return;
@ -337,7 +342,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -2,6 +2,7 @@
use crate::utils::{is_expn_of, match_def_path, method_chain_args, span_lint_and_then, walk_ptrs_ty};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty::{self, Ty};
use rustc_hir as hir;
@ -47,7 +48,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>)
}
fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef<'_>]) {
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::*;
struct FindPanicUnwrap<'a, 'tcx> {
@ -57,6 +58,8 @@ struct FindPanicUnwrap<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
// check for `begin_panic`
if_chain! {
@ -83,7 +86,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
intravisit::walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -4,13 +4,14 @@
type_is_unsafe_function,
};
use matches::matches;
use rustc::hir::intravisit;
use rustc::hir::map::Map;
use rustc::impl_lint_pass;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::ty::{self, Ty};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::intravisit;
use rustc_hir::{def::Res, def_id::DefId};
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;
@ -538,6 +539,8 @@ struct DerefVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
match expr.kind {
hir::ExprKind::Call(ref f, args) => {
@ -566,7 +569,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
intravisit::walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::None
}
}
@ -594,6 +597,8 @@ struct StaticMutVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
use hir::ExprKind::*;
@ -627,7 +632,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::None
}
}

View File

@ -6,10 +6,10 @@
use if_chain::if_chain;
use rustc::{
declare_lint_pass,
hir::intravisit::FnKind,
lint::{LateContext, LateLintPass, LintArray, LintPass},
};
use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, MatchSource, StmtKind};
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;

View File

@ -1,11 +1,12 @@
use crate::utils::{higher, qpath_res, snippet, span_lint_and_then};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit;
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::intravisit;
use rustc_hir::BindingAnnotation;
use rustc_session::declare_tool_lint;
@ -144,6 +145,8 @@ struct UsedVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
if_chain! {
if let hir::ExprKind::Path(ref qpath) = expr.kind;
@ -156,7 +159,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
}
intravisit::walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::None
}
}

View File

@ -1,9 +1,10 @@
use matches::matches;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::*;
use rustc::hir::map::Map;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::*;
use rustc_hir::FunctionRetTy::Return;
use rustc_hir::*;
use rustc_session::declare_tool_lint;
@ -359,6 +360,8 @@ fn collect_anonymous_lifetimes(&mut self, qpath: &QPath<'_>, ty: &Ty<'_>) {
}
impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
self.record(&Some(*lifetime));
@ -398,7 +401,7 @@ fn visit_ty(&mut self, ty: &'tcx Ty<'_>) {
}
walk_ty(self, ty);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -453,6 +456,8 @@ struct LifetimeChecker {
}
impl<'tcx> Visitor<'tcx> for LifetimeChecker {
type Map = Map<'tcx>;
// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
self.map.remove(&lifetime.name.ident().name);
@ -468,7 +473,7 @@ fn visit_generic_param(&mut self, param: &'tcx GenericParam<'_>) {
walk_generic_param(self, param)
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -502,6 +507,8 @@ struct BodyLifetimeChecker {
}
impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker {
type Map = Map<'tcx>;
// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
if lifetime.name.ident().name != kw::Invalid && lifetime.name.ident().name != kw::StaticLifetime {
@ -509,7 +516,7 @@ fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -2,17 +2,18 @@
use if_chain::if_chain;
use itertools::Itertools;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_block, walk_expr, walk_pat, walk_stmt, NestedVisitorMap, Visitor};
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::middle::region;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id;
use rustc_hir::intravisit::{walk_block, walk_expr, walk_pat, walk_stmt, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
// use rustc::middle::region::CodeExtent;
use crate::consts::{constant, Constant};
use crate::utils::usage::mutated_variables;
use crate::utils::{is_type_diagnostic_item, qpath_res, same_tys, sext, sugg};
use rustc::hir::map::Map;
use rustc::ty::{self, Ty};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::Applicability;
@ -1706,6 +1707,8 @@ struct UsedVisitor {
}
impl<'tcx> Visitor<'tcx> for UsedVisitor {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if match_var(expr, self.var) {
self.used = true;
@ -1714,7 +1717,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -1726,6 +1729,8 @@ struct LocalUsedVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for LocalUsedVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if same_var(self.cx, expr, self.local) {
self.used = true;
@ -1734,7 +1739,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -1824,6 +1829,8 @@ fn check(&mut self, idx: &'tcx Expr<'_>, seqexpr: &'tcx Expr<'_>, expr: &'tcx Ex
}
impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if_chain! {
// a range index op
@ -1905,7 +1912,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
}
self.prefer_mutable = old;
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -1950,6 +1957,8 @@ struct VarUsedAfterLoopVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for VarUsedAfterLoopVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if self.past_while_let {
if Some(self.def_id) == var_def_id(self.cx, expr) {
@ -1960,7 +1969,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
}
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -2058,6 +2067,8 @@ struct IncrementVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if self.done {
return;
@ -2100,7 +2111,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
}
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -2117,6 +2128,8 @@ struct InitializeVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) {
// Look for declarations of the variable
if let StmtKind::Local(ref local) = stmt.kind {
@ -2190,7 +2203,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir())
}
}
@ -2285,6 +2298,8 @@ struct LoopNestVisitor {
}
impl<'tcx> Visitor<'tcx> for LoopNestVisitor {
type Map = Map<'tcx>;
fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) {
if stmt.hir_id == self.hir_id {
self.nesting = LookFurther;
@ -2324,7 +2339,7 @@ fn visit_pat(&mut self, pat: &'tcx Pat<'_>) {
walk_pat(self, pat)
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -2392,6 +2407,8 @@ struct HasBreakOrReturnVisitor {
}
impl<'a, 'tcx> Visitor<'tcx> for HasBreakOrReturnVisitor {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if self.has_break_or_return {
return;
@ -2408,7 +2425,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -2447,6 +2464,8 @@ fn insert_def_id(&mut self, ex: &'tcx Expr<'_>) {
}
impl<'a, 'tcx> Visitor<'tcx> for VarCollectorVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, ex: &'tcx Expr<'_>) {
match ex.kind {
ExprKind::Path(_) => self.insert_def_id(ex),
@ -2457,7 +2476,7 @@ fn visit_expr(&mut self, ex: &'tcx Expr<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -10,11 +10,12 @@
use if_chain::if_chain;
use matches::matches;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{self, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, Lint, LintArray, LintContext, LintPass};
use rustc::ty::{self, Predicate, Ty};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::intravisit::{self, Visitor};
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;
use rustc_span::symbol::{sym, Symbol, SymbolStr};
@ -1412,6 +1413,8 @@ struct FunCallFinder<'a, 'tcx> {
}
impl<'a, 'tcx> intravisit::Visitor<'tcx> for FunCallFinder<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
let call_found = match &expr.kind {
// ignore enum and struct constructors
@ -1429,7 +1432,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::None
}
}
@ -3188,6 +3191,8 @@ struct RetCallFinder {
}
impl<'tcx> intravisit::Visitor<'tcx> for RetCallFinder {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
if self.found {
return;
@ -3199,7 +3204,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::None
}
}

View File

@ -1,9 +1,10 @@
use crate::utils::{differing_macro_contexts, paths, snippet_with_applicability, span_lint_and_then};
use crate::utils::{is_copy, match_type};
use rustc::hir::intravisit::{walk_path, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::LateContext;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_path, NestedVisitorMap, Visitor};
use rustc_hir::{self, *};
use rustc_span::source_map::Span;
use rustc_span::symbol::Symbol;
@ -91,12 +92,14 @@ struct UnwrapVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
self.identifiers.insert(ident(path));
walk_path(self, path);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.cx.tcx.hir())
}
}
@ -108,6 +111,8 @@ struct MapExprVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for MapExprVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
if self.identifiers.contains(&ident(path)) {
self.found_identifier = true;
@ -116,7 +121,7 @@ fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
walk_path(self, path);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.cx.tcx.hir())
}
}

View File

@ -1,10 +1,11 @@
use crate::utils::paths;
use crate::utils::usage::mutated_variables;
use crate::utils::{match_qpath, match_trait_method, span_lint};
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::LateContext;
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use if_chain::if_chain;
@ -123,6 +124,8 @@ fn new(cx: &'a LateContext<'a, 'tcx>, arg_id: hir::HirId) -> ReturnVisitor<'a, '
}
impl<'a, 'tcx> Visitor<'tcx> for ReturnVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
if let hir::ExprKind::Ret(Some(expr)) = &expr.kind {
let (found_mapping, found_filtering) = check_expression(self.cx, self.arg_id, expr);
@ -133,7 +136,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -1,10 +1,10 @@
use if_chain::if_chain;
use matches::matches;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::FnKind;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty;
use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::source_map::{ExpnKind, Span};

View File

@ -1,8 +1,8 @@
use crate::utils::{has_drop, is_entrypoint_fn, span_lint, trait_ref_of_method};
use rustc::declare_lint_pass;
use rustc::hir::intravisit::FnKind;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintPass};
use rustc_hir as hir;
use rustc_hir::intravisit::FnKind;
use rustc_hir::{Body, Constness, FnDecl, HirId};
use rustc_mir::transform::qualify_min_const_fn::is_min_const_fn;
use rustc_session::declare_tool_lint;

View File

@ -1,9 +1,10 @@
use crate::utils::{higher, span_lint};
use rustc::declare_lint_pass;
use rustc::hir::intravisit;
use rustc::hir::map::Map;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::ty;
use rustc_hir as hir;
use rustc_hir::intravisit;
use rustc_session::declare_tool_lint;
declare_clippy_lint! {
@ -33,7 +34,7 @@ fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block<'_
}
fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ty: &'tcx hir::Ty<'_>) {
use rustc::hir::intravisit::Visitor;
use rustc_hir::intravisit::Visitor;
MutVisitor { cx }.visit_ty(ty);
}
@ -44,6 +45,8 @@ pub struct MutVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
if in_external_macro(self.cx.sess(), expr.span) {
return;
@ -105,7 +108,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) {
intravisit::walk_ty(self, ty);
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::None
}
}

View File

@ -1,9 +1,10 @@
use crate::utils::{is_direct_expn_of, span_lint};
use if_chain::if_chain;
use matches::matches;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, ty};
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, StmtKind, UnOp};
use rustc_session::declare_tool_lint;
use rustc_span::Span;
@ -127,6 +128,8 @@ fn expr_span(&self) -> Option<Span> {
}
impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
match expr.kind {
ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, _) => {
@ -150,7 +153,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr)
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir())
}
}

View File

@ -6,13 +6,13 @@
use if_chain::if_chain;
use matches::matches;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::FnKind;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::traits;
use rustc::traits::misc::can_type_implement_copy;
use rustc::ty::{self, RegionKind, TypeFoldable};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::{Span, Symbol};

View File

@ -5,7 +5,6 @@
use if_chain::if_chain;
use matches::matches;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::FnKind;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::mir::{
self, traversal,
@ -14,6 +13,7 @@
use rustc::ty::{self, fold::TypeVisitor, Ty};
use rustc_data_structures::{fx::FxHashMap, transitive_relation::TransitiveRelation};
use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;
use rustc_hir::{def_id, Body, FnDecl, HirId};
use rustc_index::bit_set::{BitSet, HybridBitSet};
use rustc_mir::dataflow::{

View File

@ -1,9 +1,9 @@
use crate::reexport::*;
use crate::utils::{contains_name, higher, iter_input_pats, snippet, span_lint_and_then};
use rustc::declare_lint_pass;
use rustc::hir::intravisit::FnKind;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::ty;
use rustc_hir::intravisit::FnKind;
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;

View File

@ -2,9 +2,10 @@
use crate::utils::{get_enclosing_block, match_qpath, span_lint_and_then, SpanlessEq};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_block, walk_expr, walk_stmt, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, Lint, LintArray, LintPass};
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_block, walk_expr, walk_stmt, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::symbol::Symbol;
@ -279,6 +280,8 @@ fn is_repeat_zero(expr: &Expr<'_>) -> bool {
}
impl<'a, 'tcx> Visitor<'tcx> for VectorInitializationVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) {
if self.initialization_found {
match stmt.kind {
@ -316,7 +319,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -1,9 +1,10 @@
use crate::utils::{get_trait_def_id, span_lint, trait_ref_of_method};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc_hir as hir;
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc_session::declare_tool_lint;
declare_clippy_lint! {
@ -185,6 +186,8 @@ struct BinaryExprVisitor {
}
impl<'a, 'tcx> Visitor<'tcx> for BinaryExprVisitor {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
match expr.kind {
hir::ExprKind::Binary(..)
@ -195,7 +198,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -3,13 +3,13 @@
use crate::utils::{is_copy, is_self_ty, snippet, span_lint_and_sugg};
use if_chain::if_chain;
use matches::matches;
use rustc::hir::intravisit::FnKind;
use rustc::impl_lint_pass;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::session::config::Config as SessionConfig;
use rustc::ty;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::intravisit::FnKind;
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::Span;

View File

@ -5,13 +5,14 @@
use std::collections::BTreeMap;
use if_chain::if_chain;
use rustc::hir::intravisit::{walk_body, walk_expr, walk_ty, FnKind, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::ty::layout::LayoutOf;
use rustc::ty::{self, InferTy, Ty, TyCtxt, TypeckTables};
use rustc::{declare_lint_pass, impl_lint_pass};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::intravisit::{walk_body, walk_expr, walk_ty, FnKind, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::hygiene::{ExpnKind, MacroKind};
@ -1493,6 +1494,8 @@ struct TypeComplexityVisitor {
}
impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
type Map = Map<'tcx>;
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) {
let (add_score, sub_nest) = match ty.kind {
// _, &x and *x have only small overhead; don't mess with nesting level
@ -1527,7 +1530,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) {
walk_ty(self, ty);
self.nest -= sub_nest;
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -2272,6 +2275,8 @@ fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
}
impl<'a, 'tcx> Visitor<'tcx> for ImplicitHasherTypeVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_ty(&mut self, t: &'tcx hir::Ty<'_>) {
if let Some(target) = ImplicitHasherType::new(self.cx, t) {
self.found.push(target);
@ -2280,7 +2285,7 @@ fn visit_ty(&mut self, t: &'tcx hir::Ty<'_>) {
walk_ty(self, t);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -2305,6 +2310,8 @@ fn new(cx: &'a LateContext<'a, 'tcx>, target: &'b ImplicitHasherType<'tcx>) -> S
}
impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
type Map = Map<'tcx>;
fn visit_body(&mut self, body: &'tcx Body<'_>) {
let prev_body = self.body;
self.body = self.cx.tcx.body_tables(body.id());
@ -2355,7 +2362,7 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
walk_expr(self, e);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir())
}
}

View File

@ -1,8 +1,9 @@
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_path, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc_hir::def::Res;
use rustc_hir::intravisit::{walk_path, NestedVisitorMap, Visitor};
use rustc_hir::{AssocItemKind, HirId, ImplItemKind, ImplItemRef, Item, ItemKind, Path};
use rustc_session::declare_tool_lint;
@ -86,6 +87,8 @@ struct UnusedSelfVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for UnusedSelfVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
if self.uses_self {
// This function already uses `self`
@ -97,7 +100,7 @@ fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
walk_path(self, path);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir())
}
}

View File

@ -1,11 +1,11 @@
use crate::utils::{higher::if_block, match_type, paths, span_lint_and_then, usage::is_potentially_mutated};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc_session::declare_tool_lint;
use crate::utils::{higher::if_block, match_type, paths, span_lint_and_then, usage::is_potentially_mutated};
use rustc::hir::intravisit::*;
use rustc_hir::intravisit::*;
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;
declare_clippy_lint! {
@ -136,6 +136,8 @@ fn visit_branch(&mut self, cond: &'tcx Expr<'_>, branch: &'tcx Expr<'_>, else_br
}
impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if let Some((cond, then, els)) = if_block(&expr) {
walk_expr(self, cond);
@ -179,7 +181,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir())
}
}

View File

@ -1,12 +1,13 @@
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{walk_item, walk_path, walk_ty, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::ty;
use rustc::ty::{DefIdTree, Ty};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{walk_item, walk_path, walk_ty, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::symbol::kw;
@ -84,6 +85,8 @@ struct TraitImplTyVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for TraitImplTyVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_ty(&mut self, t: &'tcx hir::Ty<'_>) {
let trait_ty = self.trait_type_walker.next();
let impl_ty = self.impl_type_walker.next();
@ -107,7 +110,7 @@ fn visit_ty(&mut self, t: &'tcx hir::Ty<'_>) {
walk_ty(self, t)
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
@ -223,6 +226,8 @@ struct UseSelfVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
if !path.segments.iter().any(|p| p.ident.span.is_dummy()) {
if path.segments.len() >= 2 {
@ -272,7 +277,7 @@ fn visit_item(&mut self, item: &'tcx Item<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.cx.tcx.hir())
}
}

View File

@ -3,11 +3,12 @@
use crate::utils::{get_attr, higher};
use rustc::declare_lint_pass;
use rustc::hir::intravisit::{NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::session::Session;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::intravisit::{NestedVisitorMap, Visitor};
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, Pat, PatKind, QPath, Stmt, StmtKind, TyKind};
use rustc_session::declare_tool_lint;
use syntax::ast::{Attribute, LitFloatType, LitKind};
@ -188,6 +189,8 @@ struct PrintVisitor {
}
impl<'tcx> Visitor<'tcx> for PrintVisitor {
type Map = Map<'tcx>;
#[allow(clippy::too_many_lines)]
fn visit_expr(&mut self, expr: &Expr<'_>) {
// handle if desugarings
@ -686,7 +689,7 @@ fn visit_stmt(&mut self, s: &Stmt<'_>) {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -3,13 +3,14 @@
walk_ptrs_ty,
};
use if_chain::if_chain;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, impl_lint_pass};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_session::declare_tool_lint;
use rustc_span::source_map::Span;
@ -239,6 +240,8 @@ struct LintCollector<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for LintCollector<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr);
}
@ -248,7 +251,7 @@ fn visit_path(&mut self, path: &'tcx Path<'_>, _: HirId) {
self.output.insert(path.segments[0].ident.name);
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.cx.tcx.hir())
}
}

View File

@ -25,7 +25,7 @@
use if_chain::if_chain;
use matches::matches;
use rustc::hir::intravisit::{NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::{LateContext, Level, Lint, LintContext};
use rustc::traits;
use rustc::traits::predicate_for_trait_def;
@ -39,6 +39,7 @@
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::intravisit::{NestedVisitorMap, Visitor};
use rustc_hir::Node;
use rustc_hir::*;
use rustc_span::hygiene::ExpnKind;
@ -455,12 +456,14 @@ struct ContainsName {
}
impl<'tcx> Visitor<'tcx> for ContainsName {
type Map = Map<'tcx>;
fn visit_name(&mut self, _: Span, name: Name) {
if self.name == name {
self.result = true;
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -1,6 +1,7 @@
use crate::utils::{get_pat_name, match_var, snippet};
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::map::Map;
use rustc::lint::LateContext;
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_span::source_map::Span;
use std::borrow::Cow;
@ -52,6 +53,8 @@ struct PtrCloneVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for PtrCloneVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if self.abort {
return;
@ -75,7 +78,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}