Skip to content

Commit

Permalink
Rollup merge of #72996 - marmeladema:remove-hir-map-nodeid-apis, r=ec…
Browse files Browse the repository at this point in the history
…static-morse

Remove unsused `NodeId` related APIs in hir map

cc #50928

r? @ecstatic-morse
  • Loading branch information
Dylan-DPC authored Jun 5, 2020
2 parents 28c9095 + d0fccb5 commit 915b165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
6 changes: 6 additions & 0 deletions src/librustc_hir/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
37 changes: 2 additions & 35 deletions src/librustc_middle/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(|| {
Expand All @@ -182,35 +170,14 @@ 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]
pub fn as_local_hir_id(&self, def_id: LocalDefId) -> HirId {
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<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)
Expand Down

0 comments on commit 915b165

Please sign in to comment.