diff options
| author | Kyle Stachowicz <kylestach99@gmail.com> | 2018-05-18 16:53:39 -0700 |
|---|---|---|
| committer | Kyle Stachowicz <kylestach99@gmail.com> | 2018-05-18 16:57:16 -0700 |
| commit | 6da64a7666e89b39b99d728aaa3a40c124f31563 (patch) | |
| tree | e5bf48427867efa10f9c979ea98b3d2e906b58b1 | |
| parent | 5586cd80e244936283b913ab3cf0f3626eec3136 (diff) | |
| download | rust-6da64a7666e89b39b99d728aaa3a40c124f31563.tar.gz rust-6da64a7666e89b39b99d728aaa3a40c124f31563.zip | |
Default `unused_labels` to allow, move to "unused"
| -rw-r--r-- | src/librustc/lint/builtin.rs | 2 | ||||
| -rw-r--r-- | src/librustc_lint/lib.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/lint/unused_labels.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/lint/unused_labels.stderr | 24 |
4 files changed, 26 insertions, 11 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 71eefec2210..79b4ec61bd0 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -281,7 +281,7 @@ declare_lint! { declare_lint! { pub UNUSED_LABELS, - Warn, + Allow, "detects labels that are never used" } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 0ae133640fa..69825027b05 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -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, diff --git a/src/test/ui/lint/unused_labels.rs b/src/test/ui/lint/unused_labels.rs index 22b7ad4e6a7..23add604da6 100644 --- a/src/test/ui/lint/unused_labels.rs +++ b/src/test/ui/lint/unused_labels.rs @@ -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 { diff --git a/src/test/ui/lint/unused_labels.stderr b/src/test/ui/lint/unused_labels.stderr index d09209853e3..825f5e281f0 100644 --- a/src/test/ui/lint/unused_labels.stderr +++ b/src/test/ui/lint/unused_labels.stderr @@ -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 |
