2 #![allow(unreachable_code)]
3 #![allow(unused_labels)]
4 // Test that labels injected by macros do not break hygiene.
6 // Issue #24278: The label/lifetime shadowing checker from #24162
7 // conservatively ignores hygiene, and thus issues warnings that are
8 // both true- and false-positives for this test.
12 // $e shouldn't be able to interact with this 'x
14 //~^ WARNING shadows a label name that is already in scope
15 //~| WARNING shadows a label name that is already in scope
16 //~| WARNING shadows a label name that is already in scope
17 //~| WARNING shadows a label name that is already in scope
21 macro_rules! run_once {
24 'x: for _ in 0..1 { $e }
25 //~^ WARNING shadows a label name that is already in scope
26 //~| WARNING shadows a label name that is already in scope
27 //~| WARNING shadows a label name that is already in scope
28 //~| WARNING shadows a label name that is already in scope
29 //~| WARNING shadows a label name that is already in scope
30 //~| WARNING shadows a label name that is already in scope
31 //~| WARNING shadows a label name that is already in scope
35 macro_rules! while_x {
38 'x: while 1 + 1 == 2 { $e }
39 //~^ WARNING shadows a label name that is already in scope
40 //~| WARNING shadows a label name that is already in scope
41 //~| WARNING shadows a label name that is already in scope
42 //~| WARNING shadows a label name that is already in scope
43 //~| WARNING shadows a label name that is already in scope
49 // this 'x should refer to the outer loop, lexically
51 panic!("break doesn't act hygienically inside for loop");
55 //~^ WARNING shadows a label name that is already in scope
56 //~| WARNING shadows a label name that is already in scope
60 panic!("break doesn't act hygienically inside infinite loop");
63 'x: while 1 + 1 == 2 {
64 //~^ WARNING shadows a label name that is already in scope
65 //~| WARNING shadows a label name that is already in scope
66 //~| WARNING shadows a label name that is already in scope
67 //~| WARNING shadows a label name that is already in scope
70 panic!("break doesn't act hygienically inside infinite while loop");
74 //~^ WARNING shadows a label name that is already in scope
75 //~| WARNING shadows a label name that is already in scope
76 //~| WARNING shadows a label name that is already in scope
77 //~| WARNING shadows a label name that is already in scope
78 //~| WARNING shadows a label name that is already in scope
79 //~| WARNING shadows a label name that is already in scope
82 run_once!(continue 'x);
83 panic!("continue doesn't act hygienically inside for loop");