Properly implement labeled breaks in while conditions

This commit is contained in:
Taylor Cramer 2017-02-15 23:28:59 -08:00
parent 5205e2f8b8
commit 4d65622dcd
12 changed files with 247 additions and 58 deletions

View file

@ -122,4 +122,20 @@ pub fn main() {
panic!();
};
assert_eq!(nested_break_value, "hello");
let break_from_while_cond = loop {
'inner_loop: while break 'inner_loop {
panic!();
}
break 123;
};
assert_eq!(break_from_while_cond, 123);
let break_from_while_to_outer = 'outer_loop: loop {
while break 'outer_loop 567 {
panic!("from_inner");
}
panic!("from outer");
};
assert_eq!(break_from_while_to_outer, 567);
}