diff options
| author | marmeladema <xademax@gmail.com> | 2020-06-04 20:31:51 +0100 |
|---|---|---|
| committer | marmeladema <xademax@gmail.com> | 2020-06-04 20:32:35 +0100 |
| commit | d0fccb552b87fa88c4c15c912e5012ffbb54f98e (patch) | |
| tree | ec9788e33dbdf67baf885cc4c1ad594a7095affa | |
| parent | 3d5d0f898c2f3998e50c2180c6202f193c3acdbc (diff) | |
| download | rust-d0fccb552b87fa88c4c15c912e5012ffbb54f98e.tar.gz rust-d0fccb552b87fa88c4c15c912e5012ffbb54f98e.zip | |
Remove unsused `NodeId` related APIs in hir map
| -rw-r--r-- | src/librustc_hir/definitions.rs | 6 | ||||
| -rw-r--r-- | 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<LocalDefId> { + 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<Span> { 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}; @@ -158,18 +158,6 @@ impl<'hir> Map<'hir> { } #[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(|| { bug!( @@ -182,13 +170,7 @@ impl<'hir> Map<'hir> { #[inline] pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<LocalDefId> { - 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<LocalDefId> { - self.tcx.definitions.opt_local_def_id(node) + self.tcx.definitions.opt_hir_id_to_local_def_id(hir_id) } #[inline] @@ -197,21 +179,6 @@ impl<'hir> Map<'hir> { } #[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<HirId> { - 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) } |
