]> git.lizzy.rs Git - rust.git/blob - src/test/ui/macros/macro-lifetime-used-with-labels.rs
Diagnose shadowing on AST.
[rust.git] / src / test / ui / macros / macro-lifetime-used-with-labels.rs
1 // run-pass
2 #![allow(stable_features)]
3 #![allow(unused_labels)]
4 #![allow(unreachable_code)]
5
6 macro_rules! x {
7     ($a:lifetime) => {
8         $a: loop {
9             break $a;
10             panic!("failed");
11         }
12     }
13 }
14 macro_rules! br {
15     ($a:lifetime) => {
16         break $a;
17     }
18 }
19 macro_rules! br2 {
20     ($b:lifetime) => {
21         'b: loop { //~ WARNING `'b` shadows a label name that is already in scope
22             break $b; // this $b should refer to the outer loop.
23         }
24     }
25 }
26 fn main() {
27     x!('a);
28     'c: loop {
29         br!('c);
30         panic!("failed");
31     }
32     'b: loop {
33         br2!('b);
34         panic!("failed");
35     }
36 }