]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/let_if_seq.rs
Auto merge of #3985 - phansch:move_some_cast_tests, r=flip1995
[rust.git] / clippy_lints / src / let_if_seq.rs
index 5ef3d8dd4abf101602edf3a7442f01f9f931e875..f5da2d7803e381254daaaa079093fc6bb77eaafc 100644 (file)
@@ -4,7 +4,7 @@
 use rustc::hir::def::Def;
 use rustc::hir::BindingAnnotation;
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_tool_lint, lint_array};
+use rustc::{declare_lint_pass, declare_tool_lint};
 use rustc_errors::Applicability;
 
 declare_clippy_lint! {
     "unidiomatic `let mut` declaration followed by initialization in `if`"
 }
 
-#[derive(Copy, Clone)]
-pub struct LetIfSeq;
-
-impl LintPass for LetIfSeq {
-    fn get_lints(&self) -> LintArray {
-        lint_array!(USELESS_LET_IF_SEQ)
-    }
-
-    fn name(&self) -> &'static str {
-        "LetIfSeq"
-    }
-}
+declare_lint_pass!(LetIfSeq => [USELESS_LET_IF_SEQ]);
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
     fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block) {
@@ -150,7 +139,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
         if_chain! {
             if let hir::ExprKind::Path(ref qpath) = expr.node;
             if let Def::Local(local_id) = self.cx.tables.qpath_def(qpath, expr.hir_id);
-            if self.id == self.cx.tcx.hir().node_to_hir_id(local_id);
+            if self.id == local_id;
             then {
                 self.used = true;
                 return;
@@ -175,7 +164,7 @@ fn check_assign<'a, 'tcx>(
         if let hir::ExprKind::Assign(ref var, ref value) = expr.node;
         if let hir::ExprKind::Path(ref qpath) = var.node;
         if let Def::Local(local_id) = cx.tables.qpath_def(qpath, var.hir_id);
-        if decl == cx.tcx.hir().node_to_hir_id(local_id);
+        if decl == local_id;
         then {
             let mut v = UsedVisitor {
                 cx,