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