Skip to content

Commit 43c26e6

Browse files
committed
auto merge of #16190 : Pythoner6/rust/labeled-while-loop, r=alexcrichton
Fixes #12643 > Say! > I like labelled breaks/continues! I will use them with a `for` loop. And I will use with a `loop` loop. Say! I will use them ANYWHERE! … _even_ in a `while` loop. Because they're now supported there.
2 parents c8e86e9 + e76db8e commit 43c26e6

File tree

21 files changed

+106
-33
lines changed

21 files changed

+106
-33
lines changed

src/librustc/lint/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl LintPass for WhileTrue {
5858

5959
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
6060
match e.node {
61-
ast::ExprWhile(cond, _) => {
61+
ast::ExprWhile(cond, _, _) => {
6262
match cond.node {
6363
ast::ExprLit(lit) => {
6464
match lit.node {
@@ -1073,7 +1073,7 @@ impl LintPass for UnnecessaryParens {
10731073
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
10741074
let (value, msg, struct_lit_needs_parens) = match e.node {
10751075
ast::ExprIf(cond, _, _) => (cond, "`if` condition", true),
1076-
ast::ExprWhile(cond, _) => (cond, "`while` condition", true),
1076+
ast::ExprWhile(cond, _, _) => (cond, "`while` condition", true),
10771077
ast::ExprMatch(head, _) => (head, "`match` head expression", true),
10781078
ast::ExprRet(Some(value)) => (value, "`return` value", false),
10791079
ast::ExprAssign(_, value) => (value, "assigned value", false),

src/librustc/middle/cfg/construct.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -227,7 +227,7 @@ impl<'a> CFGBuilder<'a> {
227227
self.add_node(expr.id, [then_exit, else_exit]) // 4, 5
228228
}
229229

230-
ast::ExprWhile(ref cond, ref body) => {
230+
ast::ExprWhile(ref cond, ref body, _) => {
231231
//
232232
// [pred]
233233
// |

src/librustc/middle/check_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -35,7 +35,7 @@ impl<'a> Visitor<Context> for CheckLoopVisitor<'a> {
3535

3636
fn visit_expr(&mut self, e: &ast::Expr, cx:Context) {
3737
match e.node {
38-
ast::ExprWhile(ref e, ref b) => {
38+
ast::ExprWhile(ref e, ref b, _) => {
3939
self.visit_expr(&**e, cx);
4040
self.visit_block(&**b, Loop);
4141
}

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
410410
self.walk_block(&**blk);
411411
}
412412

413-
ast::ExprWhile(ref cond_expr, ref blk) => {
413+
ast::ExprWhile(ref cond_expr, ref blk, _) => {
414414
self.consume_expr(&**cond_expr);
415415
self.walk_block(&**blk);
416416
}

src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ impl<'a> Liveness<'a> {
10171017
self.propagate_through_expr(&**cond, ln)
10181018
}
10191019

1020-
ExprWhile(ref cond, ref blk) => {
1020+
ExprWhile(ref cond, ref blk, _) => {
10211021
self.propagate_through_loop(expr,
10221022
WhileLoop(cond.clone()),
10231023
&**blk,

src/librustc/middle/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -496,7 +496,7 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor,
496496
visitor.region_maps.mark_as_terminating_scope(body.id);
497497
}
498498

499-
ast::ExprWhile(expr, body) => {
499+
ast::ExprWhile(expr, body, _) => {
500500
visitor.region_maps.mark_as_terminating_scope(expr.id);
501501
visitor.region_maps.mark_as_terminating_scope(body.id);
502502
}

src/librustc/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use util::nodemap::{NodeMap, DefIdSet, FnvHashMap};
2323

2424
use syntax::ast::{Arm, BindByRef, BindByValue, BindingMode, Block, Crate};
2525
use syntax::ast::{DeclItem, DefId, Expr, ExprAgain, ExprBreak, ExprField};
26-
use syntax::ast::{ExprFnBlock, ExprForLoop, ExprLoop, ExprMethodCall};
26+
use syntax::ast::{ExprFnBlock, ExprForLoop, ExprLoop, ExprWhile, ExprMethodCall};
2727
use syntax::ast::{ExprPath, ExprProc, ExprStruct, ExprUnboxedFn, FnDecl};
2828
use syntax::ast::{ForeignItem, ForeignItemFn, ForeignItemStatic, Generics};
2929
use syntax::ast::{Ident, ImplItem, Item, ItemEnum, ItemFn, ItemForeignMod};
@@ -5622,7 +5622,7 @@ impl<'a> Resolver<'a> {
56225622
visit::walk_expr(self, expr, ());
56235623
}
56245624

5625-
ExprLoop(_, Some(label)) => {
5625+
ExprLoop(_, Some(label)) | ExprWhile(_, _, Some(label)) => {
56265626
self.with_label_rib(|this| {
56275627
let def_like = DlDef(DefLabel(expr.id));
56285628

src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3512,7 +3512,7 @@ fn populate_scope_map(cx: &CrateContext,
35123512
}
35133513
}
35143514

3515-
ast::ExprWhile(ref cond_exp, ref loop_body) => {
3515+
ast::ExprWhile(ref cond_exp, ref loop_body, _) => {
35163516
walk_expr(cx, &**cond_exp, scope_stack, scope_map);
35173517

35183518
with_new_scope(cx,

src/librustc/middle/trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ fn trans_rvalue_stmt_unadjusted<'a>(bcx: &'a Block<'a>,
900900
ast::ExprRet(ex) => {
901901
controlflow::trans_ret(bcx, ex)
902902
}
903-
ast::ExprWhile(ref cond, ref body) => {
903+
ast::ExprWhile(ref cond, ref body, _) => {
904904
controlflow::trans_while(bcx, expr.id, &**cond, &**body)
905905
}
906906
ast::ExprForLoop(ref pat, ref head, ref body, _) => {

src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3757,7 +3757,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
37573757
check_then_else(fcx, &**cond, &**then_blk, opt_else_expr.clone(),
37583758
id, expr.span, expected);
37593759
}
3760-
ast::ExprWhile(ref cond, ref body) => {
3760+
ast::ExprWhile(ref cond, ref body, _) => {
37613761
check_expr_has_type(fcx, &**cond, ty::mk_bool());
37623762
check_block_no_value(fcx, &**body);
37633763
let cond_ty = fcx.expr_ty(&**cond);

0 commit comments

Comments
 (0)