Remove now-unnecessary calls to node_to_hir_id

This commit is contained in:
Manish Goregaokar 2019-04-14 13:09:17 -07:00
parent 6505794bc6
commit 1b2f2be085
6 changed files with 13 additions and 15 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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<HirId>
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<HirId> {
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);

View File

@ -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)
}
}

View File

@ -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;
}

View File

@ -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 {