Skip to content
This repository
Browse code

Remove match check

  • Loading branch information...
commit 5e22fb9c7f94c76e1e7e17709884198ec4ba3fcb 1 parent c7a3d0e
Tim Chevalier authored
2  src/libsyntax/ast.rs
@@ -348,7 +348,7 @@ enum expr_ {
348 348
        Same semantics as while(true) { body }, but typestate knows that the
349 349
        (implicit) condition is always true. */
350 350
     expr_loop(blk, option<ident>),
351  
-    expr_match(@expr, ~[arm], alt_mode),
  351
+    expr_match(@expr, ~[arm]),
352 352
     expr_fn(proto, fn_decl, blk, capture_clause),
353 353
     expr_fn_block(fn_decl, blk, capture_clause),
354 354
     // Inner expr is always an expr_fn_block. We need the wrapping node to
4  src/libsyntax/ext/auto_serialize.rs
@@ -250,7 +250,7 @@ impl ext_ctxt: ext_ctxt_helpers {
250 250
         self.stmt(
251 251
             self.expr(
252 252
                 span,
253  
-                ast::expr_match(v, arms, ast::alt_exhaustive)))
  253
+                ast::expr_match(v, arms)))
254 254
     }
255 255
 
256 256
     fn lit_str(span: span, s: @~str) -> @ast::expr {
@@ -944,7 +944,7 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident,
944 944
     // Generate code like:
945 945
     let e_name = cx.lit_str(e_span, @cx.str_of(e_name));
946 946
     let alt_expr = cx.expr(e_span,
947  
-                   ast::expr_match(#ast{__i}, arms, ast::alt_exhaustive));
  947
+                           ast::expr_match(#ast{__i}, arms));
948 948
     let var_lambda = #ast{ |__i| $(alt_expr) };
949 949
     let read_var = #ast{ $(cx.clone(d)).read_enum_variant($(var_lambda)) };
950 950
     let read_lambda = cx.lambda(cx.expr_blk(read_var));
4  src/libsyntax/fold.rs
@@ -456,9 +456,9 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
456 456
               expr_loop(fld.fold_block(body),
457 457
                         option::map(opt_ident, |x| fld.fold_ident(x)))
458 458
           }
459  
-          expr_match(expr, arms, mode) => {
  459
+          expr_match(expr, arms) => {
460 460
             expr_match(fld.fold_expr(expr),
461  
-                     vec::map(arms, |x| fld.fold_arm(x)), mode)
  461
+                     vec::map(arms, |x| fld.fold_arm(x)))
462 462
           }
463 463
           expr_fn(proto, decl, body, captures) => {
464 464
             expr_fn(proto, fold_fn_decl(decl, fld),
4  src/libsyntax/parse/parser.rs
@@ -1668,8 +1668,6 @@ struct parser {
1668 1668
 
1669 1669
     fn parse_alt_expr() -> @expr {
1670 1670
         let lo = self.last_span.lo;
1671  
-        let mode = if self.eat_keyword(~"check") { alt_check }
1672  
-        else { alt_exhaustive };
1673 1671
         let discriminant = self.parse_expr();
1674 1672
         self.expect(token::LBRACE);
1675 1673
         let mut arms: ~[arm] = ~[];
@@ -1701,7 +1699,7 @@ struct parser {
1701 1699
         }
1702 1700
         let mut hi = self.span.hi;
1703 1701
         self.bump();
1704  
-        return self.mk_expr(lo, hi, expr_match(discriminant, arms, mode));
  1702
+        return self.mk_expr(lo, hi, expr_match(discriminant, arms));
1705 1703
     }
1706 1704
 
1707 1705
     fn parse_expr() -> @expr {
3  src/libsyntax/print/pprust.rs
@@ -1128,11 +1128,10 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
1128 1128
         option::iter(opt_ident, |ident| {print_ident(s, ident); space(s.s)});
1129 1129
         print_block(s, blk);
1130 1130
       }
1131  
-      ast::expr_match(expr, arms, mode) => {
  1131
+      ast::expr_match(expr, arms) => {
1132 1132
         cbox(s, alt_indent_unit);
1133 1133
         ibox(s, 4u);
1134 1134
         word_nbsp(s, ~"match");
1135  
-        if mode == ast::alt_check { word_nbsp(s, ~"check"); }
1136 1135
         print_maybe_parens_discrim(s, expr);
1137 1136
         space(s.s);
1138 1137
         bopen(s);
2  src/libsyntax/visit.rs
@@ -430,7 +430,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
430 430
       }
431 431
       expr_while(x, b) => { v.visit_expr(x, e, v); v.visit_block(b, e, v); }
432 432
       expr_loop(b, _) => v.visit_block(b, e, v),
433  
-      expr_match(x, arms, _) => {
  433
+      expr_match(x, arms) => {
434 434
         v.visit_expr(x, e, v);
435 435
         for arms.each |a| { v.visit_arm(a, e, v); }
436 436
       }
2  src/rustc/middle/borrowck/gather_loans.rs
@@ -171,7 +171,7 @@ fn req_loans_in_expr(ex: @ast::expr,
171 171
         visit::visit_expr(ex, self, vt);
172 172
       }
173 173
 
174  
-      ast::expr_match(ex_v, arms, _) => {
  174
+      ast::expr_match(ex_v, arms) => {
175 175
         let cmt = self.bccx.cat_expr(ex_v);
176 176
         for arms.each |arm| {
177 177
             for arm.pats.each |pat| {
13  src/rustc/middle/check_alt.rs
@@ -24,7 +24,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
24 24
 fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
25 25
     visit::visit_expr(ex, s, v);
26 26
     match ex.node {
27  
-      expr_match(scrut, arms, mode) => {
  27
+      expr_match(scrut, arms) => {
28 28
         check_arms(tcx, arms);
29 29
         /* Check for exhaustiveness */
30 30
          // Check for empty enum, because is_useful only works on inhabited
@@ -48,13 +48,10 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
48 48
           }
49 49
           _ => { /* We assume only enum types can be uninhabited */ }
50 50
        }
51  
-
52  
-        if mode == alt_exhaustive {
53  
-            let arms = vec::concat(vec::filter_map(arms, unguarded_pat));
54  
-            check_exhaustive(tcx, ex.span, arms);
55  
-        }
56  
-      }
57  
-      _ => ()
  51
+       let arms = vec::concat(vec::filter_map(arms, unguarded_pat));
  52
+       check_exhaustive(tcx, ex.span, arms);
  53
+     }
  54
+     _ => ()
58 55
     }
59 56
 }
60 57
 
2  src/rustc/middle/liveness.rs
@@ -1048,7 +1048,7 @@ impl Liveness {
1048 1048
             self.propagate_through_loop(expr, none, blk, succ)
1049 1049
           }
1050 1050
 
1051  
-          expr_match(e, arms, _) => {
  1051
+          expr_match(e, arms) => {
1052 1052
             //
1053 1053
             //      (e)
1054 1054
             //       |
2  src/rustc/middle/region.rs
@@ -259,7 +259,7 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
259 259
                                                            cx.sess.intr()));
260 260
         new_cx.parent = some(expr.id);
261 261
       }
262  
-      ast::expr_match(subexpr, _, _) => {
  262
+      ast::expr_match(subexpr, _) => {
263 263
         debug!("node %d: %s", expr.id, pprust::expr_to_str(expr,
264 264
                                                            cx.sess.intr()));
265 265
         new_cx.parent = some(expr.id);
16  src/rustc/middle/trans/alt.rs
@@ -822,16 +822,15 @@ fn trans_alt(bcx: block,
822 822
              alt_expr: @ast::expr,
823 823
              expr: @ast::expr,
824 824
              arms: ~[ast::arm],
825  
-             mode: ast::alt_mode,
826 825
              dest: dest) -> block {
827 826
     let _icx = bcx.insn_ctxt("alt::trans_alt");
828 827
     do with_scope(bcx, alt_expr.info(), ~"alt") |bcx| {
829  
-        trans_alt_inner(bcx, expr, arms, mode, dest)
  828
+        trans_alt_inner(bcx, expr, arms, dest)
830 829
     }
831 830
 }
832 831
 
833 832
 fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
834  
-                   mode: ast::alt_mode, dest: dest) -> block {
  833
+                   dest: dest) -> block {
835 834
     let _icx = scope_cx.insn_ctxt("alt::trans_alt_inner");
836 835
     let bcx = scope_cx, tcx = bcx.tcx();
837 836
     let mut bodies = ~[], matches = ~[];
@@ -860,15 +859,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
860 859
             return fail_cx.llbb;
861 860
     }
862 861
     let t = node_id_type(bcx, expr.id);
863  
-    let mk_fail = match mode {
864  
-      ast::alt_check => {
865  
-        let fail_cx = @mut none;
866  
-        // Cached fail-on-fallthrough block
867  
-        some(|| mk_fail(scope_cx, expr.span, ~"non-exhaustive match failure",
868  
-                        fail_cx))
869  
-      }
870  
-      ast::alt_exhaustive => {
871  
-          let fail_cx = @mut none;
  862
+    let mk_fail = { let fail_cx = @mut none;
872 863
           // special case for uninhabited type
873 864
           if ty::type_is_empty(tcx, t) {
874 865
                   some(|| mk_fail(scope_cx, expr.span,
@@ -877,7 +868,6 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
877 868
           else {
878 869
               none
879 870
           }
880  
-      }
881 871
     };
882 872
     let mut exit_map = ~[];
883 873
     let spilled = spill_if_immediate(bcx, val, t);
6  src/rustc/middle/trans/base.rs
@@ -3798,8 +3798,8 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
3798 3798
           ast::expr_if(cond, thn, els) => {
3799 3799
             return trans_if(bcx, cond, thn, els, dest);
3800 3800
           }
3801  
-          ast::expr_match(expr, arms, mode) => {
3802  
-            return alt::trans_alt(bcx, e, expr, arms, mode, dest);
  3801
+          ast::expr_match(expr, arms) => {
  3802
+            return alt::trans_alt(bcx, e, expr, arms, dest);
3803 3803
           }
3804 3804
           ast::expr_block(blk) => {
3805 3805
             return do with_scope(bcx, blk.info(), ~"block-expr body") |bcx| {
@@ -4488,7 +4488,7 @@ fn trans_block_cleanups_(bcx: block,
4488 4488
                 }
4489 4489
               }
4490 4490
             }
4491  
-            }
  4491
+        }
4492 4492
     return bcx;
4493 4493
 }
4494 4494
 
2  src/rustc/middle/typeck/check.rs
@@ -1599,7 +1599,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1599 1599
         fcx.write_ty(id, ty::mk_nil(tcx));
1600 1600
         bot = !may_break(body);
1601 1601
       }
1602  
-      ast::expr_match(discrim, arms, mode) => {
  1602
+      ast::expr_match(discrim, arms) => {
1603 1603
         bot = alt::check_alt(fcx, expr, discrim, arms);
1604 1604
       }
1605 1605
       ast::expr_fn(proto, decl, body, cap_clause) => {

0 notes on commit 5e22fb9

Please sign in to comment.
Something went wrong with that request. Please try again.