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) {
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;
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,