Skip to content

Commit

Permalink
Revert "Add lint checks for unused loop labels"
Browse files Browse the repository at this point in the history
This functionality is being reimplemented in the resolver phase

This reverts commit 503a69e844970476b27bf1ac7be951bb22194f50.
  • Loading branch information
kylestach committed May 18, 2018
1 parent 167cede commit 7676982
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 190 deletions.
2 changes: 0 additions & 2 deletions src/librustc_lint/lib.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
58 changes: 0 additions & 58 deletions src/librustc_lint/unused.rs
Expand Up @@ -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");
}
}
}
_ => {}
}
}
}
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/eval_context.rs
Expand Up @@ -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();
}
Expand Down
76 changes: 0 additions & 76 deletions src/test/ui/lint/unused_label.rs

This file was deleted.

53 changes: 0 additions & 53 deletions src/test/ui/lint/unused_label.stderr

This file was deleted.

0 comments on commit 7676982

Please sign in to comment.