]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/hygienic-labels.rs
rustdoc: Replace no-pretty-expanded with pretty-expanded
[rust.git] / src / test / run-pass / hygienic-labels.rs
1 // Copyright 2012-2014 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.
4 //
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.
10
11 // pretty-expanded FIXME #23616
12
13 macro_rules! loop_x {
14     ($e: expr) => {
15         // $e shouldn't be able to interact with this 'x
16         'x: loop { $e }
17     }
18 }
19
20 macro_rules! run_once {
21     ($e: expr) => {
22         // ditto
23         'x: for _ in 0..1 { $e }
24     }
25 }
26
27 macro_rules! while_x {
28     ($e: expr) => {
29         // ditto
30         'x: while 1 + 1 == 2 { $e }
31     }
32 }
33
34 pub fn main() {
35     'x: for _ in 0..1 {
36         // this 'x should refer to the outer loop, lexically
37         loop_x!(break 'x);
38         panic!("break doesn't act hygienically inside for loop");
39     }
40
41     'x: loop {
42         // ditto
43         loop_x!(break 'x);
44         panic!("break doesn't act hygienically inside infinite loop");
45     }
46
47     'x: while 1 + 1 == 2 {
48         while_x!(break 'x);
49         panic!("break doesn't act hygienically inside infinite while loop");
50     }
51
52     'x: for _ in 0..1 {
53         // ditto
54         run_once!(continue 'x);
55         panic!("continue doesn't act hygienically inside for loop");
56     }
57 }