]> git.lizzy.rs Git - rust.git/commitdiff
Default `unused_labels` to allow, move to "unused"
authorKyle Stachowicz <kylestach99@gmail.com>
Fri, 18 May 2018 23:53:39 +0000 (16:53 -0700)
committerKyle Stachowicz <kylestach99@gmail.com>
Fri, 18 May 2018 23:57:16 +0000 (16:57 -0700)
src/librustc/lint/builtin.rs
src/librustc_lint/lib.rs
src/test/ui/lint/unused_labels.rs
src/test/ui/lint/unused_labels.stderr

index 71eefec2210e46fb324b8e33fb2f85634425f833..79b4ec61bd081ba5eba79fcd4d3eb2094570f969 100644 (file)
 
 declare_lint! {
     pub UNUSED_LABELS,
-    Warn,
+    Allow,
     "detects labels that are never used"
 }
 
index 0ae133640fad9feb93bd68ce0faec1a271cbaa4b..69825027b052bc77ed5fb17dabaf37915720e9c7 100644 (file)
@@ -177,6 +177,7 @@ macro_rules! add_lint_group {
                     UNUSED_DOC_COMMENT,
                     UNUSED_EXTERN_CRATES,
                     UNUSED_FEATURES,
+                    UNUSED_LABELS,
                     UNUSED_PARENS);
 
     add_lint_group!(sess,
index 22b7ad4e6a7c9b2be74160cde7fead7bcc5058af..23add604da6ab29feda8ae149b6c9313145a2018 100644 (file)
@@ -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 {
index d09209853e3a3d3be6fa9ce73b7d7bb5d3ff1706..825f5e281f0b9d784ef42fb19ace6d97f5c76b3e 100644 (file)
@@ -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