1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![feature(never_type)]
14 let val: ! = loop { break break; };
15 //~^ ERROR mismatched types
21 break 123; //~ ERROR mismatched types
26 break "asdf"; //~ ERROR mismatched types
29 let _: i32 = 'outer_loop: loop {
31 break 'outer_loop "nope"; //~ ERROR mismatched types
36 'while_loop: while true {
38 break (); //~ ERROR `break` with value from a `while` loop
40 break 'while_loop 123;
41 //~^ ERROR `break` with value from a `while` loop
47 while let Some(_) = Some(()) {
48 if break () { //~ ERROR `break` with value from a `while let` loop
52 while let Some(_) = Some(()) {
54 //~^ ERROR `break` with value from a `while let` loop
57 'while_let_loop: while let Some(_) = Some(()) {
59 break 'while_let_loop "nope";
60 //~^ ERROR `break` with value from a `while let` loop
66 break (); //~ ERROR `break` with value from a `for` loop
68 //~^ ERROR `break` with value from a `for` loop
71 'for_loop: for _ in &[1,2,3] {
74 break 'for_loop Some(17);
75 //~^ ERROR `break` with value from a `for` loop
79 let _: i32 = 'a: loop {
80 let _: () = 'b: loop {
83 break 'c 123; //~ ERROR mismatched types
90 break (break, break); //~ ERROR mismatched types
95 break 2; //~ ERROR mismatched types
100 break; //~ ERROR mismatched types