]> git.lizzy.rs Git - rust.git/blob - src/test/ui/loops/loops-reject-duplicate-labels-2.rs
Auto merge of #83152 - guswynn:jemallocator_part2, r=Mark-Simulacrum
[rust.git] / src / test / ui / loops / loops-reject-duplicate-labels-2.rs
1 // check-pass
2
3
4 // Issue #21633: reject duplicate loop labels in function bodies.
5 //
6 // This is testing the generalization (to the whole function body)
7 // discussed here:
8 // https://internals.rust-lang.org/t/psa-rejecting-duplicate-loop-labels/1833
9
10 #[allow(unused_labels)]
11 pub fn foo() {
12     { 'fl: for _ in 0..10 { break; } }
13     { 'fl: loop { break; } }             //~ WARN label name `'fl` shadows a label name that is already in scope
14     { 'lf: loop { break; } }
15     { 'lf: for _ in 0..10 { break; } }   //~ WARN label name `'lf` shadows a label name that is already in scope
16     { 'wl: while 2 > 1 { break; } }
17     { 'wl: loop { break; } }             //~ WARN label name `'wl` shadows a label name that is already in scope
18     { 'lw: loop { break; } }
19     { 'lw: while 2 > 1 { break; } }      //~ WARN label name `'lw` shadows a label name that is already in scope
20     { 'fw: for _ in 0..10 { break; } }
21     { 'fw: while 2 > 1 { break; } }      //~ WARN label name `'fw` shadows a label name that is already in scope
22     { 'wf: while 2 > 1 { break; } }
23     { 'wf: for _ in 0..10 { break; } }   //~ WARN label name `'wf` shadows a label name that is already in scope
24     { 'tl: while let Some(_) = None::<i32> { break; } }
25     { 'tl: loop { break; } }             //~ WARN label name `'tl` shadows a label name that is already in scope
26     { 'lt: loop { break; } }
27     { 'lt: while let Some(_) = None::<i32> { break; } }
28                                          //~^ WARN label name `'lt` shadows a label name that is already in scope
29 }
30
31
32 pub fn main() {
33     foo();
34 }