From 816cb8c5350084e04770b9c3a133400923bd2e1b Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Fri, 4 Jan 2013 09:52:07 -0500 Subject: [PATCH] Rename identifiers that still use 'alt' to use 'match' This'll be less confusing for anyone who works on match in future. --- src/librustc/driver/driver.rs | 4 +-- src/librustc/middle/borrowck/gather_loans.rs | 8 ++--- src/librustc/middle/borrowck/mod.rs | 4 +-- src/librustc/middle/borrowck/preserve.rs | 18 +++++----- .../middle/{check_alt.rs => check_match.rs} | 36 +++++++++---------- src/librustc/middle/const_eval.rs | 2 +- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc/middle/region.rs | 2 +- .../middle/trans/{alt.rs => _match.rs} | 34 +++++++++--------- src/librustc/middle/trans/base.rs | 22 ++++++------ src/librustc/middle/trans/debuginfo.rs | 2 +- src/librustc/middle/trans/expr.rs | 3 +- .../middle/typeck/check/{alt.rs => _match.rs} | 14 ++++---- src/librustc/middle/typeck/check/mod.rs | 16 ++++----- src/librustc/rustc.rc | 4 +-- src/librustc/util/ppaux.rs | 2 +- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/parse/parser.rs | 4 +-- src/libsyntax/print/pprust.rs | 12 +++---- 19 files changed, 96 insertions(+), 95 deletions(-) rename src/librustc/middle/{check_alt.rs => check_match.rs} (96%) rename src/librustc/middle/trans/{alt.rs => _match.rs} (98%) rename src/librustc/middle/typeck/check/{alt.rs => _match.rs} (98%) diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 12573e0fc62..b5f57d904bc 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -275,8 +275,8 @@ fn compile_upto(sess: Session, cfg: ast::crate_cfg, time(time_passes, ~"mode computation", || middle::mode::compute_modes(ty_cx, method_map, crate)); - time(time_passes, ~"alt checking", || - middle::check_alt::check_crate(ty_cx, method_map, crate)); + time(time_passes, ~"match checking", || + middle::check_match::check_crate(ty_cx, method_map, crate)); let last_use_map = time(time_passes, ~"liveness checking", || diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index 9524980a1f9..d5652ae78d6 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -506,7 +506,7 @@ impl gather_loan_ctxt { discr_cmt: cmt, root_pat: @ast::pat, arm_id: ast::node_id, - alt_id: ast::node_id) { + match_id: ast::node_id) { do self.bccx.cat_pattern(discr_cmt, root_pat) |cmt, pat| { match pat.node { ast::pat_ident(bm, _, _) if self.pat_is_binding(pat) => { @@ -514,11 +514,11 @@ impl gather_loan_ctxt { ast::bind_by_value | ast::bind_by_move => { // copying does not borrow anything, so no check // is required - // as for move, check::alt ensures it's from an rvalue. + // as for move, check::_match ensures it's from an rvalue. } ast::bind_by_ref(mutbl) => { // ref x or ref x @ p --- creates a ptr which must - // remain valid for the scope of the alt + // remain valid for the scope of the match // find the region of the resulting pointer (note that // the type of such a pattern will *always* be a @@ -531,7 +531,7 @@ impl gather_loan_ctxt { // of the function of this node in method preserve(): let arm_scope = ty::re_scope(arm_id); if self.bccx.is_subregion_of(scope_r, arm_scope) { - let cmt_discr = self.bccx.cat_discr(cmt, alt_id); + let cmt_discr = self.bccx.cat_discr(cmt, match_id); self.guarantee_valid(cmt_discr, mutbl, scope_r); } else { self.guarantee_valid(cmt, mutbl, scope_r); diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 1cd88aa8197..fa7dfd1b77f 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -494,8 +494,8 @@ impl borrowck_ctxt { cat_variant(self.tcx, self.method_map, arg, enum_did, cmt) } - fn cat_discr(cmt: cmt, alt_id: ast::node_id) -> cmt { - return @{cat:cat_discr(cmt, alt_id),.. *cmt}; + fn cat_discr(cmt: cmt, match_id: ast::node_id) -> cmt { + return @{cat:cat_discr(cmt, match_id),.. *cmt}; } fn cat_pattern(cmt: cmt, pat: @ast::pat, op: fn(cmt, @ast::pat)) { diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 220685e58ca..e6d311fd04f 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -195,15 +195,15 @@ priv impl &preserve_ctxt { self.attempt_root(cmt, base, derefs) } } - cat_discr(base, alt_id) => { - // Subtle: in an alt, we must ensure that each binding + cat_discr(base, match_id) => { + // Subtle: in a match, we must ensure that each binding // variable remains valid for the duration of the arm in // which it appears, presuming that this arm is taken. // But it is inconvenient in trans to root something just // for one arm. Therefore, we insert a cat_discr(), // basically a special kind of category that says "if this // value must be dynamically rooted, root it for the scope - // `alt_id`. + // `match_id`. // // As an example, consider this scenario: // @@ -213,7 +213,7 @@ priv impl &preserve_ctxt { // Technically, the value `x` need only be rooted // in the `some` arm. However, we evaluate `x` in trans // before we know what arm will be taken, so we just - // always root it for the duration of the alt. + // always root it for the duration of the match. // // As a second example, consider *this* scenario: // @@ -225,7 +225,7 @@ priv impl &preserve_ctxt { // found only when checking which pattern matches: but // this check is done before entering the arm. Therefore, // even in this case we just choose to keep the value - // rooted for the entire alt. This means the value will be + // rooted for the entire match. This means the value will be // rooted even if the none arm is taken. Oh well. // // At first, I tried to optimize the second case to only @@ -247,12 +247,12 @@ priv impl &preserve_ctxt { // Nonetheless, if you decide to optimize this case in the // future, you need only adjust where the cat_discr() // node appears to draw the line between what will be rooted - // in the *arm* vs the *alt*. + // in the *arm* vs the *match*. - let alt_rooting_ctxt = - preserve_ctxt({scope_region: ty::re_scope(alt_id), + let match_rooting_ctxt = + preserve_ctxt({scope_region: ty::re_scope(match_id), .. **self}); - (&alt_rooting_ctxt).preserve(base) + (&match_rooting_ctxt).preserve(base) } } } diff --git a/src/librustc/middle/check_alt.rs b/src/librustc/middle/check_match.rs similarity index 96% rename from src/librustc/middle/check_alt.rs rename to src/librustc/middle/check_match.rs index bdd2b06e6ab..dc66df93624 100644 --- a/src/librustc/middle/check_alt.rs +++ b/src/librustc/middle/check_match.rs @@ -30,13 +30,13 @@ use syntax::codemap::span; use syntax::print::pprust::pat_to_str; use syntax::visit; -struct AltCheckCtxt { +struct MatchCheckCtxt { tcx: ty::ctxt, method_map: method_map, } fn check_crate(tcx: ty::ctxt, method_map: method_map, crate: @crate) { - let cx = @AltCheckCtxt { tcx: tcx, method_map: method_map }; + let cx = @MatchCheckCtxt { tcx: tcx, method_map: method_map }; visit::visit_crate(*crate, (), visit::mk_vt(@{ visit_expr: |a,b,c| check_expr(cx, a, b, c), visit_local: |a,b,c| check_local(cx, a, b, c), @@ -47,7 +47,7 @@ fn check_crate(tcx: ty::ctxt, method_map: method_map, crate: @crate) { tcx.sess.abort_if_errors(); } -fn expr_is_non_moving_lvalue(cx: @AltCheckCtxt, expr: @expr) -> bool { +fn expr_is_non_moving_lvalue(cx: @MatchCheckCtxt, expr: @expr) -> bool { if !ty::expr_is_lval(cx.tcx, cx.method_map, expr) { return false; } @@ -61,7 +61,7 @@ fn expr_is_non_moving_lvalue(cx: @AltCheckCtxt, expr: @expr) -> bool { } } -fn check_expr(cx: @AltCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) { +fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) { visit::visit_expr(ex, s, v); match ex.node { expr_match(scrut, ref arms) => { @@ -107,7 +107,7 @@ fn check_expr(cx: @AltCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) { } // Check for unreachable patterns -fn check_arms(cx: @AltCheckCtxt, arms: ~[arm]) { +fn check_arms(cx: @MatchCheckCtxt, arms: ~[arm]) { let mut seen = ~[]; for arms.each |arm| { for arm.pats.each |pat| { @@ -130,7 +130,7 @@ fn raw_pat(p: @pat) -> @pat { } } -fn check_exhaustive(cx: @AltCheckCtxt, sp: span, pats: ~[@pat]) { +fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) { assert(pats.is_not_empty()); let ext = match is_useful(cx, vec::map(pats, |p| ~[*p]), ~[wild()]) { not_useful => return, // This is good, wildcard pattern isn't reachable @@ -216,7 +216,7 @@ impl ctor : cmp::Eq { // Note: is_useful doesn't work on empty types, as the paper notes. // So it assumes that v is non-empty. -fn is_useful(cx: @AltCheckCtxt, +m: matrix, +v: ~[@pat]) -> useful { +fn is_useful(cx: @MatchCheckCtxt, +m: matrix, +v: ~[@pat]) -> useful { if m.len() == 0u { return useful_; } if m[0].len() == 0u { return not_useful; } let real_pat = match vec::find(m, |r| r[0].id != 0) { @@ -289,7 +289,7 @@ fn is_useful(cx: @AltCheckCtxt, +m: matrix, +v: ~[@pat]) -> useful { } } -fn is_useful_specialized(cx: @AltCheckCtxt, m: matrix, +v: ~[@pat], +fn is_useful_specialized(cx: @MatchCheckCtxt, m: matrix, +v: ~[@pat], +ctor: ctor, arity: uint, lty: ty::t) -> useful { let ms = vec::filter_map(m, |r| specialize(cx, *r, ctor, arity, lty)); let could_be_useful = is_useful( @@ -300,7 +300,7 @@ fn is_useful_specialized(cx: @AltCheckCtxt, m: matrix, +v: ~[@pat], } } -fn pat_ctor_id(cx: @AltCheckCtxt, p: @pat) -> Option { +fn pat_ctor_id(cx: @MatchCheckCtxt, p: @pat) -> Option { let pat = raw_pat(p); match /*bad*/copy pat.node { pat_wild => { None } @@ -337,7 +337,7 @@ fn pat_ctor_id(cx: @AltCheckCtxt, p: @pat) -> Option { } } -fn is_wild(cx: @AltCheckCtxt, p: @pat) -> bool { +fn is_wild(cx: @MatchCheckCtxt, p: @pat) -> bool { let pat = raw_pat(p); match pat.node { pat_wild => { true } @@ -351,7 +351,7 @@ fn is_wild(cx: @AltCheckCtxt, p: @pat) -> bool { } } -fn missing_ctor(cx: @AltCheckCtxt, +fn missing_ctor(cx: @MatchCheckCtxt, m: matrix, left_ty: ty::t) -> Option { @@ -451,7 +451,7 @@ fn missing_ctor(cx: @AltCheckCtxt, } } -fn ctor_arity(cx: @AltCheckCtxt, ctor: ctor, ty: ty::t) -> uint { +fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint { match /*bad*/copy ty::get(ty).sty { ty::ty_tup(fs) => fs.len(), ty::ty_rec(fs) => fs.len(), @@ -479,7 +479,7 @@ fn wild() -> @pat { @{id: 0, node: pat_wild, span: ast_util::dummy_sp()} } -fn specialize(cx: @AltCheckCtxt, r: ~[@pat], ctor_id: ctor, arity: uint, +fn specialize(cx: @MatchCheckCtxt, r: ~[@pat], ctor_id: ctor, arity: uint, left_ty: ty::t) -> Option<~[@pat]> { let r0 = raw_pat(r[0]); match /*bad*/copy r0.node { @@ -637,12 +637,12 @@ fn specialize(cx: @AltCheckCtxt, r: ~[@pat], ctor_id: ctor, arity: uint, } } -fn default(cx: @AltCheckCtxt, r: ~[@pat]) -> Option<~[@pat]> { +fn default(cx: @MatchCheckCtxt, r: ~[@pat]) -> Option<~[@pat]> { if is_wild(cx, r[0]) { Some(vec::tail(r)) } else { None } } -fn check_local(cx: @AltCheckCtxt, loc: @local, &&s: (), v: visit::vt<()>) { +fn check_local(cx: @MatchCheckCtxt, loc: @local, &&s: (), v: visit::vt<()>) { visit::visit_local(loc, s, v); if is_refutable(cx, loc.node.pat) { cx.tcx.sess.span_err(loc.node.pat.span, @@ -657,7 +657,7 @@ fn check_local(cx: @AltCheckCtxt, loc: @local, &&s: (), v: visit::vt<()>) { check_legality_of_move_bindings(cx, is_lvalue, false, [ loc.node.pat ]); } -fn check_fn(cx: @AltCheckCtxt, +fn check_fn(cx: @MatchCheckCtxt, kind: visit::fn_kind, decl: fn_decl, body: blk, @@ -674,7 +674,7 @@ fn check_fn(cx: @AltCheckCtxt, } } -fn is_refutable(cx: @AltCheckCtxt, pat: &pat) -> bool { +fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool { match cx.tcx.def_map.find(pat.id) { Some(def_variant(enum_id, _)) => { if vec::len(*ty::enum_variants(cx.tcx, enum_id)) != 1u { @@ -712,7 +712,7 @@ fn is_refutable(cx: @AltCheckCtxt, pat: &pat) -> bool { // Legality of move bindings checking -fn check_legality_of_move_bindings(cx: @AltCheckCtxt, +fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, is_lvalue: bool, has_guard: bool, pats: &[@pat]) { diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index dbde060c6f5..e2de186ca2f 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -46,7 +46,7 @@ use syntax::ast::*; // & and * pointers // copies of general constants // -// (in theory, probably not at first: if/alt on integer-const +// (in theory, probably not at first: if/match on integer-const // conditions / descriminants) // // - Non-constants: everything else. diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 1bbdc699377..9b373ef0c16 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -904,7 +904,7 @@ impl &mem_categorization_ctxt { // local(x)->@->@ // // where the id of `local(x)` is the id of the `x` that appears - // in the alt, the id of `local(x)->@` is the `@y` pattern, + // in the match, the id of `local(x)->@` is the `@y` pattern, // and the id of `local(x)->@->@` is the id of the `y` pattern. diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 3a263347536..6f9c3070a0e 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -71,7 +71,7 @@ struct ctxt { // that when we visit it we can view it as a parent. root_exprs: HashMap, - // The parent scope is the innermost block, statement, call, or alt + // The parent scope is the innermost block, statement, call, or match // expression during the execution of which the current expression // will be evaluated. Generally speaking, the innermost parent // scope is also the closest suitable ancestor in the AST tree. diff --git a/src/librustc/middle/trans/alt.rs b/src/librustc/middle/trans/_match.rs similarity index 98% rename from src/librustc/middle/trans/alt.rs rename to src/librustc/middle/trans/_match.rs index a183bd453d0..97331021560 100644 --- a/src/librustc/middle/trans/alt.rs +++ b/src/librustc/middle/trans/_match.rs @@ -245,7 +245,7 @@ enum opt_result { range_result(Result, Result), } fn trans_opt(bcx: block, o: &Opt) -> opt_result { - let _icx = bcx.insn_ctxt("alt::trans_opt"); + let _icx = bcx.insn_ctxt("match::trans_opt"); let ccx = bcx.ccx(); let mut bcx = bcx; match *o { @@ -463,8 +463,8 @@ fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r], } // nmatsakis: what does enter_opt do? -// in trans/alt -// trans/alt.rs is like stumbling around in a dark cave +// in trans/match +// trans/match.rs is like stumbling around in a dark cave // pcwalton: the enter family of functions adjust the set of // patterns as needed // yeah, at some point I kind of achieved some level of @@ -810,7 +810,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, val: ValueRef) -> {vals: ~[ValueRef], bcx: block} { - let _icx = bcx.insn_ctxt("alt::extract_variant_args"); + let _icx = bcx.insn_ctxt("match::extract_variant_args"); let ccx = bcx.fcx.ccx; let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id)).sty { ty::ty_enum(id, ref substs) => { @@ -841,7 +841,7 @@ fn extract_vec_elems(bcx: block, pat_id: ast::node_id, elem_count: uint, tail: bool, val: ValueRef) -> {vals: ~[ValueRef], bcx: block} { - let _icx = bcx.insn_ctxt("alt::extract_vec_elems"); + let _icx = bcx.insn_ctxt("match::extract_vec_elems"); let vt = tvec::vec_types(bcx, node_id_type(bcx, pat_id)); let unboxed = load_if_immediate(bcx, val, vt.vec_ty); let (base, len) = tvec::get_base_and_len(bcx, unboxed, vt.vec_ty); @@ -909,7 +909,7 @@ fn root_pats_as_necessary(bcx: block, m: &[@Match], match bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) { None => (), Some(scope_id) => { - // Note: the scope_id will always be the id of the alt. See + // Note: the scope_id will always be the id of the match. See // the extended comment in rustc::middle::borrowck::preserve() // for details (look for the case covering cat_discr). @@ -1201,7 +1201,7 @@ fn compile_submatch(bcx: block, For an empty match, a fall-through case must exist */ assert(m.len() > 0u || chk.is_some()); - let _icx = bcx.insn_ctxt("alt::compile_submatch"); + let _icx = bcx.insn_ctxt("match::compile_submatch"); let mut bcx = bcx; let tcx = bcx.tcx(), dm = tcx.def_map; if m.len() == 0u { @@ -1520,22 +1520,22 @@ fn compile_submatch(bcx: block, } } -fn trans_alt(bcx: block, - alt_expr: @ast::expr, +fn trans_match(bcx: block, + match_expr: @ast::expr, discr_expr: @ast::expr, arms: ~[ast::arm], dest: Dest) -> block { - let _icx = bcx.insn_ctxt("alt::trans_alt"); - do with_scope(bcx, alt_expr.info(), ~"alt") |bcx| { - trans_alt_inner(bcx, discr_expr, arms, dest) + let _icx = bcx.insn_ctxt("match::trans_match"); + do with_scope(bcx, match_expr.info(), ~"match") |bcx| { + trans_match_inner(bcx, discr_expr, arms, dest) } } -fn trans_alt_inner(scope_cx: block, +fn trans_match_inner(scope_cx: block, discr_expr: @ast::expr, arms: &[ast::arm], dest: Dest) -> block { - let _icx = scope_cx.insn_ctxt("alt::trans_alt_inner"); + let _icx = scope_cx.insn_ctxt("match::trans_match_inner"); let mut bcx = scope_cx; let tcx = bcx.tcx(); @@ -1655,18 +1655,18 @@ enum IrrefutablePatternBindingMode { BindArgument } -// Not alt-related, but similar to the pattern-munging code above +// Not match-related, but similar to the pattern-munging code above fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, make_copy: bool, binding_mode: IrrefutablePatternBindingMode) -> block { - let _icx = bcx.insn_ctxt("alt::bind_irrefutable_pat"); + let _icx = bcx.insn_ctxt("match::bind_irrefutable_pat"); let ccx = bcx.fcx.ccx; let mut bcx = bcx; - // Necessary since bind_irrefutable_pat is called outside trans_alt + // Necessary since bind_irrefutable_pat is called outside trans_match match /*bad*/copy pat.node { ast::pat_ident(_, _,inner) => { if pat_is_variant_or_struct(bcx.tcx().def_map, pat) { diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index c20747b54b5..c3b4adeaf8b 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -41,7 +41,7 @@ use metadata::{csearch, cstore, decoder, encoder}; use middle::astencode; use middle::pat_util::*; use middle::resolve; -use middle::trans::alt; +use middle::trans::_match; use middle::trans::build::*; use middle::trans::callee; use middle::trans::common::*; @@ -1045,11 +1045,11 @@ fn init_local(bcx: block, local: @ast::local) -> block { bcx.to_str()); add_clean(bcx, llptr, ty); - return alt::bind_irrefutable_pat(bcx, - local.node.pat, - llptr, - false, - alt::BindLocal); + return _match::bind_irrefutable_pat(bcx, + local.node.pat, + llptr, + false, + _match::BindLocal); } fn trans_stmt(cx: block, s: ast::stmt) -> block { @@ -1597,11 +1597,11 @@ fn copy_args_to_allocas(fcx: fn_ctxt, } } - bcx = alt::bind_irrefutable_pat(bcx, - args[arg_n].pat, - llarg, - false, - alt::BindArgument); + bcx = _match::bind_irrefutable_pat(bcx, + args[arg_n].pat, + llarg, + false, + _match::BindArgument); fcx.llargs.insert(arg_id, local_mem(llarg)); diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 78d19e9e0cb..10edfb2f929 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -266,7 +266,7 @@ fn create_block(cx: block) -> @metadata { let fname = /*bad*/copy start.file.name; let end = cx.sess().codemap.lookup_char_pos(sp.hi); let tg = LexicalBlockTag; - /*alt cached_metadata::<@metadata>( + /*match cached_metadata::<@metadata>( cache, tg, {|md| start == md.data.start && end == md.data.end}) { option::Some(md) { return md; } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index d2254097106..ed9abea465b 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -528,7 +528,8 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr, return controlflow::trans_if(bcx, cond, (*thn), els, dest); } ast::expr_match(discr, ref arms) => { - return alt::trans_alt(bcx, expr, discr, /*bad*/copy *arms, dest); + return _match::trans_match(bcx, expr, discr, /*bad*/copy *arms, + dest); } ast::expr_block(ref blk) => { return do base::with_scope(bcx, (*blk).info(), diff --git a/src/librustc/middle/typeck/check/alt.rs b/src/librustc/middle/typeck/check/_match.rs similarity index 98% rename from src/librustc/middle/typeck/check/alt.rs rename to src/librustc/middle/typeck/check/_match.rs index 95bd9a39769..7ff3dfcb073 100644 --- a/src/librustc/middle/typeck/check/alt.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -21,10 +21,10 @@ use syntax::ast_util::walk_pat; use syntax::ast_util; use syntax::print::pprust; -fn check_alt(fcx: @fn_ctxt, - expr: @ast::expr, - discrim: @ast::expr, - arms: ~[ast::arm]) -> bool { +fn check_match(fcx: @fn_ctxt, + expr: @ast::expr, + discrim: @ast::expr, + arms: ~[ast::arm]) -> bool { let tcx = fcx.ccx.tcx; let mut bot; @@ -37,7 +37,7 @@ fn check_alt(fcx: @fn_ctxt, let pcx = pat_ctxt { fcx: fcx, map: pat_id_map(tcx.def_map, arm.pats[0]), - alt_region: ty::re_scope(expr.id), + match_region: ty::re_scope(expr.id), block_region: ty::re_scope(arm.body.node.id) }; @@ -65,7 +65,7 @@ fn check_alt(fcx: @fn_ctxt, struct pat_ctxt { fcx: @fn_ctxt, map: PatIdMap, - alt_region: ty::Region, // Region for the alt as a whole + match_region: ty::Region, // Region for the match as a whole block_region: ty::Region, // Region for the block of the arm } @@ -389,7 +389,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { } fcx.write_ty(pat.id, typ); - debug!("(checking alt) writing type for pat id %d", pat.id); + debug!("(checking match) writing type for pat id %d", pat.id); match sub { Some(p) => check_pat(pcx, p, expected), diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index f4bae52bd91..4eaf6311148 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -85,7 +85,7 @@ use middle::ty; use middle::typeck::astconv::{ast_conv, ast_path_to_ty}; use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty}; use middle::typeck::astconv; -use middle::typeck::check::alt::pat_ctxt; +use middle::typeck::check::_match::pat_ctxt; use middle::typeck::check::method::TransformTypeNormally; use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_ty; use middle::typeck::check::vtable::{LocationInfo, VtableContext}; @@ -117,7 +117,7 @@ use syntax::print::pprust; use syntax::visit; use syntax; -export alt; +export _match; export vtable; export writeback; export regionmanip; @@ -133,7 +133,7 @@ export DoDerefArgs; export check_item_types; #[legacy_exports] -pub mod alt; +pub mod _match; #[legacy_exports] pub mod vtable; #[legacy_exports] @@ -427,10 +427,10 @@ fn check_fn(ccx: @crate_ctxt, let pcx = pat_ctxt { fcx: fcx, map: pat_id_map(tcx.def_map, input.pat), - alt_region: region, + match_region: region, block_region: region, }; - alt::check_pat(pcx, input.pat, *arg_ty); + _match::check_pat(pcx, input.pat, *arg_ty); } // Add explicitly-declared locals. @@ -2124,7 +2124,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, bot = !may_break(tcx, expr.id, (*body)); } ast::expr_match(discrim, ref arms) => { - bot = alt::check_alt(fcx, expr, discrim, (/*bad*/copy *arms)); + bot = _match::check_match(fcx, expr, discrim, (/*bad*/copy *arms)); } ast::expr_fn(proto, ref decl, ref body, cap_clause) => { check_expr_fn(fcx, expr, Some(proto), @@ -2517,10 +2517,10 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool { let pcx = pat_ctxt { fcx: fcx, map: pat_id_map(tcx.def_map, local.node.pat), - alt_region: region, + match_region: region, block_region: region, }; - alt::check_pat(pcx, local.node.pat, t); + _match::check_pat(pcx, local.node.pat, t); return bot; } diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 271d43087f3..60780df5287 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -77,7 +77,7 @@ mod middle { #[legacy_exports] mod base; #[legacy_exports] - mod alt; + mod _match; #[legacy_exports] mod uniq; #[legacy_exports] @@ -109,7 +109,7 @@ mod middle { #[legacy_exports] mod check_loop; #[legacy_exports] - mod check_alt; + mod check_match; #[legacy_exports] mod check_const; #[legacy_exports] diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index b5609f72523..12dd40356eb 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -158,7 +158,7 @@ fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { cx.sess.codemap.span_to_str(expr.span)) } ast::expr_match(*) => { - fmt!("", + fmt!("", cx.sess.codemap.span_to_str(expr.span)) } ast::expr_assign_op(*) | diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index c7b4a2b239a..724e2fc9dba 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -245,7 +245,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) /* at end of sequence */ if idx >= len { - // can't move out of `alt`s, so: + // can't move out of `match`es, so: if is_some(ei.up) { // hack: a matcher sequence is repeating iff it has a // parent (the top level is just a container) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f85ca3fefef..f32a782622a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -940,7 +940,7 @@ impl Parser { } else if self.eat_keyword(~"loop") { return self.parse_loop_expr(); } else if self.eat_keyword(~"match") { - return self.parse_alt_expr(); + return self.parse_match_expr(); } else if self.eat_keyword(~"fn") { let opt_proto = self.parse_fn_ty_proto(); let proto = match opt_proto { @@ -1722,7 +1722,7 @@ impl Parser { return expr_rec(fields, base); } - fn parse_alt_expr() -> @expr { + fn parse_match_expr() -> @expr { let lo = self.last_span.lo; let discriminant = self.parse_expr(); self.expect(token::LBRACE); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ad4080c3094..239cff22cc0 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -83,7 +83,7 @@ fn rust_printer(writer: io::Writer, intr: @ident_interner) -> ps { } const indent_unit: uint = 4u; -const alt_indent_unit: uint = 2u; +const match_indent_unit: uint = 2u; const default_columns: uint = 78u; @@ -1251,7 +1251,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { print_block(s, (*blk)); } ast::expr_match(expr, ref arms) => { - cbox(s, alt_indent_unit); + cbox(s, match_indent_unit); ibox(s, 4); word_nbsp(s, ~"match"); print_expr(s, expr); @@ -1260,7 +1260,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { let len = (*arms).len(); for (*arms).eachi |i, arm| { space(s.s); - cbox(s, alt_indent_unit); + cbox(s, match_indent_unit); ibox(s, 0u); let mut first = true; for arm.pats.each |p| { @@ -1293,7 +1293,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_block(ref blk) => { // the block will close the pattern's ibox print_block_unclosed_indent( - s, (*blk), alt_indent_unit); + s, (*blk), match_indent_unit); } _ => { end(s); // close the ibox for the pattern @@ -1310,10 +1310,10 @@ fn print_expr(s: ps, &&expr: @ast::expr) { } } else { // the block will close the pattern's ibox - print_block_unclosed_indent(s, arm.body, alt_indent_unit); + print_block_unclosed_indent(s, arm.body, match_indent_unit); } } - bclose_(s, expr.span, alt_indent_unit); + bclose_(s, expr.span, match_indent_unit); } ast::expr_fn(proto, decl, ref body, cap_clause) => { // containing cbox, will be closed by print-block at }