]> git.lizzy.rs Git - rust.git/commitdiff
make hir::def_kind work with HirId
authorljedrz <ljedrz@gmail.com>
Thu, 20 Jun 2019 07:41:26 +0000 (09:41 +0200)
committerljedrz <ljedrz@gmail.com>
Thu, 20 Jun 2019 10:47:26 +0000 (12:47 +0200)
src/librustc/hir/map/mod.rs

index 259f6cd27112fbe602dd2fde729d8194f63faad3..572f94d3382e17b55e5b45f13bbd31d6d521bd6e 100644 (file)
@@ -291,8 +291,8 @@ pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId {
         self.definitions.def_index_to_hir_id(def_id.to_def_id().index)
     }
 
-    fn def_kind(&self, node_id: NodeId) -> Option<DefKind> {
-        let node = if let Some(node) = self.find(node_id) {
+    fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {
+        let node = if let Some(node) = self.find_by_hir_id(hir_id) {
             node
         } else {
             return None
@@ -347,7 +347,7 @@ fn def_kind(&self, node_id: NodeId) -> Option<DefKind> {
                 if variant_data.ctor_hir_id().is_none() {
                     return None;
                 }
-                let ctor_of = match self.find(self.get_parent_node(node_id)) {
+                let ctor_of = match self.find_by_hir_id(self.get_parent_node_by_hir_id(hir_id)) {
                     Some(Node::Item(..)) => def::CtorOf::Struct,
                     Some(Node::Variant(..)) => def::CtorOf::Variant,
                     _ => unreachable!(),
@@ -1400,8 +1400,8 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
 
 pub fn provide(providers: &mut Providers<'_>) {
     providers.def_kind = |tcx, def_id| {
-        if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
-            tcx.hir().def_kind(node_id)
+        if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
+            tcx.hir().def_kind(hir_id)
         } else {
             bug!("calling local def_kind query provider for upstream DefId: {:?}",
                 def_id