Skip to content

Commit 7676982

Browse files
committed
Revert "Add lint checks for unused loop labels"
This functionality is being reimplemented in the resolver phase This reverts commit 503a69e844970476b27bf1ac7be951bb22194f50.
1 parent 167cede commit 7676982

File tree

5 files changed

+1
-190
lines changed

5 files changed

+1
-190
lines changed

src/librustc_lint/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
110110

111111
add_early_builtin_with_new!(sess,
112112
DeprecatedAttr,
113-
UnusedLabel,
114113
);
115114

116115
add_builtin!(sess,
@@ -178,7 +177,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
178177
UNUSED_DOC_COMMENT,
179178
UNUSED_EXTERN_CRATES,
180179
UNUSED_FEATURES,
181-
UNUSED_LABEL,
182180
UNUSED_PARENS);
183181

184182
add_lint_group!(sess,

src/librustc_lint/unused.rs

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -464,61 +464,3 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
464464
}
465465
}
466466
}
467-
468-
declare_lint! {
469-
pub(super) UNUSED_LABEL,
470-
Warn,
471-
"warns on unused labels"
472-
}
473-
474-
#[derive(Clone)]
475-
pub struct UnusedLabel(pub Vec<(ast::Label, bool)>);
476-
477-
impl UnusedLabel {
478-
pub fn new() -> Self {
479-
UnusedLabel(vec![])
480-
}
481-
}
482-
483-
impl LintPass for UnusedLabel {
484-
fn get_lints(&self) -> LintArray {
485-
lint_array!(UNUSED_LABEL)
486-
}
487-
}
488-
489-
impl EarlyLintPass for UnusedLabel {
490-
fn check_expr(&mut self, _: &EarlyContext, expr: &ast::Expr) {
491-
match expr.node {
492-
ast::ExprKind::While(_, _, Some(label))
493-
| ast::ExprKind::WhileLet(_, _, _, Some(label))
494-
| ast::ExprKind::ForLoop(_, _, _, Some(label))
495-
| ast::ExprKind::Loop(_, Some(label)) => {
496-
self.0.push((label, false));
497-
}
498-
ast::ExprKind::Break(Some(label), _) | ast::ExprKind::Continue(Some(label)) => {
499-
if let Some((_, ref mut was_used)) =
500-
self.0.iter_mut().rev().find(|(l, _)| label == *l)
501-
{
502-
*was_used = true;
503-
}
504-
}
505-
_ => {}
506-
}
507-
}
508-
509-
fn check_expr_post(&mut self, ctxt: &EarlyContext, expr: &ast::Expr) {
510-
match expr.node {
511-
ast::ExprKind::While(_, _, Some(label))
512-
| ast::ExprKind::WhileLet(_, _, _, Some(label))
513-
| ast::ExprKind::ForLoop(_, _, _, Some(label))
514-
| ast::ExprKind::Loop(_, Some(label)) => {
515-
if let Some((_, was_used)) = self.0.pop() {
516-
if !was_used {
517-
ctxt.span_lint(UNUSED_LABEL, label.ident.span, "unused label");
518-
}
519-
}
520-
}
521-
_ => {}
522-
}
523-
}
524-
}

src/librustc_mir/interpret/eval_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
17051705
let mut trace_text = "\n\nAn error occurred in miri:\n".to_string();
17061706
backtrace.resolve();
17071707
write!(trace_text, "backtrace frames: {}\n", backtrace.frames().len()).unwrap();
1708-
for (i, frame) in backtrace.frames().iter().enumerate() {
1708+
'frames: for (i, frame) in backtrace.frames().iter().enumerate() {
17091709
if frame.symbols().is_empty() {
17101710
write!(trace_text, "{}: no symbols\n", i).unwrap();
17111711
}

src/test/ui/lint/unused_label.rs

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/test/ui/lint/unused_label.stderr

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)