1
Fork 0

Remove HirId to NodeId conversion APIs

This commit is contained in:
marmeladema 2020-06-12 18:43:58 +01:00
parent a98f35f503
commit 6a0f1af19d
2 changed files with 5 additions and 18 deletions

View file

@ -337,11 +337,6 @@ impl Definitions {
self.local_def_id_to_hir_id(def_id)
}
#[inline]
pub fn hir_id_to_node_id(&self, hir_id: hir::HirId) -> ast::NodeId {
self.hir_id_to_node_id[&hir_id]
}
#[inline]
pub fn local_def_id_to_hir_id(&self, id: LocalDefId) -> hir::HirId {
let node_id = self.def_id_to_node_id[id];
@ -356,7 +351,7 @@ impl Definitions {
#[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);
let node_id = self.hir_id_to_node_id[&hir_id];
self.opt_local_def_id(node_id)
}

View file

@ -242,10 +242,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
// Make sure that the DepNode of some node coincides with the HirId
// owner of that node.
if cfg!(debug_assertions) {
let node_id = self.definitions.hir_id_to_node_id(hir_id);
if hir_id.owner != self.current_dep_node_owner {
let node_str = match self.definitions.opt_local_def_id(node_id) {
let node_str = match self.definitions.opt_hir_id_to_local_def_id(hir_id) {
Some(def_id) => self.definitions.def_path(def_id).to_string_no_crate(),
None => format!("{:?}", node),
};
@ -335,9 +333,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
debug!("visit_item: {:?}", i);
debug_assert_eq!(
i.hir_id.owner,
self.definitions
.opt_local_def_id(self.definitions.hir_id_to_node_id(i.hir_id))
.unwrap()
self.definitions.opt_hir_id_to_local_def_id(i.hir_id).unwrap()
);
self.with_dep_node_owner(i.hir_id.owner, i, |this, hash| {
this.insert_with_hash(i.span, i.hir_id, Node::Item(i), hash);
@ -369,9 +365,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
debug_assert_eq!(
ti.hir_id.owner,
self.definitions
.opt_local_def_id(self.definitions.hir_id_to_node_id(ti.hir_id))
.unwrap()
self.definitions.opt_hir_id_to_local_def_id(ti.hir_id).unwrap()
);
self.with_dep_node_owner(ti.hir_id.owner, ti, |this, hash| {
this.insert_with_hash(ti.span, ti.hir_id, Node::TraitItem(ti), hash);
@ -385,9 +379,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) {
debug_assert_eq!(
ii.hir_id.owner,
self.definitions
.opt_local_def_id(self.definitions.hir_id_to_node_id(ii.hir_id))
.unwrap()
self.definitions.opt_hir_id_to_local_def_id(ii.hir_id).unwrap()
);
self.with_dep_node_owner(ii.hir_id.owner, ii, |this, hash| {
this.insert_with_hash(ii.span, ii.hir_id, Node::ImplItem(ii), hash);