Incorporate review comments (mostly fixing indentation)
Previous commit was r=nmatsakis
This commit is contained in:
@@ -502,9 +502,9 @@ fn visit_expr(expr: @expr, &&self: @IrMaps, vt: vt<@IrMaps>) {
|
|||||||
}
|
}
|
||||||
expr_fn(_, _, _, cap_clause) |
|
expr_fn(_, _, _, cap_clause) |
|
||||||
expr_fn_block(_, _, cap_clause) => {
|
expr_fn_block(_, _, cap_clause) => {
|
||||||
// Interesting control flow (for loops can contain labeled
|
// Interesting control flow (for loops can contain labeled
|
||||||
// breaks or continues)
|
// breaks or continues)
|
||||||
self.add_live_node_for_node(expr.id, ExprNode(expr.span));
|
self.add_live_node_for_node(expr.id, ExprNode(expr.span));
|
||||||
|
|
||||||
// Make a live_node for each captured variable, with the span
|
// Make a live_node for each captured variable, with the span
|
||||||
// being the location that the variable is used. This results
|
// being the location that the variable is used. This results
|
||||||
@@ -596,7 +596,7 @@ struct Liveness {
|
|||||||
users: ~[mut users],
|
users: ~[mut users],
|
||||||
// The list of node IDs for the nested loop scopes
|
// The list of node IDs for the nested loop scopes
|
||||||
// we're in.
|
// we're in.
|
||||||
mut loop_scope: @DVec<node_id>,
|
loop_scope: DVec<node_id>,
|
||||||
// mappings from loop node ID to LiveNode
|
// mappings from loop node ID to LiveNode
|
||||||
// ("break" label should map to loop node ID,
|
// ("break" label should map to loop node ID,
|
||||||
// it probably doesn't now)
|
// it probably doesn't now)
|
||||||
@@ -778,10 +778,10 @@ impl Liveness {
|
|||||||
Some(_) => // Refers to a labeled loop. Use the results of resolve
|
Some(_) => // Refers to a labeled loop. Use the results of resolve
|
||||||
// to find with one
|
// to find with one
|
||||||
match self.tcx.def_map.find(id) {
|
match self.tcx.def_map.find(id) {
|
||||||
Some(def_label(loop_id)) => loop_id,
|
Some(def_label(loop_id)) => loop_id,
|
||||||
_ => self.tcx.sess.span_bug(sp, ~"Label on break/loop \
|
_ => self.tcx.sess.span_bug(sp, ~"Label on break/loop \
|
||||||
doesn't refer to a loop")
|
doesn't refer to a loop")
|
||||||
},
|
},
|
||||||
None =>
|
None =>
|
||||||
// Vanilla 'break' or 'loop', so use the enclosing
|
// Vanilla 'break' or 'loop', so use the enclosing
|
||||||
// loop scope
|
// loop scope
|
||||||
@@ -1024,7 +1024,7 @@ impl Liveness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn propagate_through_expr(expr: @expr, succ: LiveNode) -> LiveNode {
|
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()));
|
expr_to_str(expr, self.tcx.sess.intr()));
|
||||||
|
|
||||||
match expr.node {
|
match expr.node {
|
||||||
@@ -1039,7 +1039,7 @@ impl Liveness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expr_fn(_, _, blk, _) | expr_fn_block(_, blk, _) => {
|
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()));
|
expr_to_str(expr, self.tcx.sess.intr()));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ fn trans_while(bcx: block, cond: @ast::expr, body: ast::blk)
|
|||||||
// | body_bcx_out --+
|
// | body_bcx_out --+
|
||||||
// next_bcx
|
// next_bcx
|
||||||
|
|
||||||
// tjc: while should have labels...
|
|
||||||
let loop_bcx = loop_scope_block(bcx, next_bcx, None, ~"`while`",
|
let loop_bcx = loop_scope_block(bcx, next_bcx, None, ~"`while`",
|
||||||
body.info());
|
body.info());
|
||||||
let cond_bcx_in = scope_block(loop_bcx, cond.info(), ~"while loop cond");
|
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 {
|
match unwind.kind {
|
||||||
block_scope({loop_break: Some(brk), loop_label: l, _}) => {
|
block_scope({loop_break: Some(brk), loop_label: l, _}) => {
|
||||||
// If we're looking for a labeled loop, check the label...
|
// If we're looking for a labeled loop, check the label...
|
||||||
target = if to_end {
|
target = if to_end {
|
||||||
brk
|
brk
|
||||||
} else {
|
} else {
|
||||||
unwind
|
unwind
|
||||||
};
|
};
|
||||||
match opt_label {
|
match opt_label {
|
||||||
Some(desired) => match l {
|
Some(desired) => match l {
|
||||||
Some(actual) if actual == desired => break,
|
Some(actual) if actual == desired => break,
|
||||||
|
|||||||
@@ -2550,22 +2550,21 @@ fn may_break(cx: ty::ctxt, id: ast::node_id, b: ast::blk) -> bool {
|
|||||||
// inside the loop?
|
// inside the loop?
|
||||||
(loop_query(b, |e| {
|
(loop_query(b, |e| {
|
||||||
match e {
|
match e {
|
||||||
ast::expr_break(_) => true,
|
ast::expr_break(_) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
})) ||
|
})) ||
|
||||||
// Second: is there a labeled break with label
|
// Second: is there a labeled break with label
|
||||||
// <id> nested anywhere inside the loop?
|
// <id> nested anywhere inside the loop?
|
||||||
(block_query(b, |e| {
|
(block_query(b, |e| {
|
||||||
match e.node {
|
match e.node {
|
||||||
ast::expr_break(Some(_)) =>
|
ast::expr_break(Some(_)) =>
|
||||||
match cx.def_map.find(e.id) {
|
match cx.def_map.find(e.id) {
|
||||||
Some(ast::def_label(loop_id)) if id == loop_id => true,
|
Some(ast::def_label(loop_id)) if id == loop_id => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}}))
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_bounds_are_used(ccx: @crate_ctxt,
|
fn check_bounds_are_used(ccx: @crate_ctxt,
|
||||||
|
|||||||
Reference in New Issue
Block a user