]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/mem_categorization.rs
Auto merge of #30341 - pnkfelix:call-site-scope, r=nikomatsakis
[rust.git] / src / librustc / middle / mem_categorization.rs
index d8031e3134d5c858831162175a49f93ce0a9ce3d..f869cac9236f6e710095d2a13048c33112c31334 100644 (file)
@@ -609,6 +609,8 @@ pub fn cat_def(&self,
                 note: NoteNone
             }))
           }
+
+          def::DefErr => panic!("DefErr in memory categorization")
         }
     }
 
@@ -1196,7 +1198,7 @@ fn cat_pattern_<F>(&self, cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F)
         (*op)(self, cmt.clone(), pat);
 
         let opt_def = if let Some(path_res) = self.tcx().def_map.borrow().get(&pat.id) {
-            if path_res.depth != 0 {
+            if path_res.depth != 0 || path_res.base_def == def::DefErr {
                 // Since patterns can be associated constants
                 // which are resolved during typeck, we might have
                 // some unresolved patterns reaching this stage
@@ -1261,7 +1263,7 @@ fn cat_pattern_<F>(&self, cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F)
                 _ => {
                     self.tcx().sess.span_bug(
                         pat.span,
-                        "enum pattern didn't resolve to enum or struct");
+                        &format!("enum pattern didn't resolve to enum or struct {:?}", opt_def));
                 }
             }
           }
@@ -1424,7 +1426,7 @@ pub fn freely_aliasable(&self, ctxt: &ty::ctxt<'tcx>)
                 NonAliasable
             }
 
-            Categorization::StaticItem(..) => {
+            Categorization::StaticItem => {
                 if self.mutbl.is_mutable() {
                     FreelyAliasable(AliasableStaticMut)
                 } else {