Skip to content

Commit d01f7ae

Browse files
authored
Rollup merge of rust-lang#72996 - marmeladema:remove-hir-map-nodeid-apis, r=ecstatic-morse
Remove unsused `NodeId` related APIs in hir map cc rust-lang#50928 r? @ecstatic-morse
2 parents 14dc34d + d0fccb5 commit d01f7ae

File tree

2 files changed

+8
-35
lines changed

2 files changed

+8
-35
lines changed

src/librustc_hir/definitions.rs

+6
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ impl Definitions {
364364
self.node_id_to_hir_id[node_id]
365365
}
366366

367+
#[inline]
368+
pub fn opt_hir_id_to_local_def_id(&self, hir_id: hir::HirId) -> Option<LocalDefId> {
369+
let node_id = self.hir_id_to_node_id(hir_id);
370+
self.opt_local_def_id(node_id)
371+
}
372+
367373
/// Retrieves the span of the given `DefId` if `DefId` is in the local crate.
368374
#[inline]
369375
pub fn opt_span(&self, def_id: DefId) -> Option<Span> {

src/librustc_middle/hir/map/mod.rs

+2-35
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use self::collector::NodeCollector;
33
use crate::hir::{Owner, OwnerNodes};
44
use crate::ty::query::Providers;
55
use crate::ty::TyCtxt;
6-
use rustc_ast::ast::{self, NodeId};
6+
use rustc_ast::ast::{self};
77
use rustc_data_structures::svh::Svh;
88
use rustc_hir::def::{DefKind, Res};
99
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
@@ -157,18 +157,6 @@ impl<'hir> Map<'hir> {
157157
self.tcx.definitions.def_path(def_id)
158158
}
159159

160-
#[inline]
161-
pub fn local_def_id_from_node_id(&self, node: NodeId) -> LocalDefId {
162-
self.opt_local_def_id_from_node_id(node).unwrap_or_else(|| {
163-
let hir_id = self.node_id_to_hir_id(node);
164-
bug!(
165-
"local_def_id_from_node_id: no entry for `{}`, which has a map of `{:?}`",
166-
node,
167-
self.find_entry(hir_id)
168-
)
169-
})
170-
}
171-
172160
#[inline]
173161
pub fn local_def_id(&self, hir_id: HirId) -> LocalDefId {
174162
self.opt_local_def_id(hir_id).unwrap_or_else(|| {
@@ -182,35 +170,14 @@ impl<'hir> Map<'hir> {
182170

183171
#[inline]
184172
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<LocalDefId> {
185-
let node_id = self.hir_id_to_node_id(hir_id);
186-
self.opt_local_def_id_from_node_id(node_id)
187-
}
188-
189-
#[inline]
190-
pub fn opt_local_def_id_from_node_id(&self, node: NodeId) -> Option<LocalDefId> {
191-
self.tcx.definitions.opt_local_def_id(node)
173+
self.tcx.definitions.opt_hir_id_to_local_def_id(hir_id)
192174
}
193175

194176
#[inline]
195177
pub fn as_local_hir_id(&self, def_id: LocalDefId) -> HirId {
196178
self.tcx.definitions.as_local_hir_id(def_id)
197179
}
198180

199-
#[inline]
200-
pub fn hir_id_to_node_id(&self, hir_id: HirId) -> NodeId {
201-
self.tcx.definitions.hir_id_to_node_id(hir_id)
202-
}
203-
204-
#[inline]
205-
pub fn node_id_to_hir_id(&self, node_id: NodeId) -> HirId {
206-
self.tcx.definitions.node_id_to_hir_id(node_id)
207-
}
208-
209-
#[inline]
210-
pub fn opt_node_id_to_hir_id(&self, node_id: NodeId) -> Option<HirId> {
211-
self.tcx.definitions.opt_node_id_to_hir_id(node_id)
212-
}
213-
214181
#[inline]
215182
pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId {
216183
self.tcx.definitions.local_def_id_to_hir_id(def_id)

0 commit comments

Comments
 (0)