mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Use infer_ctxt
This commit is contained in:
parent
45842e5131
commit
b2523afae4
4 changed files with 16 additions and 24 deletions
|
@ -1,11 +1,11 @@
|
|||
use rustc::hir::intravisit as visit;
|
||||
use rustc::hir::{self, *};
|
||||
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||
use rustc_typeck::expr_use_visitor::*;
|
||||
use rustc::ty::layout::LayoutOf;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::util::nodemap::HirIdSet;
|
||||
use rustc::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_typeck::expr_use_visitor::*;
|
||||
use syntax::source_map::Span;
|
||||
|
||||
use crate::utils::span_lint;
|
||||
|
@ -76,7 +76,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
|
|||
};
|
||||
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
ExprUseVisitor::new(&mut v, cx.tcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
|
||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||
ExprUseVisitor::new(&mut v, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
|
||||
});
|
||||
|
||||
for node in v.set {
|
||||
span_lint(
|
||||
|
|
|
@ -12,11 +12,11 @@ use rustc::{declare_lint_pass, declare_tool_lint};
|
|||
use crate::consts::{constant, Constant};
|
||||
use crate::utils::usage::mutated_variables;
|
||||
use crate::utils::{is_type_diagnostic_item, qpath_res, sext, sugg};
|
||||
use rustc_typeck::expr_use_visitor::*;
|
||||
use rustc::ty::subst::Subst;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_typeck::expr_use_visitor::*;
|
||||
use std::iter::{once, Iterator};
|
||||
use std::mem;
|
||||
use syntax::ast;
|
||||
|
@ -1678,14 +1678,9 @@ fn check_for_mutation(
|
|||
span_high: None,
|
||||
};
|
||||
let def_id = def_id::DefId::local(body.hir_id.owner);
|
||||
ExprUseVisitor::new(
|
||||
&mut delegate,
|
||||
cx.tcx,
|
||||
def_id,
|
||||
cx.param_env,
|
||||
cx.tables,
|
||||
)
|
||||
.walk_expr(body);
|
||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||
ExprUseVisitor::new(&mut delegate, &infcx, def_id, cx.param_env, cx.tables).walk_expr(body);
|
||||
});
|
||||
delegate.mutation_span()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ use matches::matches;
|
|||
use rustc::hir::intravisit::FnKind;
|
||||
use rustc::hir::*;
|
||||
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||
use rustc_typeck::expr_use_visitor as euv;
|
||||
use rustc::traits;
|
||||
use rustc::ty::{self, RegionKind, TypeFoldable};
|
||||
use rustc::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_typeck::expr_use_visitor as euv;
|
||||
use std::borrow::Cow;
|
||||
use syntax::ast::Attribute;
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
|
@ -134,8 +134,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
|||
..
|
||||
} = {
|
||||
let mut ctx = MovedVariablesCtxt::default();
|
||||
euv::ExprUseVisitor::new(&mut ctx, cx.tcx, fn_def_id, cx.param_env, cx.tables)
|
||||
.consume_body(body);
|
||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||
euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
|
||||
});
|
||||
ctx
|
||||
};
|
||||
|
||||
|
@ -342,4 +343,3 @@ impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
|
|||
|
||||
fn mutate(&mut self, _: &euv::Place<'tcx>) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use rustc::hir::def::Res;
|
||||
use rustc::hir::*;
|
||||
use rustc::lint::LateContext;
|
||||
use rustc_typeck::expr_use_visitor::*;
|
||||
use rustc::ty;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_typeck::expr_use_visitor::*;
|
||||
|
||||
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
|
||||
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
|
|||
skip: false,
|
||||
};
|
||||
let def_id = def_id::DefId::local(expr.hir_id.owner);
|
||||
ExprUseVisitor::new(
|
||||
&mut delegate,
|
||||
cx.tcx,
|
||||
def_id,
|
||||
cx.param_env,
|
||||
cx.tables,
|
||||
)
|
||||
.walk_expr(expr);
|
||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||
ExprUseVisitor::new(&mut delegate, &infcx, def_id, cx.param_env, cx.tables).walk_expr(expr);
|
||||
});
|
||||
|
||||
if delegate.skip {
|
||||
return None;
|
||||
|
|
Loading…
Reference in a new issue