};
use if_chain::if_chain;
use matches::matches;
+use rustc::declare_lint_pass;
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_session::declare_tool_lint;
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;
cx: &LateContext<'a, 'tcx>,
kind: FnKind<'tcx>,
decl: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
span: Span,
hir_id: HirId,
) {
..
} = {
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
};
let fn_sig = cx.tcx.fn_sig(fn_def_id);
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);
- for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(&body.params).enumerate() {
+ for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(body.params).enumerate() {
// All spans generated from a proc-macro invocation are the same...
if span == input.span {
return;
impl MovedVariablesCtxt {
fn move_common(&mut self, cmt: &euv::Place<'_>) {
- let cmt = unwrap_downcast_or_interior(cmt);
-
- if let mc::Categorization::Local(vid) = cmt.cat {
+ if let euv::PlaceBase::Local(vid) = cmt.base {
self.moved_vars.insert(vid);
}
}
fn mutate(&mut self, _: &euv::Place<'tcx>) {}
}
-
-fn unwrap_downcast_or_interior<'a, 'tcx>(mut cmt: &'a euv::Place<'tcx>) -> euv::Place<'tcx> {
- loop {
- match cmt.cat {
- mc::Categorization::Downcast(ref c, _) | mc::Categorization::Interior(ref c, _) => {
- cmt = c;
- },
- _ => return (*cmt).clone(),
- }
- }
-}