]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/trans/_match.rs
track, for each upvar, its index in list of upvars
[rust.git] / src / librustc_trans / trans / _match.rs
index 57bac4d4f81bb6044b85f79cc406b72b6a5e8a19..c6866004df949254f515bac2b5d81b2154c9e845 100644 (file)
 use std::cmp::Ordering;
 use std::fmt;
 use std::rc::Rc;
-use syntax::ast;
-use syntax::ast::{DUMMY_NODE_ID, NodeId};
+use rustc_front::hir;
+use syntax::ast::{self, DUMMY_NODE_ID, NodeId};
 use syntax::codemap::Span;
-use syntax::fold::Folder;
+use rustc_front::fold::Folder;
 use syntax::ptr::P;
 
 #[derive(Copy, Clone, Debug)]
-struct ConstantExpr<'a>(&'a ast::Expr);
+struct ConstantExpr<'a>(&'a hir::Expr);
 
 impl<'a> ConstantExpr<'a> {
     fn eq(self, other: ConstantExpr<'a>, tcx: &ty::ctxt) -> bool {
@@ -379,7 +379,7 @@ pub struct BindingInfo<'tcx> {
 
 struct ArmData<'p, 'blk, 'tcx: 'blk> {
     bodycx: Block<'blk, 'tcx>,
-    arm: &'p ast::Arm,
+    arm: &'p hir::Arm,
     bindings_map: BindingsMap<'tcx>
 }
 
@@ -388,7 +388,7 @@ struct ArmData<'p, 'blk, 'tcx: 'blk> {
 /// As we proceed `bound_ptrs` are filled with pointers to values to be bound,
 /// these pointers are stored in llmatch variables just before executing `data` arm.
 struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> {
-    pats: Vec<&'p ast::Pat>,
+    pats: Vec<&'p hir::Pat>,
     data: &'a ArmData<'p, 'blk, 'tcx>,
     bound_ptrs: Vec<(ast::Ident, ValueRef)>,
     // Thread along renamings done by the check_match::StaticInliner, so we can
@@ -410,7 +410,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 fn has_nested_bindings(m: &[Match], col: usize) -> bool {
     for br in m {
         match br.pats[col].node {
-            ast::PatIdent(_, _, Some(_)) => return true,
+            hir::PatIdent(_, _, Some(_)) => return true,
             _ => ()
         }
     }
@@ -463,7 +463,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         let mut pat = br.pats[col];
         loop {
             pat = match pat.node {
-                ast::PatIdent(_, ref path, Some(ref inner)) => {
+                hir::PatIdent(_, ref path, Some(ref inner)) => {
                     bound_ptrs.push((path.node, val.val));
                     &**inner
                 },
@@ -489,7 +489,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
                                           val: MatchInput,
                                           mut e: F)
                                           -> Vec<Match<'a, 'p, 'blk, 'tcx>> where
-    F: FnMut(&[&'p ast::Pat]) -> Option<Vec<&'p ast::Pat>>,
+    F: FnMut(&[&'p hir::Pat]) -> Option<Vec<&'p hir::Pat>>,
 {
     debug!("enter_match(bcx={}, m={:?}, col={}, val={})",
            bcx.to_str(),
@@ -503,13 +503,13 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
             let this = br.pats[col];
             let mut bound_ptrs = br.bound_ptrs.clone();
             match this.node {
-                ast::PatIdent(_, ref path, None) => {
+                hir::PatIdent(_, ref path, None) => {
                     if pat_is_binding(dm, &*this) {
                         bound_ptrs.push((path.node, val.val));
                     }
                 }
-                ast::PatVec(ref before, Some(ref slice), ref after) => {
-                    if let ast::PatIdent(_, ref path, None) = slice.node {
+                hir::PatVec(ref before, Some(ref slice), ref after) => {
+                    if let hir::PatIdent(_, ref path, None) = slice.node {
                         let subslice_val = bind_subslice_pat(
                             bcx, this.id, val,
                             before.len(), after.len());
@@ -648,10 +648,10 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         };
 
         let opt = match cur.node {
-            ast::PatLit(ref l) => {
+            hir::PatLit(ref l) => {
                 ConstantValue(ConstantExpr(&**l), debug_loc)
             }
-            ast::PatIdent(..) | ast::PatEnum(..) | ast::PatStruct(..) => {
+            hir::PatIdent(..) | hir::PatEnum(..) | hir::PatStruct(..) => {
                 // This is either an enum variant or a variable binding.
                 let opt_def = tcx.def_map.borrow().get(&cur.id).map(|d| d.full_def());
                 match opt_def {
@@ -665,13 +665,13 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                     _ => continue
                 }
             }
-            ast::PatRange(ref l1, ref l2) => {
+            hir::PatRange(ref l1, ref l2) => {
                 ConstantRange(ConstantExpr(&**l1), ConstantExpr(&**l2), debug_loc)
             }
-            ast::PatVec(ref before, None, ref after) => {
+            hir::PatVec(ref before, None, ref after) => {
                 SliceLengthEqual(before.len() + after.len(), debug_loc)
             }
-            ast::PatVec(ref before, Some(_), ref after) => {
+            hir::PatVec(ref before, Some(_), ref after) => {
                 SliceLengthGreaterOrEqual(before.len(), after.len(), debug_loc)
             }
             _ => continue
@@ -770,25 +770,25 @@ macro_rules! any_pat {
 }
 
 fn any_uniq_pat(m: &[Match], col: usize) -> bool {
-    any_pat!(m, col, ast::PatBox(_))
+    any_pat!(m, col, hir::PatBox(_))
 }
 
 fn any_region_pat(m: &[Match], col: usize) -> bool {
-    any_pat!(m, col, ast::PatRegion(..))
+    any_pat!(m, col, hir::PatRegion(..))
 }
 
 fn any_irrefutable_adt_pat(tcx: &ty::ctxt, m: &[Match], col: usize) -> bool {
     m.iter().any(|br| {
         let pat = br.pats[col];
         match pat.node {
-            ast::PatTup(_) => true,
-            ast::PatStruct(..) => {
+            hir::PatTup(_) => true,
+            hir::PatStruct(..) => {
                 match tcx.def_map.borrow().get(&pat.id).map(|d| d.full_def()) {
                     Some(def::DefVariant(..)) => false,
                     _ => true,
                 }
             }
-            ast::PatEnum(..) | ast::PatIdent(_, _, None) => {
+            hir::PatEnum(..) | hir::PatIdent(_, _, None) => {
                 match tcx.def_map.borrow().get(&pat.id).map(|d| d.full_def()) {
                     Some(def::DefStruct(..)) => true,
                     _ => false
@@ -831,9 +831,9 @@ fn handle_fail(&self, bcx: Block) {
 }
 
 fn pick_column_to_specialize(def_map: &DefMap, m: &[Match]) -> Option<usize> {
-    fn pat_score(def_map: &DefMap, pat: &ast::Pat) -> usize {
+    fn pat_score(def_map: &DefMap, pat: &hir::Pat) -> usize {
         match pat.node {
-            ast::PatIdent(_, _, Some(ref inner)) => pat_score(def_map, &**inner),
+            hir::PatIdent(_, _, Some(ref inner)) => pat_score(def_map, &**inner),
             _ if pat_is_refutable(def_map, pat) => 1,
             _ => 0
         }
@@ -855,7 +855,7 @@ fn pat_score(def_map: &DefMap, pat: &ast::Pat) -> usize {
 
     let column_contains_any_nonwild_patterns = |&col: &usize| -> bool {
         m.iter().any(|row| match row.pats[col].node {
-            ast::PatWild(_) => false,
+            hir::PatWild(_) => false,
             _ => true
         })
     };
@@ -891,7 +891,7 @@ fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
 
     let _icx = push_ctxt("compare_values");
     if rhs_t.is_scalar() {
-        let cmp = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq, debug_loc);
+        let cmp = compare_scalar_types(cx, lhs, rhs, rhs_t, hir::BiEq, debug_loc);
         return Result::new(cx, cmp);
     }
 
@@ -905,7 +905,7 @@ fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                 compare_str(cx, lhs_data, lhs_len, rhs_data, rhs_len, rhs_t, debug_loc)
             }
             ty::TyArray(ty, _) | ty::TySlice(ty) => match ty.sty {
-                ty::TyUint(ast::TyU8) => {
+                ty::TyUint(hir::TyU8) => {
                     // NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
                     // which calls memcmp().
                     let pat_len = val_ty(rhs).element_type().array_length();
@@ -1027,7 +1027,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 }
 
 fn compile_guard<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                     guard_expr: &ast::Expr,
+                                     guard_expr: &hir::Expr,
                                      data: &ArmData<'p, 'blk, 'tcx>,
                                      m: &[Match<'a, 'p, 'blk, 'tcx>],
                                      vals: &[MatchInput],
@@ -1196,8 +1196,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                 let unsized_ty = def.struct_variant().fields.last().map(|field| {
                     monomorphize::field_ty(bcx.tcx(), substs, field)
                 }).unwrap();
-                let llty = type_of::type_of(bcx.ccx(), unsized_ty);
-                let scratch = alloca(bcx, llty, "__struct_field_fat_ptr");
+                let scratch = alloc_ty(bcx, unsized_ty, "__struct_field_fat_ptr");
                 let data = adt::trans_field_ptr(bcx, &*repr, struct_val, 0, arg_count);
                 let len = Load(bcx, expr::get_meta(bcx, val.val));
                 Store(bcx, data, expr::get_dataptr(bcx, scratch));
@@ -1325,14 +1324,14 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                             RangeResult(Result { val: vbegin, .. },
                                         Result { bcx, val: vend }) => {
                                 let llge = compare_scalar_types(bcx, test_val, vbegin,
-                                                                t, ast::BiGe, debug_loc);
+                                                                t, hir::BiGe, debug_loc);
                                 let llle = compare_scalar_types(bcx, test_val, vend,
-                                                                t, ast::BiLe, debug_loc);
+                                                                t, hir::BiLe, debug_loc);
                                 Result::new(bcx, And(bcx, llge, llle, DebugLoc::None))
                             }
                             LowerBound(Result { bcx, val }) => {
                                 Result::new(bcx, compare_scalar_types(bcx, test_val,
-                                                                      val, t, ast::BiGe,
+                                                                      val, t, hir::BiGe,
                                                                       debug_loc))
                             }
                         }
@@ -1416,9 +1415,9 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 }
 
 pub fn trans_match<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                               match_expr: &ast::Expr,
-                               discr_expr: &ast::Expr,
-                               arms: &[ast::Arm],
+                               match_expr: &hir::Expr,
+                               discr_expr: &hir::Expr,
+                               arms: &[hir::Arm],
                                dest: Dest)
                                -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("match::trans_match");
@@ -1426,22 +1425,22 @@ pub fn trans_match<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 }
 
 /// Checks whether the binding in `discr` is assigned to anywhere in the expression `body`
-fn is_discr_reassigned(bcx: Block, discr: &ast::Expr, body: &ast::Expr) -> bool {
+fn is_discr_reassigned(bcx: Block, discr: &hir::Expr, body: &hir::Expr) -> bool {
     let (vid, field) = match discr.node {
-        ast::ExprPath(..) => match bcx.def(discr.id) {
-            def::DefLocal(vid) | def::DefUpvar(vid, _) => (vid, None),
+        hir::ExprPath(..) => match bcx.def(discr.id) {
+            def::DefLocal(vid) | def::DefUpvar(vid, _, _) => (vid, None),
             _ => return false
         },
-        ast::ExprField(ref base, field) => {
+        hir::ExprField(ref base, field) => {
             let vid = match bcx.tcx().def_map.borrow().get(&base.id).map(|d| d.full_def()) {
-                Some(def::DefLocal(vid)) | Some(def::DefUpvar(vid, _)) => vid,
+                Some(def::DefLocal(vid)) | Some(def::DefUpvar(vid, _, _)) => vid,
                 _ => return false
             };
             (vid, Some(mc::NamedField(field.node.name)))
         },
-        ast::ExprTupField(ref base, field) => {
+        hir::ExprTupField(ref base, field) => {
             let vid = match bcx.tcx().def_map.borrow().get(&base.id).map(|d| d.full_def()) {
-                Some(def::DefLocal(vid)) | Some(def::DefUpvar(vid, _)) => vid,
+                Some(def::DefLocal(vid)) | Some(def::DefUpvar(vid, _, _)) => vid,
                 _ => return false
             };
             (vid, Some(mc::PositionalField(field.node)))
@@ -1474,8 +1473,8 @@ struct ReassignmentChecker {
 // for cases where the matched value is moved.
 impl<'tcx> euv::Delegate<'tcx> for ReassignmentChecker {
     fn consume(&mut self, _: ast::NodeId, _: Span, _: mc::cmt, _: euv::ConsumeMode) {}
-    fn matched_pat(&mut self, _: &ast::Pat, _: mc::cmt, _: euv::MatchMode) {}
-    fn consume_pat(&mut self, _: &ast::Pat, _: mc::cmt, _: euv::ConsumeMode) {}
+    fn matched_pat(&mut self, _: &hir::Pat, _: mc::cmt, _: euv::MatchMode) {}
+    fn consume_pat(&mut self, _: &hir::Pat, _: mc::cmt, _: euv::ConsumeMode) {}
     fn borrow(&mut self, _: ast::NodeId, _: Span, _: mc::cmt, _: ty::Region,
               _: ty::BorrowKind, _: euv::LoanCause) {}
     fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
@@ -1499,8 +1498,8 @@ fn mutate(&mut self, _: ast::NodeId, _: Span, cmt: mc::cmt, _: euv::MutateMode)
     }
 }
 
-fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
-                                   discr: &ast::Expr, body: &ast::Expr)
+fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &hir::Pat,
+                                   discr: &hir::Expr, body: &hir::Expr)
                                    -> BindingsMap<'tcx> {
     // Create the bindings map, which is a mapping from each binding name
     // to an alloca() that will be the value for that local variable.
@@ -1522,7 +1521,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
         let trmode;
         let moves_by_default = variable_ty.moves_by_default(&param_env, span);
         match bm {
-            ast::BindByValue(_) if !moves_by_default || reassigned =>
+            hir::BindByValue(_) if !moves_by_default || reassigned =>
             {
                 llmatch = alloca(bcx, llvariable_ty.ptr_to(), "__llmatch");
                 let llcopy = alloca(bcx, llvariable_ty, &bcx.name(name));
@@ -1532,14 +1531,14 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
                     TrByCopy(llcopy)
                 };
             }
-            ast::BindByValue(_) => {
+            hir::BindByValue(_) => {
                 // in this case, the final type of the variable will be T,
                 // but during matching we need to store a *T as explained
                 // above
                 llmatch = alloca(bcx, llvariable_ty.ptr_to(), &bcx.name(name));
                 trmode = TrByMoveRef;
             }
-            ast::BindByRef(_) => {
+            hir::BindByRef(_) => {
                 llmatch = alloca(bcx, llvariable_ty, &bcx.name(name));
                 trmode = TrByRef;
             }
@@ -1557,8 +1556,8 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
 
 fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
                                  match_id: ast::NodeId,
-                                 discr_expr: &ast::Expr,
-                                 arms: &[ast::Arm],
+                                 discr_expr: &hir::Expr,
+                                 arms: &[hir::Arm],
                                  dest: Dest) -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("match::trans_match_inner");
     let fcx = scope_cx.fcx;
@@ -1590,7 +1589,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
         None
     };
 
-    let arm_pats: Vec<Vec<P<ast::Pat>>> = {
+    let arm_pats: Vec<Vec<P<hir::Pat>>> = {
         let mut static_inliner = StaticInliner::new(scope_cx.tcx(),
                                                     pat_renaming_map.as_mut());
         arm_datas.iter().map(|arm_data| {
@@ -1616,7 +1615,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
     // to the default arm.
     let has_default = arms.last().map_or(false, |arm| {
         arm.pats.len() == 1
-        && arm.pats.last().unwrap().node == ast::PatWild(ast::PatWildSingle)
+        && arm.pats.last().unwrap().node == hir::PatWild(hir::PatWildSingle)
     });
 
     compile_submatch(bcx, &matches[..], &[discr_datum.match_input()], &chk, has_default);
@@ -1640,7 +1639,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
 /// Generates code for a local variable declaration like `let <pat>;` or `let <pat> =
 /// <opt_init_expr>`.
 pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                               local: &ast::Local)
+                               local: &hir::Local)
                                -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("match::store_local");
     let mut bcx = bcx;
@@ -1648,7 +1647,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let pat = &*local.pat;
 
     fn create_dummy_locals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
-                                       pat: &ast::Pat)
+                                       pat: &hir::Pat)
                                        -> Block<'blk, 'tcx> {
         let _icx = push_ctxt("create_dummy_locals");
         // create dummy memory for the variables if we have no
@@ -1765,7 +1764,7 @@ fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
 /// - pat: the irrefutable pattern being matched.
 /// - val: the value being matched -- must be an lvalue (by ref, with cleanup)
 pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                    pat: &ast::Pat,
+                                    pat: &hir::Pat,
                                     val: MatchInput,
                                     cleanup_scope: cleanup::ScopeId)
                                     -> Block<'blk, 'tcx> {
@@ -1785,7 +1784,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let tcx = bcx.tcx();
     let ccx = bcx.ccx();
     match pat.node {
-        ast::PatIdent(pat_binding_mode, ref path1, ref inner) => {
+        hir::PatIdent(pat_binding_mode, ref path1, ref inner) => {
             if pat_is_binding(&tcx.def_map, &*pat) {
                 // Allocate the stack slot where the value of this
                 // binding will live and place it into the appropriate
@@ -1795,14 +1794,14 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                     "_match::bind_irrefutable_pat",
                     |(), bcx, Datum { val: llval, ty, kind: _ }| {
                         match pat_binding_mode {
-                            ast::BindByValue(_) => {
+                            hir::BindByValue(_) => {
                                 // By value binding: move the value that `val`
                                 // points at into the binding's stack slot.
                                 let d = val.to_datum(ty);
                                 d.store_to(bcx, llval)
                             }
 
-                            ast::BindByRef(_) => {
+                            hir::BindByRef(_) => {
                                 // By ref binding: the value of the variable
                                 // is the pointer `val` itself or fat pointer referenced by `val`
                                 if type_is_fat_ptr(bcx.tcx(), ty) {
@@ -1822,7 +1821,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 bcx = bind_irrefutable_pat(bcx, &**inner_pat, val, cleanup_scope);
             }
         }
-        ast::PatEnum(_, ref sub_pats) => {
+        hir::PatEnum(_, ref sub_pats) => {
             let opt_def = bcx.tcx().def_map.borrow().get(&pat.id).map(|d| d.full_def());
             match opt_def {
                 Some(def::DefVariant(enum_id, var_id, _)) => {
@@ -1867,7 +1866,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 }
             }
         }
-        ast::PatStruct(_, ref fields, _) => {
+        hir::PatStruct(_, ref fields, _) => {
             let tcx = bcx.tcx();
             let pat_ty = node_id_type(bcx, pat.id);
             let pat_repr = adt::represent_type(bcx.ccx(), pat_ty);
@@ -1886,7 +1885,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                            cleanup_scope);
             }
         }
-        ast::PatTup(ref elems) => {
+        hir::PatTup(ref elems) => {
             let repr = adt::represent_node(bcx, pat.id);
             for (i, elem) in elems.iter().enumerate() {
                 let fldptr = adt::trans_field_ptr(bcx, &*repr, val.val, 0, i);
@@ -1897,12 +1896,12 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                     cleanup_scope);
             }
         }
-        ast::PatBox(ref inner) => {
+        hir::PatBox(ref inner) => {
             let llbox = Load(bcx, val.val);
             bcx = bind_irrefutable_pat(
                 bcx, &**inner, MatchInput::from_val(llbox), cleanup_scope);
         }
-        ast::PatRegion(ref inner, _) => {
+        hir::PatRegion(ref inner, _) => {
             let loaded_val = Load(bcx, val.val);
             bcx = bind_irrefutable_pat(
                 bcx,
@@ -1910,7 +1909,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 MatchInput::from_val(loaded_val),
                 cleanup_scope);
         }
-        ast::PatVec(ref before, ref slice, ref after) => {
+        hir::PatVec(ref before, ref slice, ref after) => {
             let pat_ty = node_id_type(bcx, pat.id);
             let mut extracted = extract_vec_elems(bcx, pat_ty, before.len(), after.len(), val);
             match slice {
@@ -1935,11 +1934,8 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                         cleanup_scope)
                 });
         }
-        ast::PatMac(..) => {
-            bcx.sess().span_bug(pat.span, "unexpanded macro");
-        }
-        ast::PatQPath(..) | ast::PatWild(_) | ast::PatLit(_) |
-        ast::PatRange(_, _) => ()
+        hir::PatQPath(..) | hir::PatWild(_) | hir::PatLit(_) |
+        hir::PatRange(_, _) => ()
     }
     return bcx;
 }