1 // Copyright 2015 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.
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.
11 #![feature(rustc_attrs)]
13 // ignore-tidy-linelength
15 // Issue #21633: reject duplicate loop labels in function bodies.
17 // This is testing the generalization (to the whole function body)
19 // https://internals.rust-lang.org/t/psa-rejecting-duplicate-loop-labels/1833
22 { 'fl: for _ in 0..10 { break; } }
23 { 'fl: loop { break; } } //~ WARN label name `'fl` shadows a label name that is already in scope
24 { 'lf: loop { break; } }
25 { 'lf: for _ in 0..10 { break; } } //~ WARN label name `'lf` shadows a label name that is already in scope
26 { 'wl: while 2 > 1 { break; } }
27 { 'wl: loop { break; } } //~ WARN label name `'wl` shadows a label name that is already in scope
28 { 'lw: loop { break; } }
29 { 'lw: while 2 > 1 { break; } } //~ WARN label name `'lw` shadows a label name that is already in scope
30 { 'fw: for _ in 0..10 { break; } }
31 { 'fw: while 2 > 1 { break; } } //~ WARN label name `'fw` shadows a label name that is already in scope
32 { 'wf: while 2 > 1 { break; } }
33 { 'wf: for _ in 0..10 { break; } } //~ WARN label name `'wf` shadows a label name that is already in scope
34 { 'tl: while let Some(_) = None::<i32> { break; } }
35 { 'tl: loop { break; } } //~ WARN label name `'tl` shadows a label name that is already in scope
36 { 'lt: loop { break; } }
37 { 'lt: while let Some(_) = None::<i32> { break; } }
38 //~^ WARN label name `'lt` shadows a label name that is already in scope
42 pub fn main() { //~ ERROR compilation successful