Skip to content

Commit 5e22fb9

Browse files
committed
Remove match check
1 parent c7a3d0e commit 5e22fb9

File tree

13 files changed

+23
-39
lines changed

13 files changed

+23
-39
lines changed

src/libsyntax/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ enum expr_ {
348348
Same semantics as while(true) { body }, but typestate knows that the
349349
(implicit) condition is always true. */
350350
expr_loop(blk, option<ident>),
351-
expr_match(@expr, ~[arm], alt_mode),
351+
expr_match(@expr, ~[arm]),
352352
expr_fn(proto, fn_decl, blk, capture_clause),
353353
expr_fn_block(fn_decl, blk, capture_clause),
354354
// Inner expr is always an expr_fn_block. We need the wrapping node to

src/libsyntax/ext/auto_serialize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl ext_ctxt: ext_ctxt_helpers {
250250
self.stmt(
251251
self.expr(
252252
span,
253-
ast::expr_match(v, arms, ast::alt_exhaustive)))
253+
ast::expr_match(v, arms)))
254254
}
255255

256256
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,
944944
// Generate code like:
945945
let e_name = cx.lit_str(e_span, @cx.str_of(e_name));
946946
let alt_expr = cx.expr(e_span,
947-
ast::expr_match(#ast{__i}, arms, ast::alt_exhaustive));
947+
ast::expr_match(#ast{__i}, arms));
948948
let var_lambda = #ast{ |__i| $(alt_expr) };
949949
let read_var = #ast{ $(cx.clone(d)).read_enum_variant($(var_lambda)) };
950950
let read_lambda = cx.lambda(cx.expr_blk(read_var));

src/libsyntax/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,9 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
456456
expr_loop(fld.fold_block(body),
457457
option::map(opt_ident, |x| fld.fold_ident(x)))
458458
}
459-
expr_match(expr, arms, mode) => {
459+
expr_match(expr, arms) => {
460460
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)))
462462
}
463463
expr_fn(proto, decl, body, captures) => {
464464
expr_fn(proto, fold_fn_decl(decl, fld),

src/libsyntax/parse/parser.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1668,8 +1668,6 @@ struct parser {
16681668

16691669
fn parse_alt_expr() -> @expr {
16701670
let lo = self.last_span.lo;
1671-
let mode = if self.eat_keyword(~"check") { alt_check }
1672-
else { alt_exhaustive };
16731671
let discriminant = self.parse_expr();
16741672
self.expect(token::LBRACE);
16751673
let mut arms: ~[arm] = ~[];
@@ -1701,7 +1699,7 @@ struct parser {
17011699
}
17021700
let mut hi = self.span.hi;
17031701
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));
17051703
}
17061704
17071705
fn parse_expr() -> @expr {

src/libsyntax/print/pprust.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1128,11 +1128,10 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
11281128
option::iter(opt_ident, |ident| {print_ident(s, ident); space(s.s)});
11291129
print_block(s, blk);
11301130
}
1131-
ast::expr_match(expr, arms, mode) => {
1131+
ast::expr_match(expr, arms) => {
11321132
cbox(s, alt_indent_unit);
11331133
ibox(s, 4u);
11341134
word_nbsp(s, ~"match");
1135-
if mode == ast::alt_check { word_nbsp(s, ~"check"); }
11361135
print_maybe_parens_discrim(s, expr);
11371136
space(s.s);
11381137
bopen(s);

src/libsyntax/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
430430
}
431431
expr_while(x, b) => { v.visit_expr(x, e, v); v.visit_block(b, e, v); }
432432
expr_loop(b, _) => v.visit_block(b, e, v),
433-
expr_match(x, arms, _) => {
433+
expr_match(x, arms) => {
434434
v.visit_expr(x, e, v);
435435
for arms.each |a| { v.visit_arm(a, e, v); }
436436
}

src/rustc/middle/borrowck/gather_loans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn req_loans_in_expr(ex: @ast::expr,
171171
visit::visit_expr(ex, self, vt);
172172
}
173173

174-
ast::expr_match(ex_v, arms, _) => {
174+
ast::expr_match(ex_v, arms) => {
175175
let cmt = self.bccx.cat_expr(ex_v);
176176
for arms.each |arm| {
177177
for arm.pats.each |pat| {

src/rustc/middle/check_alt.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
2424
fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
2525
visit::visit_expr(ex, s, v);
2626
match ex.node {
27-
expr_match(scrut, arms, mode) => {
27+
expr_match(scrut, arms) => {
2828
check_arms(tcx, arms);
2929
/* Check for exhaustiveness */
3030
// 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<()>) {
4848
}
4949
_ => { /* We assume only enum types can be uninhabited */ }
5050
}
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+
_ => ()
5855
}
5956
}
6057

src/rustc/middle/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ impl Liveness {
10481048
self.propagate_through_loop(expr, none, blk, succ)
10491049
}
10501050

1051-
expr_match(e, arms, _) => {
1051+
expr_match(e, arms) => {
10521052
//
10531053
// (e)
10541054
// |

src/rustc/middle/region.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
259259
cx.sess.intr()));
260260
new_cx.parent = some(expr.id);
261261
}
262-
ast::expr_match(subexpr, _, _) => {
262+
ast::expr_match(subexpr, _) => {
263263
debug!("node %d: %s", expr.id, pprust::expr_to_str(expr,
264264
cx.sess.intr()));
265265
new_cx.parent = some(expr.id);

src/rustc/middle/trans/alt.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -822,16 +822,15 @@ fn trans_alt(bcx: block,
822822
alt_expr: @ast::expr,
823823
expr: @ast::expr,
824824
arms: ~[ast::arm],
825-
mode: ast::alt_mode,
826825
dest: dest) -> block {
827826
let _icx = bcx.insn_ctxt("alt::trans_alt");
828827
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)
830829
}
831830
}
832831

833832
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 {
835834
let _icx = scope_cx.insn_ctxt("alt::trans_alt_inner");
836835
let bcx = scope_cx, tcx = bcx.tcx();
837836
let mut bodies = ~[], matches = ~[];
@@ -860,15 +859,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
860859
return fail_cx.llbb;
861860
}
862861
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;
872863
// special case for uninhabited type
873864
if ty::type_is_empty(tcx, t) {
874865
some(|| mk_fail(scope_cx, expr.span,
@@ -877,7 +868,6 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
877868
else {
878869
none
879870
}
880-
}
881871
};
882872
let mut exit_map = ~[];
883873
let spilled = spill_if_immediate(bcx, val, t);

src/rustc/middle/trans/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3798,8 +3798,8 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
37983798
ast::expr_if(cond, thn, els) => {
37993799
return trans_if(bcx, cond, thn, els, dest);
38003800
}
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);
38033803
}
38043804
ast::expr_block(blk) => {
38053805
return do with_scope(bcx, blk.info(), ~"block-expr body") |bcx| {
@@ -4488,7 +4488,7 @@ fn trans_block_cleanups_(bcx: block,
44884488
}
44894489
}
44904490
}
4491-
}
4491+
}
44924492
return bcx;
44934493
}
44944494

src/rustc/middle/typeck/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
15991599
fcx.write_ty(id, ty::mk_nil(tcx));
16001600
bot = !may_break(body);
16011601
}
1602-
ast::expr_match(discrim, arms, mode) => {
1602+
ast::expr_match(discrim, arms) => {
16031603
bot = alt::check_alt(fcx, expr, discrim, arms);
16041604
}
16051605
ast::expr_fn(proto, decl, body, cap_clause) => {

0 commit comments

Comments
 (0)