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
{
// 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