mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Merge pull request #4388 from lkuper/alt-to-match
Rename identifiers that still use 'alt' to use 'match'
This commit is contained in:
commit
2791877009
@ -275,8 +275,8 @@ fn compile_upto(sess: Session, cfg: ast::crate_cfg,
|
|||||||
time(time_passes, ~"mode computation", ||
|
time(time_passes, ~"mode computation", ||
|
||||||
middle::mode::compute_modes(ty_cx, method_map, crate));
|
middle::mode::compute_modes(ty_cx, method_map, crate));
|
||||||
|
|
||||||
time(time_passes, ~"alt checking", ||
|
time(time_passes, ~"match checking", ||
|
||||||
middle::check_alt::check_crate(ty_cx, method_map, crate));
|
middle::check_match::check_crate(ty_cx, method_map, crate));
|
||||||
|
|
||||||
let last_use_map =
|
let last_use_map =
|
||||||
time(time_passes, ~"liveness checking", ||
|
time(time_passes, ~"liveness checking", ||
|
||||||
|
@ -506,7 +506,7 @@ impl gather_loan_ctxt {
|
|||||||
discr_cmt: cmt,
|
discr_cmt: cmt,
|
||||||
root_pat: @ast::pat,
|
root_pat: @ast::pat,
|
||||||
arm_id: ast::node_id,
|
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| {
|
do self.bccx.cat_pattern(discr_cmt, root_pat) |cmt, pat| {
|
||||||
match pat.node {
|
match pat.node {
|
||||||
ast::pat_ident(bm, _, _) if self.pat_is_binding(pat) => {
|
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 => {
|
ast::bind_by_value | ast::bind_by_move => {
|
||||||
// copying does not borrow anything, so no check
|
// copying does not borrow anything, so no check
|
||||||
// is required
|
// 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) => {
|
ast::bind_by_ref(mutbl) => {
|
||||||
// ref x or ref x @ p --- creates a ptr which must
|
// 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
|
// find the region of the resulting pointer (note that
|
||||||
// the type of such a pattern will *always* be a
|
// 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():
|
// of the function of this node in method preserve():
|
||||||
let arm_scope = ty::re_scope(arm_id);
|
let arm_scope = ty::re_scope(arm_id);
|
||||||
if self.bccx.is_subregion_of(scope_r, arm_scope) {
|
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);
|
self.guarantee_valid(cmt_discr, mutbl, scope_r);
|
||||||
} else {
|
} else {
|
||||||
self.guarantee_valid(cmt, mutbl, scope_r);
|
self.guarantee_valid(cmt, mutbl, scope_r);
|
||||||
|
@ -494,8 +494,8 @@ impl borrowck_ctxt {
|
|||||||
cat_variant(self.tcx, self.method_map, arg, enum_did, cmt)
|
cat_variant(self.tcx, self.method_map, arg, enum_did, cmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_discr(cmt: cmt, alt_id: ast::node_id) -> cmt {
|
fn cat_discr(cmt: cmt, match_id: ast::node_id) -> cmt {
|
||||||
return @{cat:cat_discr(cmt, alt_id),.. *cmt};
|
return @{cat:cat_discr(cmt, match_id),.. *cmt};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_pattern(cmt: cmt, pat: @ast::pat, op: fn(cmt, @ast::pat)) {
|
fn cat_pattern(cmt: cmt, pat: @ast::pat, op: fn(cmt, @ast::pat)) {
|
||||||
|
@ -195,15 +195,15 @@ priv impl &preserve_ctxt {
|
|||||||
self.attempt_root(cmt, base, derefs)
|
self.attempt_root(cmt, base, derefs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cat_discr(base, alt_id) => {
|
cat_discr(base, match_id) => {
|
||||||
// Subtle: in an alt, we must ensure that each binding
|
// Subtle: in a match, we must ensure that each binding
|
||||||
// variable remains valid for the duration of the arm in
|
// variable remains valid for the duration of the arm in
|
||||||
// which it appears, presuming that this arm is taken.
|
// which it appears, presuming that this arm is taken.
|
||||||
// But it is inconvenient in trans to root something just
|
// But it is inconvenient in trans to root something just
|
||||||
// for one arm. Therefore, we insert a cat_discr(),
|
// for one arm. Therefore, we insert a cat_discr(),
|
||||||
// basically a special kind of category that says "if this
|
// basically a special kind of category that says "if this
|
||||||
// value must be dynamically rooted, root it for the scope
|
// value must be dynamically rooted, root it for the scope
|
||||||
// `alt_id`.
|
// `match_id`.
|
||||||
//
|
//
|
||||||
// As an example, consider this scenario:
|
// As an example, consider this scenario:
|
||||||
//
|
//
|
||||||
@ -213,7 +213,7 @@ priv impl &preserve_ctxt {
|
|||||||
// Technically, the value `x` need only be rooted
|
// Technically, the value `x` need only be rooted
|
||||||
// in the `some` arm. However, we evaluate `x` in trans
|
// in the `some` arm. However, we evaluate `x` in trans
|
||||||
// before we know what arm will be taken, so we just
|
// 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:
|
// As a second example, consider *this* scenario:
|
||||||
//
|
//
|
||||||
@ -225,7 +225,7 @@ priv impl &preserve_ctxt {
|
|||||||
// found only when checking which pattern matches: but
|
// found only when checking which pattern matches: but
|
||||||
// this check is done before entering the arm. Therefore,
|
// this check is done before entering the arm. Therefore,
|
||||||
// even in this case we just choose to keep the value
|
// 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.
|
// rooted even if the none arm is taken. Oh well.
|
||||||
//
|
//
|
||||||
// At first, I tried to optimize the second case to only
|
// 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
|
// Nonetheless, if you decide to optimize this case in the
|
||||||
// future, you need only adjust where the cat_discr()
|
// future, you need only adjust where the cat_discr()
|
||||||
// node appears to draw the line between what will be rooted
|
// 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 =
|
let match_rooting_ctxt =
|
||||||
preserve_ctxt({scope_region: ty::re_scope(alt_id),
|
preserve_ctxt({scope_region: ty::re_scope(match_id),
|
||||||
.. **self});
|
.. **self});
|
||||||
(&alt_rooting_ctxt).preserve(base)
|
(&match_rooting_ctxt).preserve(base)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,13 @@ use syntax::codemap::span;
|
|||||||
use syntax::print::pprust::pat_to_str;
|
use syntax::print::pprust::pat_to_str;
|
||||||
use syntax::visit;
|
use syntax::visit;
|
||||||
|
|
||||||
struct AltCheckCtxt {
|
struct MatchCheckCtxt {
|
||||||
tcx: ty::ctxt,
|
tcx: ty::ctxt,
|
||||||
method_map: method_map,
|
method_map: method_map,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_crate(tcx: ty::ctxt, method_map: method_map, crate: @crate) {
|
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::visit_crate(*crate, (), visit::mk_vt(@{
|
||||||
visit_expr: |a,b,c| check_expr(cx, a, b, c),
|
visit_expr: |a,b,c| check_expr(cx, a, b, c),
|
||||||
visit_local: |a,b,c| check_local(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();
|
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) {
|
if !ty::expr_is_lval(cx.tcx, cx.method_map, expr) {
|
||||||
return false;
|
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);
|
visit::visit_expr(ex, s, v);
|
||||||
match ex.node {
|
match ex.node {
|
||||||
expr_match(scrut, ref arms) => {
|
expr_match(scrut, ref arms) => {
|
||||||
@ -107,7 +107,7 @@ fn check_expr(cx: @AltCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for unreachable patterns
|
// Check for unreachable patterns
|
||||||
fn check_arms(cx: @AltCheckCtxt, arms: ~[arm]) {
|
fn check_arms(cx: @MatchCheckCtxt, arms: ~[arm]) {
|
||||||
let mut seen = ~[];
|
let mut seen = ~[];
|
||||||
for arms.each |arm| {
|
for arms.each |arm| {
|
||||||
for arm.pats.each |pat| {
|
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());
|
assert(pats.is_not_empty());
|
||||||
let ext = match is_useful(cx, vec::map(pats, |p| ~[*p]), ~[wild()]) {
|
let ext = match is_useful(cx, vec::map(pats, |p| ~[*p]), ~[wild()]) {
|
||||||
not_useful => return, // This is good, wildcard pattern isn't reachable
|
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.
|
// Note: is_useful doesn't work on empty types, as the paper notes.
|
||||||
// So it assumes that v is non-empty.
|
// 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.len() == 0u { return useful_; }
|
||||||
if m[0].len() == 0u { return not_useful; }
|
if m[0].len() == 0u { return not_useful; }
|
||||||
let real_pat = match vec::find(m, |r| r[0].id != 0) {
|
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 {
|
+ctor: ctor, arity: uint, lty: ty::t) -> useful {
|
||||||
let ms = vec::filter_map(m, |r| specialize(cx, *r, ctor, arity, lty));
|
let ms = vec::filter_map(m, |r| specialize(cx, *r, ctor, arity, lty));
|
||||||
let could_be_useful = is_useful(
|
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<ctor> {
|
fn pat_ctor_id(cx: @MatchCheckCtxt, p: @pat) -> Option<ctor> {
|
||||||
let pat = raw_pat(p);
|
let pat = raw_pat(p);
|
||||||
match /*bad*/copy pat.node {
|
match /*bad*/copy pat.node {
|
||||||
pat_wild => { None }
|
pat_wild => { None }
|
||||||
@ -337,7 +337,7 @@ fn pat_ctor_id(cx: @AltCheckCtxt, p: @pat) -> Option<ctor> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_wild(cx: @AltCheckCtxt, p: @pat) -> bool {
|
fn is_wild(cx: @MatchCheckCtxt, p: @pat) -> bool {
|
||||||
let pat = raw_pat(p);
|
let pat = raw_pat(p);
|
||||||
match pat.node {
|
match pat.node {
|
||||||
pat_wild => { true }
|
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,
|
m: matrix,
|
||||||
left_ty: ty::t)
|
left_ty: ty::t)
|
||||||
-> Option<ctor> {
|
-> Option<ctor> {
|
||||||
@ -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 {
|
match /*bad*/copy ty::get(ty).sty {
|
||||||
ty::ty_tup(fs) => fs.len(),
|
ty::ty_tup(fs) => fs.len(),
|
||||||
ty::ty_rec(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()}
|
@{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]> {
|
left_ty: ty::t) -> Option<~[@pat]> {
|
||||||
let r0 = raw_pat(r[0]);
|
let r0 = raw_pat(r[0]);
|
||||||
match /*bad*/copy r0.node {
|
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)) }
|
if is_wild(cx, r[0]) { Some(vec::tail(r)) }
|
||||||
else { None }
|
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);
|
visit::visit_local(loc, s, v);
|
||||||
if is_refutable(cx, loc.node.pat) {
|
if is_refutable(cx, loc.node.pat) {
|
||||||
cx.tcx.sess.span_err(loc.node.pat.span,
|
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 ]);
|
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,
|
kind: visit::fn_kind,
|
||||||
decl: fn_decl,
|
decl: fn_decl,
|
||||||
body: blk,
|
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) {
|
match cx.tcx.def_map.find(pat.id) {
|
||||||
Some(def_variant(enum_id, _)) => {
|
Some(def_variant(enum_id, _)) => {
|
||||||
if vec::len(*ty::enum_variants(cx.tcx, enum_id)) != 1u {
|
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
|
// Legality of move bindings checking
|
||||||
|
|
||||||
fn check_legality_of_move_bindings(cx: @AltCheckCtxt,
|
fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
|
||||||
is_lvalue: bool,
|
is_lvalue: bool,
|
||||||
has_guard: bool,
|
has_guard: bool,
|
||||||
pats: &[@pat]) {
|
pats: &[@pat]) {
|
@ -46,7 +46,7 @@ use syntax::ast::*;
|
|||||||
// & and * pointers
|
// & and * pointers
|
||||||
// copies of general constants
|
// 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)
|
// conditions / descriminants)
|
||||||
//
|
//
|
||||||
// - Non-constants: everything else.
|
// - Non-constants: everything else.
|
||||||
|
@ -904,7 +904,7 @@ impl &mem_categorization_ctxt {
|
|||||||
// local(x)->@->@
|
// local(x)->@->@
|
||||||
//
|
//
|
||||||
// where the id of `local(x)` is the id of the `x` that appears
|
// 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.
|
// and the id of `local(x)->@->@` is the id of the `y` pattern.
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ struct ctxt {
|
|||||||
// that when we visit it we can view it as a parent.
|
// that when we visit it we can view it as a parent.
|
||||||
root_exprs: HashMap<ast::node_id, ()>,
|
root_exprs: HashMap<ast::node_id, ()>,
|
||||||
|
|
||||||
// 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
|
// expression during the execution of which the current expression
|
||||||
// will be evaluated. Generally speaking, the innermost parent
|
// will be evaluated. Generally speaking, the innermost parent
|
||||||
// scope is also the closest suitable ancestor in the AST tree.
|
// scope is also the closest suitable ancestor in the AST tree.
|
||||||
|
@ -245,7 +245,7 @@ enum opt_result {
|
|||||||
range_result(Result, Result),
|
range_result(Result, Result),
|
||||||
}
|
}
|
||||||
fn trans_opt(bcx: block, o: &Opt) -> opt_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 ccx = bcx.ccx();
|
||||||
let mut bcx = bcx;
|
let mut bcx = bcx;
|
||||||
match *o {
|
match *o {
|
||||||
@ -463,8 +463,8 @@ fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r],
|
|||||||
}
|
}
|
||||||
|
|
||||||
// <pcwalton> nmatsakis: what does enter_opt do?
|
// <pcwalton> nmatsakis: what does enter_opt do?
|
||||||
// <pcwalton> in trans/alt
|
// <pcwalton> in trans/match
|
||||||
// <pcwalton> trans/alt.rs is like stumbling around in a dark cave
|
// <pcwalton> trans/match.rs is like stumbling around in a dark cave
|
||||||
// <nmatsakis> pcwalton: the enter family of functions adjust the set of
|
// <nmatsakis> pcwalton: the enter family of functions adjust the set of
|
||||||
// patterns as needed
|
// patterns as needed
|
||||||
// <nmatsakis> yeah, at some point I kind of achieved some level of
|
// <nmatsakis> 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)
|
val: ValueRef)
|
||||||
-> {vals: ~[ValueRef], bcx: block}
|
-> {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 ccx = bcx.fcx.ccx;
|
||||||
let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id)).sty {
|
let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id)).sty {
|
||||||
ty::ty_enum(id, ref substs) => {
|
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)
|
elem_count: uint, tail: bool, val: ValueRef)
|
||||||
-> {vals: ~[ValueRef], bcx: block}
|
-> {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 vt = tvec::vec_types(bcx, node_id_type(bcx, pat_id));
|
||||||
let unboxed = load_if_immediate(bcx, val, vt.vec_ty);
|
let unboxed = load_if_immediate(bcx, val, vt.vec_ty);
|
||||||
let (base, len) = tvec::get_base_and_len(bcx, unboxed, 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}) {
|
match bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) {
|
||||||
None => (),
|
None => (),
|
||||||
Some(scope_id) => {
|
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()
|
// the extended comment in rustc::middle::borrowck::preserve()
|
||||||
// for details (look for the case covering cat_discr).
|
// 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
|
For an empty match, a fall-through case must exist
|
||||||
*/
|
*/
|
||||||
assert(m.len() > 0u || chk.is_some());
|
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 mut bcx = bcx;
|
||||||
let tcx = bcx.tcx(), dm = tcx.def_map;
|
let tcx = bcx.tcx(), dm = tcx.def_map;
|
||||||
if m.len() == 0u {
|
if m.len() == 0u {
|
||||||
@ -1520,22 +1520,22 @@ fn compile_submatch(bcx: block,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trans_alt(bcx: block,
|
fn trans_match(bcx: block,
|
||||||
alt_expr: @ast::expr,
|
match_expr: @ast::expr,
|
||||||
discr_expr: @ast::expr,
|
discr_expr: @ast::expr,
|
||||||
arms: ~[ast::arm],
|
arms: ~[ast::arm],
|
||||||
dest: Dest) -> block {
|
dest: Dest) -> block {
|
||||||
let _icx = bcx.insn_ctxt("alt::trans_alt");
|
let _icx = bcx.insn_ctxt("match::trans_match");
|
||||||
do with_scope(bcx, alt_expr.info(), ~"alt") |bcx| {
|
do with_scope(bcx, match_expr.info(), ~"match") |bcx| {
|
||||||
trans_alt_inner(bcx, discr_expr, arms, dest)
|
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,
|
discr_expr: @ast::expr,
|
||||||
arms: &[ast::arm],
|
arms: &[ast::arm],
|
||||||
dest: Dest) -> block {
|
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 mut bcx = scope_cx;
|
||||||
let tcx = bcx.tcx();
|
let tcx = bcx.tcx();
|
||||||
|
|
||||||
@ -1655,18 +1655,18 @@ enum IrrefutablePatternBindingMode {
|
|||||||
BindArgument
|
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,
|
fn bind_irrefutable_pat(bcx: block,
|
||||||
pat: @ast::pat,
|
pat: @ast::pat,
|
||||||
val: ValueRef,
|
val: ValueRef,
|
||||||
make_copy: bool,
|
make_copy: bool,
|
||||||
binding_mode: IrrefutablePatternBindingMode)
|
binding_mode: IrrefutablePatternBindingMode)
|
||||||
-> block {
|
-> 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 ccx = bcx.fcx.ccx;
|
||||||
let mut bcx = bcx;
|
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 {
|
match /*bad*/copy pat.node {
|
||||||
ast::pat_ident(_, _,inner) => {
|
ast::pat_ident(_, _,inner) => {
|
||||||
if pat_is_variant_or_struct(bcx.tcx().def_map, pat) {
|
if pat_is_variant_or_struct(bcx.tcx().def_map, pat) {
|
@ -41,7 +41,7 @@ use metadata::{csearch, cstore, decoder, encoder};
|
|||||||
use middle::astencode;
|
use middle::astencode;
|
||||||
use middle::pat_util::*;
|
use middle::pat_util::*;
|
||||||
use middle::resolve;
|
use middle::resolve;
|
||||||
use middle::trans::alt;
|
use middle::trans::_match;
|
||||||
use middle::trans::build::*;
|
use middle::trans::build::*;
|
||||||
use middle::trans::callee;
|
use middle::trans::callee;
|
||||||
use middle::trans::common::*;
|
use middle::trans::common::*;
|
||||||
@ -1045,11 +1045,11 @@ fn init_local(bcx: block, local: @ast::local) -> block {
|
|||||||
bcx.to_str());
|
bcx.to_str());
|
||||||
add_clean(bcx, llptr, ty);
|
add_clean(bcx, llptr, ty);
|
||||||
|
|
||||||
return alt::bind_irrefutable_pat(bcx,
|
return _match::bind_irrefutable_pat(bcx,
|
||||||
local.node.pat,
|
local.node.pat,
|
||||||
llptr,
|
llptr,
|
||||||
false,
|
false,
|
||||||
alt::BindLocal);
|
_match::BindLocal);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trans_stmt(cx: block, s: ast::stmt) -> block {
|
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,
|
bcx = _match::bind_irrefutable_pat(bcx,
|
||||||
args[arg_n].pat,
|
args[arg_n].pat,
|
||||||
llarg,
|
llarg,
|
||||||
false,
|
false,
|
||||||
alt::BindArgument);
|
_match::BindArgument);
|
||||||
|
|
||||||
fcx.llargs.insert(arg_id, local_mem(llarg));
|
fcx.llargs.insert(arg_id, local_mem(llarg));
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ fn create_block(cx: block) -> @metadata<block_md> {
|
|||||||
let fname = /*bad*/copy start.file.name;
|
let fname = /*bad*/copy start.file.name;
|
||||||
let end = cx.sess().codemap.lookup_char_pos(sp.hi);
|
let end = cx.sess().codemap.lookup_char_pos(sp.hi);
|
||||||
let tg = LexicalBlockTag;
|
let tg = LexicalBlockTag;
|
||||||
/*alt cached_metadata::<@metadata<block_md>>(
|
/*match cached_metadata::<@metadata<block_md>>(
|
||||||
cache, tg,
|
cache, tg,
|
||||||
{|md| start == md.data.start && end == md.data.end}) {
|
{|md| start == md.data.start && end == md.data.end}) {
|
||||||
option::Some(md) { return md; }
|
option::Some(md) { return md; }
|
||||||
|
@ -528,7 +528,8 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
|
|||||||
return controlflow::trans_if(bcx, cond, (*thn), els, dest);
|
return controlflow::trans_if(bcx, cond, (*thn), els, dest);
|
||||||
}
|
}
|
||||||
ast::expr_match(discr, ref arms) => {
|
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) => {
|
ast::expr_block(ref blk) => {
|
||||||
return do base::with_scope(bcx, (*blk).info(),
|
return do base::with_scope(bcx, (*blk).info(),
|
||||||
|
@ -21,10 +21,10 @@ use syntax::ast_util::walk_pat;
|
|||||||
use syntax::ast_util;
|
use syntax::ast_util;
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
|
|
||||||
fn check_alt(fcx: @fn_ctxt,
|
fn check_match(fcx: @fn_ctxt,
|
||||||
expr: @ast::expr,
|
expr: @ast::expr,
|
||||||
discrim: @ast::expr,
|
discrim: @ast::expr,
|
||||||
arms: ~[ast::arm]) -> bool {
|
arms: ~[ast::arm]) -> bool {
|
||||||
let tcx = fcx.ccx.tcx;
|
let tcx = fcx.ccx.tcx;
|
||||||
let mut bot;
|
let mut bot;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ fn check_alt(fcx: @fn_ctxt,
|
|||||||
let pcx = pat_ctxt {
|
let pcx = pat_ctxt {
|
||||||
fcx: fcx,
|
fcx: fcx,
|
||||||
map: pat_id_map(tcx.def_map, arm.pats[0]),
|
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)
|
block_region: ty::re_scope(arm.body.node.id)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ fn check_alt(fcx: @fn_ctxt,
|
|||||||
struct pat_ctxt {
|
struct pat_ctxt {
|
||||||
fcx: @fn_ctxt,
|
fcx: @fn_ctxt,
|
||||||
map: PatIdMap,
|
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
|
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);
|
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 {
|
match sub {
|
||||||
Some(p) => check_pat(pcx, p, expected),
|
Some(p) => check_pat(pcx, p, expected),
|
@ -85,7 +85,7 @@ use middle::ty;
|
|||||||
use middle::typeck::astconv::{ast_conv, ast_path_to_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::{ast_region_to_region, ast_ty_to_ty};
|
||||||
use middle::typeck::astconv;
|
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::method::TransformTypeNormally;
|
||||||
use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_ty;
|
use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_ty;
|
||||||
use middle::typeck::check::vtable::{LocationInfo, VtableContext};
|
use middle::typeck::check::vtable::{LocationInfo, VtableContext};
|
||||||
@ -117,7 +117,7 @@ use syntax::print::pprust;
|
|||||||
use syntax::visit;
|
use syntax::visit;
|
||||||
use syntax;
|
use syntax;
|
||||||
|
|
||||||
export alt;
|
export _match;
|
||||||
export vtable;
|
export vtable;
|
||||||
export writeback;
|
export writeback;
|
||||||
export regionmanip;
|
export regionmanip;
|
||||||
@ -133,7 +133,7 @@ export DoDerefArgs;
|
|||||||
export check_item_types;
|
export check_item_types;
|
||||||
|
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
pub mod alt;
|
pub mod _match;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
pub mod vtable;
|
pub mod vtable;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
@ -427,10 +427,10 @@ fn check_fn(ccx: @crate_ctxt,
|
|||||||
let pcx = pat_ctxt {
|
let pcx = pat_ctxt {
|
||||||
fcx: fcx,
|
fcx: fcx,
|
||||||
map: pat_id_map(tcx.def_map, input.pat),
|
map: pat_id_map(tcx.def_map, input.pat),
|
||||||
alt_region: region,
|
match_region: region,
|
||||||
block_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.
|
// Add explicitly-declared locals.
|
||||||
@ -2124,7 +2124,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||||||
bot = !may_break(tcx, expr.id, (*body));
|
bot = !may_break(tcx, expr.id, (*body));
|
||||||
}
|
}
|
||||||
ast::expr_match(discrim, ref arms) => {
|
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) => {
|
ast::expr_fn(proto, ref decl, ref body, cap_clause) => {
|
||||||
check_expr_fn(fcx, expr, Some(proto),
|
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 {
|
let pcx = pat_ctxt {
|
||||||
fcx: fcx,
|
fcx: fcx,
|
||||||
map: pat_id_map(tcx.def_map, local.node.pat),
|
map: pat_id_map(tcx.def_map, local.node.pat),
|
||||||
alt_region: region,
|
match_region: region,
|
||||||
block_region: region,
|
block_region: region,
|
||||||
};
|
};
|
||||||
alt::check_pat(pcx, local.node.pat, t);
|
_match::check_pat(pcx, local.node.pat, t);
|
||||||
return bot;
|
return bot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ mod middle {
|
|||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod base;
|
mod base;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod alt;
|
mod _match;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod uniq;
|
mod uniq;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
@ -109,7 +109,7 @@ mod middle {
|
|||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod check_loop;
|
mod check_loop;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod check_alt;
|
mod check_match;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod check_const;
|
mod check_const;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
|
@ -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))
|
cx.sess.codemap.span_to_str(expr.span))
|
||||||
}
|
}
|
||||||
ast::expr_match(*) => {
|
ast::expr_match(*) => {
|
||||||
fmt!("<alt at %s>",
|
fmt!("<match at %s>",
|
||||||
cx.sess.codemap.span_to_str(expr.span))
|
cx.sess.codemap.span_to_str(expr.span))
|
||||||
}
|
}
|
||||||
ast::expr_assign_op(*) |
|
ast::expr_assign_op(*) |
|
||||||
|
@ -245,7 +245,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
|
|||||||
|
|
||||||
/* at end of sequence */
|
/* at end of sequence */
|
||||||
if idx >= len {
|
if idx >= len {
|
||||||
// can't move out of `alt`s, so:
|
// can't move out of `match`es, so:
|
||||||
if is_some(ei.up) {
|
if is_some(ei.up) {
|
||||||
// hack: a matcher sequence is repeating iff it has a
|
// hack: a matcher sequence is repeating iff it has a
|
||||||
// parent (the top level is just a container)
|
// parent (the top level is just a container)
|
||||||
|
@ -940,7 +940,7 @@ impl Parser {
|
|||||||
} else if self.eat_keyword(~"loop") {
|
} else if self.eat_keyword(~"loop") {
|
||||||
return self.parse_loop_expr();
|
return self.parse_loop_expr();
|
||||||
} else if self.eat_keyword(~"match") {
|
} else if self.eat_keyword(~"match") {
|
||||||
return self.parse_alt_expr();
|
return self.parse_match_expr();
|
||||||
} else if self.eat_keyword(~"fn") {
|
} else if self.eat_keyword(~"fn") {
|
||||||
let opt_proto = self.parse_fn_ty_proto();
|
let opt_proto = self.parse_fn_ty_proto();
|
||||||
let proto = match opt_proto {
|
let proto = match opt_proto {
|
||||||
@ -1722,7 +1722,7 @@ impl Parser {
|
|||||||
return expr_rec(fields, base);
|
return expr_rec(fields, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_alt_expr() -> @expr {
|
fn parse_match_expr() -> @expr {
|
||||||
let lo = self.last_span.lo;
|
let lo = self.last_span.lo;
|
||||||
let discriminant = self.parse_expr();
|
let discriminant = self.parse_expr();
|
||||||
self.expect(token::LBRACE);
|
self.expect(token::LBRACE);
|
||||||
|
@ -83,7 +83,7 @@ fn rust_printer(writer: io::Writer, intr: @ident_interner) -> ps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const indent_unit: uint = 4u;
|
const indent_unit: uint = 4u;
|
||||||
const alt_indent_unit: uint = 2u;
|
const match_indent_unit: uint = 2u;
|
||||||
|
|
||||||
const default_columns: uint = 78u;
|
const default_columns: uint = 78u;
|
||||||
|
|
||||||
@ -1251,7 +1251,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||||||
print_block(s, (*blk));
|
print_block(s, (*blk));
|
||||||
}
|
}
|
||||||
ast::expr_match(expr, ref arms) => {
|
ast::expr_match(expr, ref arms) => {
|
||||||
cbox(s, alt_indent_unit);
|
cbox(s, match_indent_unit);
|
||||||
ibox(s, 4);
|
ibox(s, 4);
|
||||||
word_nbsp(s, ~"match");
|
word_nbsp(s, ~"match");
|
||||||
print_expr(s, expr);
|
print_expr(s, expr);
|
||||||
@ -1260,7 +1260,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||||||
let len = (*arms).len();
|
let len = (*arms).len();
|
||||||
for (*arms).eachi |i, arm| {
|
for (*arms).eachi |i, arm| {
|
||||||
space(s.s);
|
space(s.s);
|
||||||
cbox(s, alt_indent_unit);
|
cbox(s, match_indent_unit);
|
||||||
ibox(s, 0u);
|
ibox(s, 0u);
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for arm.pats.each |p| {
|
for arm.pats.each |p| {
|
||||||
@ -1293,7 +1293,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||||||
ast::expr_block(ref blk) => {
|
ast::expr_block(ref blk) => {
|
||||||
// the block will close the pattern's ibox
|
// the block will close the pattern's ibox
|
||||||
print_block_unclosed_indent(
|
print_block_unclosed_indent(
|
||||||
s, (*blk), alt_indent_unit);
|
s, (*blk), match_indent_unit);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
end(s); // close the ibox for the pattern
|
end(s); // close the ibox for the pattern
|
||||||
@ -1310,10 +1310,10 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// the block will close the pattern's ibox
|
// 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) => {
|
ast::expr_fn(proto, decl, ref body, cap_clause) => {
|
||||||
// containing cbox, will be closed by print-block at }
|
// containing cbox, will be closed by print-block at }
|
||||||
|
Loading…
Reference in New Issue
Block a user