about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKyle Stachowicz <kylestach99@gmail.com>2018-05-17 16:57:46 -0700
committerKyle Stachowicz <kylestach99@gmail.com>2018-05-18 16:57:15 -0700
commit7676982e90120cf4edacc6b1ed8a8cebce12b97c (patch)
tree0eb2b5a5c90a4750faded1ccaf044cb45e13d17e
parent167cedefe63b366278dbd83b533b051cd417fcf0 (diff)
downloadrust-7676982e90120cf4edacc6b1ed8a8cebce12b97c.tar.gz
rust-7676982e90120cf4edacc6b1ed8a8cebce12b97c.zip
Revert "Add lint checks for unused loop labels"
This functionality is being reimplemented in the resolver phase

This reverts commit 503a69e844970476b27bf1ac7be951bb22194f50.
-rw-r--r--src/librustc_lint/lib.rs2
-rw-r--r--src/librustc_lint/unused.rs58
-rw-r--r--src/librustc_mir/interpret/eval_context.rs2
-rw-r--r--src/test/ui/lint/unused_label.rs76
-rw-r--r--src/test/ui/lint/unused_label.stderr53
5 files changed, 1 insertions, 190 deletions
diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs
index b0a766ec058..0ae133640fa 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -110,7 +110,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
 
     add_early_builtin_with_new!(sess,
                                 DeprecatedAttr,
-                                UnusedLabel,
                                 );
 
     add_builtin!(sess,
@@ -178,7 +177,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
                     UNUSED_DOC_COMMENT,
                     UNUSED_EXTERN_CRATES,
                     UNUSED_FEATURES,
-                    UNUSED_LABEL,
                     UNUSED_PARENS);
 
     add_lint_group!(sess,
diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs
index 2321d40f150..845c964b986 100644
--- a/src/librustc_lint/unused.rs
+++ b/src/librustc_lint/unused.rs
@@ -464,61 +464,3 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
         }
     }
 }
-
-declare_lint! {
-    pub(super) UNUSED_LABEL,
-    Warn,
-    "warns on unused labels"
-}
-
-#[derive(Clone)]
-pub struct UnusedLabel(pub Vec<(ast::Label, bool)>);
-
-impl UnusedLabel {
-    pub fn new() -> Self {
-        UnusedLabel(vec![])
-    }
-}
-
-impl LintPass for UnusedLabel {
-    fn get_lints(&self) -> LintArray {
-        lint_array!(UNUSED_LABEL)
-    }
-}
-
-impl EarlyLintPass for UnusedLabel {
-    fn check_expr(&mut self, _: &EarlyContext, expr: &ast::Expr) {
-        match expr.node {
-            ast::ExprKind::While(_, _, Some(label))
-            | ast::ExprKind::WhileLet(_, _, _, Some(label))
-            | ast::ExprKind::ForLoop(_, _, _, Some(label))
-            | ast::ExprKind::Loop(_, Some(label)) => {
-                self.0.push((label, false));
-            }
-            ast::ExprKind::Break(Some(label), _) | ast::ExprKind::Continue(Some(label)) => {
-                if let Some((_, ref mut was_used)) =
-                    self.0.iter_mut().rev().find(|(l, _)| label == *l)
-                {
-                    *was_used = true;
-                }
-            }
-            _ => {}
-        }
-    }
-
-    fn check_expr_post(&mut self, ctxt: &EarlyContext, expr: &ast::Expr) {
-        match expr.node {
-            ast::ExprKind::While(_, _, Some(label))
-            | ast::ExprKind::WhileLet(_, _, _, Some(label))
-            | ast::ExprKind::ForLoop(_, _, _, Some(label))
-            | ast::ExprKind::Loop(_, Some(label)) => {
-                if let Some((_, was_used)) = self.0.pop() {
-                    if !was_used {
-                        ctxt.span_lint(UNUSED_LABEL, label.ident.span, "unused label");
-                    }
-                }
-            }
-            _ => {}
-        }
-    }
-}
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 7b6cee96a87..03137619eda 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -1705,7 +1705,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
             let mut trace_text = "\n\nAn error occurred in miri:\n".to_string();
             backtrace.resolve();
             write!(trace_text, "backtrace frames: {}\n", backtrace.frames().len()).unwrap();
-            for (i, frame) in backtrace.frames().iter().enumerate() {
+            'frames: for (i, frame) in backtrace.frames().iter().enumerate() {
                 if frame.symbols().is_empty() {
                     write!(trace_text, "{}: no symbols\n", i).unwrap();
                 }
diff --git a/src/test/ui/lint/unused_label.rs b/src/test/ui/lint/unused_label.rs
deleted file mode 100644
index f19b793546e..00000000000
--- a/src/test/ui/lint/unused_label.rs
+++ /dev/null
@@ -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
-    }
-}
diff --git a/src/test/ui/lint/unused_label.stderr b/src/test/ui/lint/unused_label.stderr
deleted file mode 100644
index e78df677942..00000000000
--- a/src/test/ui/lint/unused_label.stderr
+++ /dev/null
@@ -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
-