]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/unused_label.rs
rustup https://github.com/rust-lang/rust/pull/67455
[rust.git] / clippy_lints / src / unused_label.rs
index 4b41a02de974b276b9c110144fd2b621f813d091..60acbc1469f900e78459ffc70821b712c9a69983 100644 (file)
@@ -1,11 +1,12 @@
-use crate::utils::{in_macro_or_desugar, span_lint};
+use crate::utils::span_lint;
+use rustc::declare_lint_pass;
 use rustc::hir;
 use rustc::hir::intravisit::{walk_expr, walk_fn, FnKind, NestedVisitorMap, Visitor};
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_lint_pass, declare_tool_lint};
 use rustc_data_structures::fx::FxHashMap;
+use rustc_session::declare_tool_lint;
 use syntax::source_map::Span;
-use syntax::symbol::LocalInternedString;
+use syntax::symbol::Symbol;
 
 declare_clippy_lint! {
     /// **What it does:** Checks for unused labels.
@@ -27,8 +28,8 @@
     "unused labels"
 }
 
-struct UnusedLabelVisitor<'a, 'tcx: 'a> {
-    labels: FxHashMap<LocalInternedString, Span>,
+struct UnusedLabelVisitor<'a, 'tcx> {
+    labels: FxHashMap<Symbol, Span>,
     cx: &'a LateContext<'a, 'tcx>,
 }
 
@@ -44,7 +45,7 @@ fn check_fn(
         span: Span,
         fn_id: hir::HirId,
     ) {
-        if in_macro_or_desugar(span) {
+        if span.from_expansion() {
             return;
         }
 
@@ -60,16 +61,16 @@ fn check_fn(
     }
 }
 
-impl<'a, 'tcx: 'a> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> {
+impl<'a, 'tcx> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> {
     fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
-        match expr.node {
+        match expr.kind {
             hir::ExprKind::Break(destination, _) | hir::ExprKind::Continue(destination) => {
                 if let Some(label) = destination.label {
-                    self.labels.remove(&label.ident.as_str());
+                    self.labels.remove(&label.ident.name);
                 }
             },
-            hir::ExprKind::Loop(_, Some(label), _) | hir::ExprKind::While(_, _, Some(label)) => {
-                self.labels.insert(label.ident.as_str(), expr.span);
+            hir::ExprKind::Loop(_, Some(label), _) => {
+                self.labels.insert(label.ident.name, expr.span);
             },
             _ => (),
         }