diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 307f03c6928..d657bb6a0b4 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -327,7 +327,7 @@ impl<'a, 'tcx: 'a> DerefVisitor<'a, 'tcx> { fn check_arg(&self, ptr: &hir::Expr) { if let hir::ExprKind::Path(ref qpath) = ptr.node { if let Def::Local(id) = self.cx.tables.qpath_def(qpath, ptr.hir_id) { - if self.ptrs.contains(&self.cx.tcx.hir().node_to_hir_id(id)) { + if self.ptrs.contains(&id) { span_lint( self.cx, NOT_UNSAFE_PTR_ARG_DEREF, diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 5ef3d8dd4ab..1f454c4983a 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -150,7 +150,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> { 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 +175,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, diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 11b4d237c56..ccd8be38868 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -790,7 +790,7 @@ fn same_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: HirId) -> bo if path.segments.len() == 1; if let Def::Local(local_id) = cx.tables.qpath_def(qpath, expr.hir_id); // our variable! - if cx.tcx.hir().node_to_hir_id(local_id) == var; + if local_id == var; then { return true; } @@ -1663,7 +1663,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option if let PatKind::Binding(bind_ann, ..) = pat.node; if let BindingAnnotation::Mutable = bind_ann; then { - return Some(cx.tcx.hir().node_to_hir_id(node_id)); + return Some(node_id); } } } @@ -1792,9 +1792,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> { } let def = self.cx.tables.qpath_def(seqpath, seqexpr.hir_id); match def { - Def::Local(node_id) | Def::Upvar(node_id, ..) => { - let hir_id = self.cx.tcx.hir().node_to_hir_id(node_id); - + Def::Local(hir_id) | Def::Upvar(hir_id, ..) => { let parent_id = self.cx.tcx.hir().get_parent_item(expr.hir_id); let parent_def_id = self.cx.tcx.hir().local_def_id_from_hir_id(parent_id); let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id); @@ -1856,7 +1854,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { then { match self.cx.tables.qpath_def(qpath, expr.hir_id) { Def::Upvar(local_id, ..) => { - if self.cx.tcx.hir().node_to_hir_id(local_id) == self.var { + if local_id == self.var { // we are not indexing anything, record that self.nonindex = true; } @@ -1864,7 +1862,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { Def::Local(local_id) => { - if self.cx.tcx.hir().node_to_hir_id(local_id) == self.var { + if local_id == self.var { self.nonindex = true; } else { // not the correct variable, but still a variable @@ -2209,7 +2207,7 @@ fn var_def_id(cx: &LateContext<'_, '_>, expr: &Expr) -> Option { if let ExprKind::Path(ref qpath) = expr.node { let path_res = cx.tables.qpath_def(qpath, expr.hir_id); if let Def::Local(node_id) = path_res { - return Some(cx.tcx.hir().node_to_hir_id(node_id)); + return Some(node_id); } } None @@ -2404,7 +2402,7 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> { then { match def { Def::Local(node_id) | Def::Upvar(node_id, ..) => { - self.ids.insert(self.cx.tcx.hir().node_to_hir_id(node_id)); + self.ids.insert(node_id); }, Def::Static(def_id, mutable) => { self.def_ids.insert(def_id, mutable); diff --git a/clippy_lints/src/methods/unnecessary_filter_map.rs b/clippy_lints/src/methods/unnecessary_filter_map.rs index c081384db4b..c751de865be 100644 --- a/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -68,7 +68,7 @@ fn check_expression<'a, 'tcx: 'a>( if let hir::ExprKind::Path(path) = &args[0].node; if let Def::Local(ref local) = cx.tables.qpath_def(path, args[0].hir_id); then { - if arg_id == cx.tcx.hir().node_to_hir_id(*local) { + if arg_id == *local { return (false, false) } } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 3383e47ac77..e5ce17cf192 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -958,7 +958,7 @@ pub fn is_try<'a>(cx: &'_ LateContext<'_, '_>, expr: &'a Expr) -> Option<&'a Exp if let PatKind::Binding(_, hir_id, _, None) = pat[0].node; if let ExprKind::Path(QPath::Resolved(None, ref path)) = arm.body.node; if let Def::Local(lid) = path.def; - if cx.tcx.hir().node_to_hir_id(lid) == hir_id; + if lid == hir_id; then { return true; } diff --git a/clippy_lints/src/utils/usage.rs b/clippy_lints/src/utils/usage.rs index 521ddbc0865..14711b7fe1b 100644 --- a/clippy_lints/src/utils/usage.rs +++ b/clippy_lints/src/utils/usage.rs @@ -33,7 +33,7 @@ pub fn is_potentially_mutated<'a, 'tcx: 'a>( Def::Local(id) | Def::Upvar(id, ..) => id, _ => return true, }; - mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&cx.tcx.hir().node_to_hir_id(id))) + mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&id)) } struct MutVarsDelegate {