Skip to content

Commit b2523af

Browse files
committed
Use infer_ctxt
1 parent 45842e5 commit b2523af

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

clippy_lints/src/escape.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use rustc::hir::intravisit as visit;
22
use rustc::hir::{self, *};
33
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
4-
use rustc_typeck::expr_use_visitor::*;
54
use rustc::ty::layout::LayoutOf;
65
use rustc::ty::{self, Ty};
76
use rustc::util::nodemap::HirIdSet;
87
use rustc::{declare_tool_lint, impl_lint_pass};
8+
use rustc_typeck::expr_use_visitor::*;
99
use syntax::source_map::Span;
1010

1111
use crate::utils::span_lint;
@@ -76,7 +76,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
7676
};
7777

7878
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
79-
ExprUseVisitor::new(&mut v, cx.tcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
79+
cx.tcx.infer_ctxt().enter(|infcx| {
80+
ExprUseVisitor::new(&mut v, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
81+
});
8082

8183
for node in v.set {
8284
span_lint(

clippy_lints/src/loops.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use rustc::{declare_lint_pass, declare_tool_lint};
1212
use crate::consts::{constant, Constant};
1313
use crate::utils::usage::mutated_variables;
1414
use crate::utils::{is_type_diagnostic_item, qpath_res, sext, sugg};
15-
use rustc_typeck::expr_use_visitor::*;
1615
use rustc::ty::subst::Subst;
1716
use rustc::ty::{self, Ty};
1817
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1918
use rustc_errors::Applicability;
19+
use rustc_typeck::expr_use_visitor::*;
2020
use std::iter::{once, Iterator};
2121
use std::mem;
2222
use syntax::ast;
@@ -1678,14 +1678,9 @@ fn check_for_mutation(
16781678
span_high: None,
16791679
};
16801680
let def_id = def_id::DefId::local(body.hir_id.owner);
1681-
ExprUseVisitor::new(
1682-
&mut delegate,
1683-
cx.tcx,
1684-
def_id,
1685-
cx.param_env,
1686-
cx.tables,
1687-
)
1688-
.walk_expr(body);
1681+
cx.tcx.infer_ctxt().enter(|infcx| {
1682+
ExprUseVisitor::new(&mut delegate, &infcx, def_id, cx.param_env, cx.tables).walk_expr(body);
1683+
});
16891684
delegate.mutation_span()
16901685
}
16911686

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use matches::matches;
88
use rustc::hir::intravisit::FnKind;
99
use rustc::hir::*;
1010
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
11-
use rustc_typeck::expr_use_visitor as euv;
1211
use rustc::traits;
1312
use rustc::ty::{self, RegionKind, TypeFoldable};
1413
use rustc::{declare_lint_pass, declare_tool_lint};
1514
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1615
use rustc_errors::Applicability;
1716
use rustc_target::spec::abi::Abi;
17+
use rustc_typeck::expr_use_visitor as euv;
1818
use std::borrow::Cow;
1919
use syntax::ast::Attribute;
2020
use syntax::errors::DiagnosticBuilder;
@@ -134,8 +134,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
134134
..
135135
} = {
136136
let mut ctx = MovedVariablesCtxt::default();
137-
euv::ExprUseVisitor::new(&mut ctx, cx.tcx, fn_def_id, cx.param_env, cx.tables)
138-
.consume_body(body);
137+
cx.tcx.infer_ctxt().enter(|infcx| {
138+
euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
139+
});
139140
ctx
140141
};
141142

@@ -342,4 +343,3 @@ impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
342343

343344
fn mutate(&mut self, _: &euv::Place<'tcx>) {}
344345
}
345-

clippy_lints/src/utils/usage.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use rustc::hir::def::Res;
22
use rustc::hir::*;
33
use rustc::lint::LateContext;
4-
use rustc_typeck::expr_use_visitor::*;
54
use rustc::ty;
65
use rustc_data_structures::fx::FxHashSet;
6+
use rustc_typeck::expr_use_visitor::*;
77

88
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
99
pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tcx>) -> Option<FxHashSet<HirId>> {
@@ -12,14 +12,9 @@ pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tc
1212
skip: false,
1313
};
1414
let def_id = def_id::DefId::local(expr.hir_id.owner);
15-
ExprUseVisitor::new(
16-
&mut delegate,
17-
cx.tcx,
18-
def_id,
19-
cx.param_env,
20-
cx.tables,
21-
)
22-
.walk_expr(expr);
15+
cx.tcx.infer_ctxt().enter(|infcx| {
16+
ExprUseVisitor::new(&mut delegate, &infcx, def_id, cx.param_env, cx.tables).walk_expr(expr);
17+
});
2318

2419
if delegate.skip {
2520
return None;

0 commit comments

Comments
 (0)