1 // build-pass (FIXME(62277): could be check-pass?)
3 // ignore-tidy-linelength
5 // Issue #21633: reject duplicate loop labels in function bodies.
6 // This is testing the exact cases that are in the issue description.
8 #[allow(unused_labels)]
10 'fl
: for _
in 0..10 { break; }
11 'fl
: loop { break; }
//~ WARN label name `'fl` shadows a label name that is already in scope
14 'lf
: for _
in 0..10 { break; }
//~ WARN label name `'lf` shadows a label name that is already in scope
15 'wl
: while 2 > 1 { break; }
16 'wl
: loop { break; }
//~ WARN label name `'wl` shadows a label name that is already in scope
18 'lw
: while 2 > 1 { break; }
//~ WARN label name `'lw` shadows a label name that is already in scope
19 'fw
: for _
in 0..10 { break; }
20 'fw
: while 2 > 1 { break; }
//~ WARN label name `'fw` shadows a label name that is already in scope
21 'wf
: while 2 > 1 { break; }
22 'wf
: for _
in 0..10 { break; }
//~ WARN label name `'wf` shadows a label name that is already in scope
23 'tl
: while let Some(_
) = None
::<i32> { break; }
24 'tl
: loop { break; }
//~ WARN label name `'tl` shadows a label name that is already in scope
26 'lt
: while let Some(_
) = None
::<i32> { break; }
27 //~^ WARN label name `'lt` shadows a label name that is already in scope
30 // Note however that it is okay for the same label to be reused in
31 // different methods of one impl, as illustrated here.
35 fn m1(&self) { 'okay: loop { break 'okay; }
}
36 fn m2(&self) { 'okay: loop { break 'okay; }
}