Skip to content

Commit e58cfac

Browse files
committed
1 parent c24251b commit e58cfac

34 files changed

+200
-88
lines changed

clippy_lints/src/assign_ops.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
use crate::utils::{
2+
get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, trait_ref_of_method, SpanlessEq,
3+
};
4+
use crate::utils::{higher, sugg};
15
use if_chain::if_chain;
26
use rustc::declare_lint_pass;
3-
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
7+
use rustc::hir::map::Map;
48
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
59
use rustc_errors::Applicability;
610
use rustc_hir as hir;
11+
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
712
use rustc_session::declare_tool_lint;
813

9-
use crate::utils::{
10-
get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, trait_ref_of_method, SpanlessEq,
11-
};
12-
use crate::utils::{higher, sugg};
13-
1414
declare_clippy_lint! {
1515
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a`
1616
/// patterns.
@@ -246,14 +246,16 @@ struct ExprVisitor<'a, 'tcx> {
246246
}
247247

248248
impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
249+
type Map = Map<'tcx>;
250+
249251
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
250252
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(self.assignee, expr) {
251253
self.counter += 1;
252254
}
253255

254256
walk_expr(self, expr);
255257
}
256-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
258+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
257259
NestedVisitorMap::None
258260
}
259261
}

clippy_lints/src/block_in_if_condition.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::utils::*;
22
use matches::matches;
33
use rustc::declare_lint_pass;
4-
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
4+
use rustc::hir::map::Map;
55
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
6+
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
67
use rustc_hir::*;
78
use rustc_session::declare_tool_lint;
89

@@ -51,6 +52,8 @@ struct ExVisitor<'a, 'tcx> {
5152
}
5253

5354
impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
55+
type Map = Map<'tcx>;
56+
5457
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
5558
if let ExprKind::Closure(_, _, eid, _, _) = expr.kind {
5659
let body = self.cx.tcx.hir().body(eid);
@@ -62,7 +65,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
6265
}
6366
walk_expr(self, expr);
6467
}
65-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
68+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
6669
NestedVisitorMap::None
6770
}
6871
}

clippy_lints/src/booleans.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ use crate::utils::{
44
};
55
use if_chain::if_chain;
66
use rustc::declare_lint_pass;
7-
use rustc::hir::intravisit;
8-
use rustc::hir::intravisit::*;
7+
use rustc::hir::map::Map;
98
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
109
use rustc_errors::Applicability;
10+
use rustc_hir::intravisit;
11+
use rustc_hir::intravisit::*;
1112
use rustc_hir::*;
1213
use rustc_session::declare_tool_lint;
1314
use rustc_span::source_map::Span;
@@ -438,6 +439,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
438439
}
439440

440441
impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
442+
type Map = Map<'tcx>;
443+
441444
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
442445
if in_macro(e.span) {
443446
return;
@@ -456,7 +459,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
456459
_ => walk_expr(self, e),
457460
}
458461
}
459-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
462+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
460463
NestedVisitorMap::None
461464
}
462465
}
@@ -471,6 +474,8 @@ struct NotSimplificationVisitor<'a, 'tcx> {
471474
}
472475

473476
impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
477+
type Map = Map<'tcx>;
478+
474479
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
475480
if let ExprKind::Unary(UnOp::UnNot, inner) = &expr.kind {
476481
if let Some(suggestion) = simplify_not(self.cx, inner) {
@@ -488,7 +493,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
488493

489494
walk_expr(self, expr);
490495
}
491-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
496+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
492497
NestedVisitorMap::None
493498
}
494499
}

clippy_lints/src/cognitive_complexity.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! calculate cognitive complexity and warn about overly complex functions
22
3-
use rustc::hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
3+
use rustc::hir::map::Map;
44
use rustc::impl_lint_pass;
55
use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
6+
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
67
use rustc_hir::*;
78
use rustc_session::declare_tool_lint;
89
use rustc_span::source_map::Span;
@@ -141,6 +142,8 @@ struct CCHelper {
141142
}
142143

143144
impl<'tcx> Visitor<'tcx> for CCHelper {
145+
type Map = Map<'tcx>;
146+
144147
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
145148
walk_expr(self, e);
146149
match e.kind {
@@ -154,7 +157,7 @@ impl<'tcx> Visitor<'tcx> for CCHelper {
154157
_ => {},
155158
}
156159
}
157-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
160+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
158161
NestedVisitorMap::None
159162
}
160163
}

clippy_lints/src/entry.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ use crate::utils::{get_item_name, higher, match_type, paths, snippet, snippet_op
33
use crate::utils::{snippet_with_applicability, span_lint_and_then, walk_ptrs_ty};
44
use if_chain::if_chain;
55
use rustc::declare_lint_pass;
6-
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
6+
use rustc::hir::map::Map;
77
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
88
use rustc_errors::Applicability;
9+
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
910
use rustc_hir::*;
1011
use rustc_session::declare_tool_lint;
1112
use rustc_span::source_map::Span;
@@ -136,6 +137,8 @@ struct InsertVisitor<'a, 'tcx, 'b> {
136137
}
137138

138139
impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
140+
type Map = Map<'tcx>;
141+
139142
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
140143
if_chain! {
141144
if let ExprKind::MethodCall(ref path, _, ref params) = expr.kind;
@@ -179,7 +182,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
179182
walk_expr(self, expr);
180183
}
181184
}
182-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
185+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
183186
NestedVisitorMap::None
184187
}
185188
}

clippy_lints/src/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use rustc::hir::intravisit as visit;
21
use rustc::impl_lint_pass;
32
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
43
use rustc::ty::layout::LayoutOf;
54
use rustc::ty::{self, Ty};
5+
use rustc_hir::intravisit as visit;
66
use rustc_hir::HirIdSet;
77
use rustc_hir::{self, *};
88
use rustc_session::declare_tool_lint;

clippy_lints/src/eval_order_dependence.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use crate::utils::{get_parent_expr, span_lint, span_note_and_lint};
22
use if_chain::if_chain;
33
use rustc::declare_lint_pass;
4-
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
4+
use rustc::hir::map::Map;
55
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
66
use rustc::ty;
7+
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
78
use rustc_hir::*;
89
use rustc_session::declare_tool_lint;
910

@@ -124,6 +125,8 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
124125
}
125126

126127
impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
128+
type Map = Map<'tcx>;
129+
127130
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
128131
match e.kind {
129132
ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e),
@@ -156,7 +159,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
156159
fn visit_block(&mut self, _: &'tcx Block<'_>) {
157160
// don't continue over blocks, LateLintPass already does that
158161
}
159-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
162+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
160163
NestedVisitorMap::None
161164
}
162165
}
@@ -288,6 +291,8 @@ struct ReadVisitor<'a, 'tcx> {
288291
}
289292

290293
impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
294+
type Map = Map<'tcx>;
295+
291296
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
292297
if expr.hir_id == self.last_expr.hir_id {
293298
return;
@@ -337,7 +342,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
337342

338343
walk_expr(self, expr);
339344
}
340-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
345+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
341346
NestedVisitorMap::None
342347
}
343348
}

clippy_lints/src/fallible_impl_from.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::utils::paths::{BEGIN_PANIC, BEGIN_PANIC_FMT, FROM_TRAIT, OPTION, RESU
22
use crate::utils::{is_expn_of, match_def_path, method_chain_args, span_lint_and_then, walk_ptrs_ty};
33
use if_chain::if_chain;
44
use rustc::declare_lint_pass;
5+
use rustc::hir::map::Map;
56
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
67
use rustc::ty::{self, Ty};
78
use rustc_hir as hir;
@@ -47,7 +48,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
4748
}
4849

4950
fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef<'_>]) {
50-
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
51+
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
5152
use rustc_hir::*;
5253

5354
struct FindPanicUnwrap<'a, 'tcx> {
@@ -57,6 +58,8 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
5758
}
5859

5960
impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
61+
type Map = Map<'tcx>;
62+
6063
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
6164
// check for `begin_panic`
6265
if_chain! {
@@ -83,7 +86,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
8386
intravisit::walk_expr(self, expr);
8487
}
8588

86-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
89+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
8790
NestedVisitorMap::None
8891
}
8992
}

clippy_lints/src/functions.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::utils::{
44
type_is_unsafe_function,
55
};
66
use matches::matches;
7-
use rustc::hir::intravisit;
7+
use rustc::hir::map::Map;
88
use rustc::impl_lint_pass;
99
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
1010
use rustc::ty::{self, Ty};
1111
use rustc_data_structures::fx::FxHashSet;
1212
use rustc_errors::Applicability;
1313
use rustc_hir as hir;
14+
use rustc_hir::intravisit;
1415
use rustc_hir::{def::Res, def_id::DefId};
1516
use rustc_session::declare_tool_lint;
1617
use rustc_span::source_map::Span;
@@ -538,6 +539,8 @@ struct DerefVisitor<'a, 'tcx> {
538539
}
539540

540541
impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
542+
type Map = Map<'tcx>;
543+
541544
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
542545
match expr.kind {
543546
hir::ExprKind::Call(ref f, args) => {
@@ -566,7 +569,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
566569
intravisit::walk_expr(self, expr);
567570
}
568571

569-
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
572+
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
570573
intravisit::NestedVisitorMap::None
571574
}
572575
}
@@ -594,6 +597,8 @@ struct StaticMutVisitor<'a, 'tcx> {
594597
}
595598

596599
impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
600+
type Map = Map<'tcx>;
601+
597602
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
598603
use hir::ExprKind::*;
599604

@@ -627,7 +632,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
627632
}
628633
}
629634

630-
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
635+
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
631636
intravisit::NestedVisitorMap::None
632637
}
633638
}

clippy_lints/src/implicit_return.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use crate::utils::{
66
use if_chain::if_chain;
77
use rustc::{
88
declare_lint_pass,
9-
hir::intravisit::FnKind,
109
lint::{LateContext, LateLintPass, LintArray, LintPass},
1110
};
1211
use rustc_errors::Applicability;
12+
use rustc_hir::intravisit::FnKind;
1313
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, MatchSource, StmtKind};
1414
use rustc_session::declare_tool_lint;
1515
use rustc_span::source_map::Span;

clippy_lints/src/let_if_seq.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use crate::utils::{higher, qpath_res, snippet, span_lint_and_then};
22
use if_chain::if_chain;
33
use rustc::declare_lint_pass;
4-
use rustc::hir::intravisit;
4+
use rustc::hir::map::Map;
55
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
66
use rustc_errors::Applicability;
77
use rustc_hir as hir;
88
use rustc_hir::def::Res;
9+
use rustc_hir::intravisit;
910
use rustc_hir::BindingAnnotation;
1011
use rustc_session::declare_tool_lint;
1112

@@ -144,6 +145,8 @@ struct UsedVisitor<'a, 'tcx> {
144145
}
145146

146147
impl<'a, 'tcx> intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
148+
type Map = Map<'tcx>;
149+
147150
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
148151
if_chain! {
149152
if let hir::ExprKind::Path(ref qpath) = expr.kind;
@@ -156,7 +159,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
156159
}
157160
intravisit::walk_expr(self, expr);
158161
}
159-
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
162+
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
160163
intravisit::NestedVisitorMap::None
161164
}
162165
}

0 commit comments

Comments
 (0)