Incorporate review comments (mostly fixing indentation)

Previous commit was r=nmatsakis
This commit is contained in:
Tim Chevalier 2012-10-22 09:44:56 -07:00
parent dd66e7549b
commit dca0776747
3 changed files with 26 additions and 28 deletions

View File

@ -502,9 +502,9 @@ fn visit_expr(expr: @expr, &&self: @IrMaps, vt: vt<@IrMaps>) {
}
expr_fn(_, _, _, cap_clause) |
expr_fn_block(_, _, cap_clause) => {
// Interesting control flow (for loops can contain labeled
// breaks or continues)
self.add_live_node_for_node(expr.id, ExprNode(expr.span));
// Interesting control flow (for loops can contain labeled
// breaks or continues)
self.add_live_node_for_node(expr.id, ExprNode(expr.span));
// Make a live_node for each captured variable, with the span
// being the location that the variable is used. This results
@ -596,7 +596,7 @@ struct Liveness {
users: ~[mut users],
// The list of node IDs for the nested loop scopes
// we're in.
mut loop_scope: @DVec<node_id>,
loop_scope: DVec<node_id>,
// mappings from loop node ID to LiveNode
// ("break" label should map to loop node ID,
// it probably doesn't now)
@ -778,10 +778,10 @@ impl Liveness {
Some(_) => // Refers to a labeled loop. Use the results of resolve
// to find with one
match self.tcx.def_map.find(id) {
Some(def_label(loop_id)) => loop_id,
_ => self.tcx.sess.span_bug(sp, ~"Label on break/loop \
doesn't refer to a loop")
},
Some(def_label(loop_id)) => loop_id,
_ => self.tcx.sess.span_bug(sp, ~"Label on break/loop \
doesn't refer to a loop")
},
None =>
// Vanilla 'break' or 'loop', so use the enclosing
// loop scope
@ -1024,7 +1024,7 @@ impl Liveness {
}
fn propagate_through_expr(expr: @expr, succ: LiveNode) -> LiveNode {
debug!("propagate_through_expr: %s",
debug!("propagate_through_expr: %s",
expr_to_str(expr, self.tcx.sess.intr()));
match expr.node {
@ -1039,7 +1039,7 @@ impl Liveness {
}
expr_fn(_, _, blk, _) | expr_fn_block(_, blk, _) => {
debug!("%s is an expr_fn or expr_fn_block",
debug!("%s is an expr_fn or expr_fn_block",
expr_to_str(expr, self.tcx.sess.intr()));
/*

View File

@ -113,7 +113,6 @@ fn trans_while(bcx: block, cond: @ast::expr, body: ast::blk)
// | body_bcx_out --+
// next_bcx
// tjc: while should have labels...
let loop_bcx = loop_scope_block(bcx, next_bcx, None, ~"`while`",
body.info());
let cond_bcx_in = scope_block(loop_bcx, cond.info(), ~"while loop cond");
@ -214,11 +213,11 @@ fn trans_break_cont(bcx: block, opt_label: Option<ident>, to_end: bool)
match unwind.kind {
block_scope({loop_break: Some(brk), loop_label: l, _}) => {
// If we're looking for a labeled loop, check the label...
target = if to_end {
brk
} else {
unwind
};
target = if to_end {
brk
} else {
unwind
};
match opt_label {
Some(desired) => match l {
Some(actual) if actual == desired => break,

View File

@ -2550,22 +2550,21 @@ fn may_break(cx: ty::ctxt, id: ast::node_id, b: ast::blk) -> bool {
// inside the loop?
(loop_query(b, |e| {
match e {
ast::expr_break(_) => true,
_ => false
ast::expr_break(_) => true,
_ => false
}
})) ||
// Second: is there a labeled break with label
// <id> nested anywhere inside the loop?
(block_query(b, |e| {
match e.node {
ast::expr_break(Some(_)) =>
match cx.def_map.find(e.id) {
Some(ast::def_label(loop_id)) if id == loop_id => true,
_ => false,
},
_ => false
}
}))
(block_query(b, |e| {
match e.node {
ast::expr_break(Some(_)) =>
match cx.def_map.find(e.id) {
Some(ast::def_label(loop_id)) if id == loop_id => true,
_ => false,
},
_ => false
}}))
}
fn check_bounds_are_used(ccx: @crate_ctxt,