Revert "Add lint checks for unused loop labels"
This functionality is being reimplemented in the resolver phase This reverts commit 503a69e844970476b27bf1ac7be951bb22194f50.
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// The output should warn when a loop label is not used. However, it
|
||||
// should also deal with the edge cases where a label is shadowed,
|
||||
// within nested loops
|
||||
|
||||
// compile-pass
|
||||
// compile-flags: -W unused-label
|
||||
|
||||
fn main() {
|
||||
'unused_while_label: while 0 == 0 {
|
||||
//~^ WARN unused label
|
||||
}
|
||||
|
||||
let opt = Some(0);
|
||||
'unused_while_let_label: while let Some(_) = opt {
|
||||
//~^ WARN unused label
|
||||
}
|
||||
|
||||
'unused_for_label: for _ in 0..10 {
|
||||
//~^ WARN unused label
|
||||
}
|
||||
|
||||
'used_loop_label: loop {
|
||||
break 'used_loop_label;
|
||||
}
|
||||
|
||||
'used_loop_label_outer_1: for _ in 0..10 {
|
||||
'used_loop_label_inner_1: for _ in 0..10 {
|
||||
break 'used_loop_label_inner_1;
|
||||
}
|
||||
break 'used_loop_label_outer_1;
|
||||
}
|
||||
|
||||
'used_loop_label_outer_2: for _ in 0..10 {
|
||||
'unused_loop_label_inner_2: for _ in 0..10 {
|
||||
//~^ WARN unused label
|
||||
break 'used_loop_label_outer_2;
|
||||
}
|
||||
}
|
||||
|
||||
'unused_loop_label_outer_3: for _ in 0..10 {
|
||||
//~^ WARN unused label
|
||||
'used_loop_label_inner_3: for _ in 0..10 {
|
||||
break 'used_loop_label_inner_3;
|
||||
}
|
||||
}
|
||||
|
||||
// Test breaking many times with the same inner label doesn't break the
|
||||
// warning on the outer label
|
||||
'many_used_shadowed: for _ in 0..10 {
|
||||
//~^ WARN unused label
|
||||
'many_used_shadowed: for _ in 0..10 {
|
||||
//~^ WARN label name `'many_used_shadowed` shadows a label name that is already in scope
|
||||
if 1 % 2 == 0 {
|
||||
break 'many_used_shadowed;
|
||||
} else {
|
||||
break 'many_used_shadowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is diverging, so put it at the end so we don't get
|
||||
// unreachable_code errors everywhere else
|
||||
'unused_loop_label: loop {
|
||||
//~^ WARN unused label
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
warning: unused label
|
||||
--> $DIR/unused_label.rs:19:5
|
||||
|
|
||||
LL | 'unused_while_label: while 0 == 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: requested on the command line with `-W unused-label`
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_label.rs:24:5
|
||||
|
|
||||
LL | 'unused_while_let_label: while let Some(_) = opt {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_label.rs:28:5
|
||||
|
|
||||
LL | 'unused_for_label: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_label.rs:44:9
|
||||
|
|
||||
LL | 'unused_loop_label_inner_2: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_label.rs:50:5
|
||||
|
|
||||
LL | 'unused_loop_label_outer_3: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_label.rs:59:5
|
||||
|
|
||||
LL | 'many_used_shadowed: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_label.rs:73:5
|
||||
|
|
||||
LL | 'unused_loop_label: loop {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: label name `'many_used_shadowed` shadows a label name that is already in scope
|
||||
--> $DIR/unused_label.rs:61:9
|
||||
|
|
||||
LL | 'many_used_shadowed: for _ in 0..10 {
|
||||
| ------------------- first declared here
|
||||
LL | //~^ WARN unused label
|
||||
LL | 'many_used_shadowed: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^^^ lifetime 'many_used_shadowed already in scope
|
||||
|
||||
Reference in New Issue
Block a user