mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
Default unused_labels
to allow, move to "unused"
This commit is contained in:
parent
5586cd80e2
commit
6da64a7666
@ -281,7 +281,7 @@ declare_lint! {
|
||||
|
||||
declare_lint! {
|
||||
pub UNUSED_LABELS,
|
||||
Warn,
|
||||
Allow,
|
||||
"detects labels that are never used"
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
|
||||
UNUSED_DOC_COMMENT,
|
||||
UNUSED_EXTERN_CRATES,
|
||||
UNUSED_FEATURES,
|
||||
UNUSED_LABELS,
|
||||
UNUSED_PARENS);
|
||||
|
||||
add_lint_group!(sess,
|
||||
|
@ -15,6 +15,7 @@
|
||||
// compile-pass
|
||||
|
||||
#![feature(label_break_value)]
|
||||
#![warn(unused_labels)]
|
||||
|
||||
fn main() {
|
||||
'unused_while_label: while 0 == 0 {
|
||||
@ -55,6 +56,15 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
// You should be able to break the same label many times
|
||||
'many_used: loop {
|
||||
if true {
|
||||
break 'many_used;
|
||||
} else {
|
||||
break 'many_used;
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
@ -1,55 +1,59 @@
|
||||
warning: unused label
|
||||
--> $DIR/unused_labels.rs:20:5
|
||||
--> $DIR/unused_labels.rs:21:5
|
||||
|
|
||||
LL | 'unused_while_label: while 0 == 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(unused_labels)] on by default
|
||||
note: lint level defined here
|
||||
--> $DIR/unused_labels.rs:18:9
|
||||
|
|
||||
LL | #![warn(unused_labels)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_labels.rs:25:5
|
||||
--> $DIR/unused_labels.rs:26:5
|
||||
|
|
||||
LL | 'unused_while_let_label: while let Some(_) = opt {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_labels.rs:29:5
|
||||
--> $DIR/unused_labels.rs:30:5
|
||||
|
|
||||
LL | 'unused_for_label: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_labels.rs:45:9
|
||||
--> $DIR/unused_labels.rs:46:9
|
||||
|
|
||||
LL | 'unused_loop_label_inner_2: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_labels.rs:51:5
|
||||
--> $DIR/unused_labels.rs:52:5
|
||||
|
|
||||
LL | 'unused_loop_label_outer_3: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_labels.rs:60:5
|
||||
--> $DIR/unused_labels.rs:70:5
|
||||
|
|
||||
LL | 'many_used_shadowed: for _ in 0..10 {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_labels.rs:72:5
|
||||
--> $DIR/unused_labels.rs:82:5
|
||||
|
|
||||
LL | 'unused_loop_label: loop {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused label
|
||||
--> $DIR/unused_labels.rs:78:5
|
||||
--> $DIR/unused_labels.rs:88:5
|
||||
|
|
||||
LL | 'unused_block_label: {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: label name `'many_used_shadowed` shadows a label name that is already in scope
|
||||
--> $DIR/unused_labels.rs:62:9
|
||||
--> $DIR/unused_labels.rs:72:9
|
||||
|
|
||||
LL | 'many_used_shadowed: for _ in 0..10 {
|
||||
| ------------------- first declared here
|
||||
|
Loading…
Reference in New Issue
Block a user