// FIXME(eddyb) this function can and should return `LocalDefId`.
#[inline]
pub fn local_def_id_from_node_id(&self, node: NodeId) -> DefId {
- 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)
- )
- })
+ 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)
+ )
+ })
+ .to_def_id()
}
// FIXME(eddyb) this function can and should return `LocalDefId`.
#[inline]
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<DefId> {
let node_id = self.hir_id_to_node_id(hir_id);
- self.opt_local_def_id_from_node_id(node_id)
+ Some(self.opt_local_def_id_from_node_id(node_id)?.to_def_id())
}
#[inline]
- pub fn opt_local_def_id_from_node_id(&self, node: NodeId) -> Option<DefId> {
- Some(self.tcx.definitions.opt_local_def_id(node)?.to_def_id())
+ pub fn opt_local_def_id_from_node_id(&self, node: NodeId) -> Option<LocalDefId> {
+ self.tcx.definitions.opt_local_def_id(node)
}
#[inline]
.tcx
.hir()
.opt_local_def_id_from_node_id(id)
- .and_then(|id| self.save_ctxt.tcx.parent(id))
+ .and_then(|id| self.save_ctxt.tcx.parent(id.to_def_id()))
.map(id_from_def_id);
match use_tree.kind {
.tcx
.hir()
.opt_local_def_id_from_node_id(item.id)
- .and_then(|id| self.save_ctxt.tcx.parent(id))
+ .and_then(|id| self.save_ctxt.tcx.parent(id.to_def_id()))
.map(id_from_def_id);
self.dumper.import(
&Access { public: false, reachable: false },
fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id {
let def_id = scx.tcx.hir().opt_local_def_id_from_node_id(id);
- def_id.map(id_from_def_id).unwrap_or_else(|| {
+ def_id.map(|id| id_from_def_id(id.to_def_id())).unwrap_or_else(|| {
// Create a *fake* `DefId` out of a `NodeId` by subtracting the `NodeId`
// out of the maximum u32 value. This will work unless you have *billions*
// of definitions in a single crate (very unlikely to actually happen).