From d0fccb552b87fa88c4c15c912e5012ffbb54f98e Mon Sep 17 00:00:00 2001 From: marmeladema Date: Thu, 4 Jun 2020 20:31:51 +0100 Subject: [PATCH] Remove unsused `NodeId` related APIs in hir map --- src/librustc_hir/definitions.rs | 6 +++++ src/librustc_middle/hir/map/mod.rs | 37 ++---------------------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/src/librustc_hir/definitions.rs b/src/librustc_hir/definitions.rs index c8971c2f9ad..2dd5e27ead2 100644 --- a/src/librustc_hir/definitions.rs +++ b/src/librustc_hir/definitions.rs @@ -364,6 +364,12 @@ impl Definitions { self.node_id_to_hir_id[node_id] } + #[inline] + pub fn opt_hir_id_to_local_def_id(&self, hir_id: hir::HirId) -> Option { + let node_id = self.hir_id_to_node_id(hir_id); + self.opt_local_def_id(node_id) + } + /// Retrieves the span of the given `DefId` if `DefId` is in the local crate. #[inline] pub fn opt_span(&self, def_id: DefId) -> Option { diff --git a/src/librustc_middle/hir/map/mod.rs b/src/librustc_middle/hir/map/mod.rs index 1e27f154911..53e88787323 100644 --- a/src/librustc_middle/hir/map/mod.rs +++ b/src/librustc_middle/hir/map/mod.rs @@ -3,7 +3,7 @@ use self::collector::NodeCollector; use crate::hir::{Owner, OwnerNodes}; use crate::ty::query::Providers; use crate::ty::TyCtxt; -use rustc_ast::ast::{self, NodeId}; +use rustc_ast::ast::{self}; use rustc_data_structures::svh::Svh; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; @@ -157,18 +157,6 @@ impl<'hir> Map<'hir> { self.tcx.definitions.def_path(def_id) } - #[inline] - pub fn local_def_id_from_node_id(&self, node: NodeId) -> LocalDefId { - self.opt_local_def_id_from_node_id(node).unwrap_or_else(|| { - let hir_id = self.node_id_to_hir_id(node); - bug!( - "local_def_id_from_node_id: no entry for `{}`, which has a map of `{:?}`", - node, - self.find_entry(hir_id) - ) - }) - } - #[inline] pub fn local_def_id(&self, hir_id: HirId) -> LocalDefId { self.opt_local_def_id(hir_id).unwrap_or_else(|| { @@ -182,13 +170,7 @@ impl<'hir> Map<'hir> { #[inline] pub fn opt_local_def_id(&self, hir_id: HirId) -> Option { - let node_id = self.hir_id_to_node_id(hir_id); - self.opt_local_def_id_from_node_id(node_id) - } - - #[inline] - pub fn opt_local_def_id_from_node_id(&self, node: NodeId) -> Option { - self.tcx.definitions.opt_local_def_id(node) + self.tcx.definitions.opt_hir_id_to_local_def_id(hir_id) } #[inline] @@ -196,21 +178,6 @@ impl<'hir> Map<'hir> { self.tcx.definitions.as_local_hir_id(def_id) } - #[inline] - pub fn hir_id_to_node_id(&self, hir_id: HirId) -> NodeId { - self.tcx.definitions.hir_id_to_node_id(hir_id) - } - - #[inline] - pub fn node_id_to_hir_id(&self, node_id: NodeId) -> HirId { - self.tcx.definitions.node_id_to_hir_id(node_id) - } - - #[inline] - pub fn opt_node_id_to_hir_id(&self, node_id: NodeId) -> Option { - self.tcx.definitions.opt_node_id_to_hir_id(node_id) - } - #[inline] pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId { self.tcx.definitions.local_def_id_to_hir_id(def_id)