//! normal visitor, which just walks the entire body in one shot, the
//! `ExprUseVisitor` determines how expressions are being used.
-pub use self::MutateMode::*;
pub use self::LoanCause::*;
pub use self::ConsumeMode::*;
pub use self::MoveReason::*;
use self::TrackMatchMode::*;
use self::OverloadedCallType::*;
-use middle::{def, pat_util};
+use middle::pat_util;
+use middle::def::Def;
use middle::def_id::{DefId};
use middle::infer;
use middle::mem_categorization as mc;
}
impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
- pub fn new(delegate: &'d mut (Delegate<'tcx>),
+ pub fn new(delegate: &'d mut (Delegate<'tcx>+'d),
typer: &'t infer::InferCtxt<'a, 'tcx>)
-> ExprUseVisitor<'d,'t,'a,'tcx> where 'tcx:'a+'d
{
self.consume_expr(&*output.expr);
} else {
self.mutate_expr(expr, &*output.expr,
- if output.is_rw { WriteAndRead } else { JustWrite });
+ if output.is_rw {
+ MutateMode::WriteAndRead
+ } else {
+ MutateMode::JustWrite
+ });
}
}
}
}
hir::ExprAssign(ref lhs, ref rhs) => {
- self.mutate_expr(expr, &**lhs, JustWrite);
+ self.mutate_expr(expr, &**lhs, MutateMode::JustWrite);
self.consume_expr(&**rhs);
}
assert!(::rustc_front::util::is_by_value_binop(op.node));
if !self.walk_overloaded_operator(expr, lhs, vec![rhs], PassArgs::ByValue) {
- self.mutate_expr(expr, &**lhs, WriteAndRead);
+ self.mutate_expr(expr, &**lhs, MutateMode::WriteAndRead);
self.consume_expr(&**rhs);
}
}
let def = def_map.borrow().get(&pat.id).unwrap().full_def();
match mc.cat_def(pat.id, pat.span, pat_ty, def) {
Ok(binding_cmt) => {
- delegate.mutate(pat.id, pat.span, binding_cmt, Init);
+ delegate.mutate(pat.id, pat.span, binding_cmt, MutateMode::Init);
}
Err(_) => { }
}
// struct or enum pattern.
}
- Some(def::DefVariant(enum_did, variant_did, _is_struct)) => {
+ Some(Def::Variant(enum_did, variant_did)) => {
let downcast_cmt =
if tcx.lookup_adt_def(enum_did).is_univariant() {
cmt_pat
delegate.matched_pat(pat, downcast_cmt, match_mode);
}
- Some(def::DefStruct(..)) | Some(def::DefTy(_, false)) => {
+ Some(Def::Struct(..)) | Some(Def::TyAlias(..)) => {
// A struct (in either the value or type
// namespace; we encounter the former on
// e.g. patterns for unit structs).
delegate.matched_pat(pat, cmt_pat, match_mode);
}
- Some(def::DefConst(..)) |
- Some(def::DefAssociatedConst(..)) |
- Some(def::DefLocal(..)) => {
+ Some(Def::Const(..)) |
+ Some(Def::AssociatedConst(..)) |
+ Some(Def::Local(..)) => {
// This is a leaf (i.e. identifier binding
// or constant value to match); thus no
// `matched_pat` call.
}
- Some(def @ def::DefTy(_, true)) => {
- // An enum's type -- should never be in a
- // pattern.
-
- if !tcx.sess.has_errors() {
- let msg = format!("Pattern has unexpected type: {:?} and type {:?}",
- def,
- cmt_pat.ty);
- tcx.sess.span_bug(pat.span, &msg)
- }
- }
-
Some(def) => {
- // Remaining cases are e.g. DefFn, to
+ // An enum type should never be in a pattern.
+ // Remaining cases are e.g. Def::Fn, to
// which identifiers within patterns
// should not resolve. However, we do
// encouter this when using the
fn cat_captured_var(&mut self,
closure_id: ast::NodeId,
closure_span: Span,
- upvar_def: def::Def)
+ upvar_def: Def)
-> mc::McResult<mc::cmt<'tcx>> {
// Create the cmt for the variable being borrowed, from the
// caller's perspective