about summary refs log tree commit diff
path: root/src/librustc/middle
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-06-25 17:15:36 +0200
committerGitHub <noreply@github.com>2019-06-25 17:15:36 +0200
commitabc7423f27cebb55ea9cbc67b3edc8cbcaa5e0eb (patch)
treea9456be8ebd20d834fb93d7f8d67c394f331b1ca /src/librustc/middle
parent6070e2e87616d8b2ae9ea58c800a79be936b9aab (diff)
parent87438a163ec153e2322b70e8c5c987c7c89be0b4 (diff)
downloadrust-abc7423f27cebb55ea9cbc67b3edc8cbcaa5e0eb.tar.gz
rust-abc7423f27cebb55ea9cbc67b3edc8cbcaa5e0eb.zip
Rollup merge of #62091 - ljedrz:hiridification_almost_there, r=Zoxc
HirIdification: almost there

I'm beginning to run out of stuff to HirIdify :wink:.

This time I targeted mainly `hir::map::{find, get_parent_node}`, but a few other bits got changed too.

r? @Zoxc
Diffstat (limited to 'src/librustc/middle')
-rw-r--r--src/librustc/middle/dead.rs4
-rw-r--r--src/librustc/middle/liveness.rs10
-rw-r--r--src/librustc/middle/mem_categorization.rs2
-rw-r--r--src/librustc/middle/reachable.rs6
-rw-r--r--src/librustc/middle/resolve_lifetime.rs6
5 files changed, 13 insertions, 15 deletions
diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs
index 9e2038fa89e..e02ee894360 100644
--- a/src/librustc/middle/dead.rs
+++ b/src/librustc/middle/dead.rs
@@ -27,7 +27,7 @@ use syntax_pos;
 // function, then we should explore its block to check for codes that
 // may need to be marked as live.
 fn should_explore<'tcx>(tcx: TyCtxt<'tcx>, hir_id: hir::HirId) -> bool {
-    match tcx.hir().find_by_hir_id(hir_id) {
+    match tcx.hir().find(hir_id) {
         Some(Node::Item(..)) |
         Some(Node::ImplItem(..)) |
         Some(Node::ForeignItem(..)) |
@@ -145,7 +145,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
             // tuple struct constructor function
             let id = self.struct_constructors.get(&id).cloned().unwrap_or(id);
 
-            if let Some(node) = self.tcx.hir().find_by_hir_id(id) {
+            if let Some(node) = self.tcx.hir().find(id) {
                 self.live_symbols.insert(id);
                 self.visit_node(node);
             }
diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs
index 0d59e32b098..7b69fe394fb 100644
--- a/src/librustc/middle/liveness.rs
+++ b/src/librustc/middle/liveness.rs
@@ -110,7 +110,7 @@ use std::{fmt, u32};
 use std::io::prelude::*;
 use std::io;
 use std::rc::Rc;
-use syntax::ast::{self, NodeId};
+use syntax::ast;
 use syntax::ptr::P;
 use syntax::symbol::{kw, sym};
 use syntax_pos::Span;
@@ -369,7 +369,7 @@ fn visit_fn<'tcx>(
     // Don't run unused pass for #[derive()]
     if let FnKind::Method(..) = fk {
         let parent = ir.tcx.hir().get_parent_item(id);
-        if let Some(Node::Item(i)) = ir.tcx.hir().find_by_hir_id(parent) {
+        if let Some(Node::Item(i)) = ir.tcx.hir().find(parent) {
             if i.attrs.iter().any(|a| a.check_name(sym::automatically_derived)) {
                 return;
             }
@@ -1327,12 +1327,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
         }
     }
 
-    fn access_var(&mut self, hir_id: HirId, nid: NodeId, succ: LiveNode, acc: u32, span: Span)
+    fn access_var(&mut self, hir_id: HirId, var_hid: HirId, succ: LiveNode, acc: u32, span: Span)
                   -> LiveNode {
         let ln = self.live_node(hir_id, span);
         if acc != 0 {
             self.init_from_succ(ln, succ);
-            let var_hid = self.ir.tcx.hir().node_to_hir_id(nid);
             let var = self.variable(var_hid, span);
             self.acc(ln, var, acc);
         }
@@ -1345,8 +1344,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
             Res::Local(hid) => {
                 let upvars = self.ir.tcx.upvars(self.ir.body_owner);
                 if !upvars.map_or(false, |upvars| upvars.contains_key(&hid)) {
-                    let nid = self.ir.tcx.hir().hir_to_node_id(hid);
-                    self.access_var(hir_id, nid, succ, acc, path.span)
+                    self.access_var(hir_id, hid, succ, acc, path.span)
                 } else {
                     succ
                 }
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index 10796abe5d4..e7253a73bd4 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -1526,7 +1526,7 @@ impl<'tcx> cmt_<'tcx> {
                 "non-place".into()
             }
             Categorization::Local(vid) => {
-                if tcx.hir().is_argument(tcx.hir().hir_to_node_id(vid)) {
+                if tcx.hir().is_argument(vid) {
                     "argument"
                 } else {
                     "local variable"
diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs
index 593c5e73421..d607c35f876 100644
--- a/src/librustc/middle/reachable.rs
+++ b/src/librustc/middle/reachable.rs
@@ -53,7 +53,7 @@ fn method_might_be_inlined<'tcx>(
         return true
     }
     if let Some(impl_hir_id) = tcx.hir().as_local_hir_id(impl_src) {
-        match tcx.hir().find_by_hir_id(impl_hir_id) {
+        match tcx.hir().find(impl_hir_id) {
             Some(Node::Item(item)) =>
                 item_might_be_inlined(tcx, &item, codegen_fn_attrs),
             Some(..) | None =>
@@ -147,7 +147,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
             None => { return false; }
         };
 
-        match self.tcx.hir().find_by_hir_id(hir_id) {
+        match self.tcx.hir().find(hir_id) {
             Some(Node::Item(item)) => {
                 match item.node {
                     hir::ItemKind::Fn(..) =>
@@ -205,7 +205,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
                 continue
             }
 
-            if let Some(ref item) = self.tcx.hir().find_by_hir_id(search_item) {
+            if let Some(ref item) = self.tcx.hir().find(search_item) {
                 self.propagate_node(item, search_item);
             }
         }
diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs
index b8e7db99d07..412346bab25 100644
--- a/src/librustc/middle/resolve_lifetime.rs
+++ b/src/librustc/middle/resolve_lifetime.rs
@@ -662,7 +662,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                         if let Some(Region::LateBound(_, def_id, _)) = def {
                             if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
                                 // Ensure that the parent of the def is an item, not HRTB
-                                let parent_id = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
+                                let parent_id = self.tcx.hir().get_parent_node(hir_id);
                                 let parent_impl_id = hir::ImplItemId { hir_id: parent_id };
                                 let parent_trait_id = hir::TraitItemId { hir_id: parent_id };
                                 let krate = self.tcx.hir().forest.krate();
@@ -1489,7 +1489,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
             }
         };
         if let Node::Lifetime(hir_lifetime) = self.tcx.hir().get(lifetime.hir_id) {
-            if let Some(parent) = self.tcx.hir().find_by_hir_id(
+            if let Some(parent) = self.tcx.hir().find(
                 self.tcx.hir().get_parent_item(hir_lifetime.hir_id))
             {
                 match parent {
@@ -2051,7 +2051,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
         // and whether there's a `self` argument (treated specially).
         let mut assoc_item_kind = None;
         let mut impl_self = None;
-        let parent = self.tcx.hir().get_parent_node_by_hir_id(output.hir_id);
+        let parent = self.tcx.hir().get_parent_node(output.hir_id);
         let body = match self.tcx.hir().get(parent) {
             // `fn` definitions and methods.
             Node::Item(&hir::Item {