1
Fork 0

rename hir::map::opt_local_def_id*

This commit is contained in:
ljedrz 2019-06-27 11:49:08 +02:00
parent 37d7e1f22a
commit c6131b23ae
4 changed files with 9 additions and 9 deletions

View file

@ -220,7 +220,7 @@ impl<'hir> Map<'hir> {
}
pub fn def_path_from_hir_id(&self, id: HirId) -> Option<DefPath> {
self.opt_local_def_id_from_hir_id(id).map(|def_id| {
self.opt_local_def_id(id).map(|def_id| {
self.def_path(def_id)
})
}
@ -232,7 +232,7 @@ impl<'hir> Map<'hir> {
#[inline]
pub fn local_def_id_from_node_id(&self, node: NodeId) -> DefId {
self.opt_local_def_id(node).unwrap_or_else(|| {
self.opt_local_def_id_from_node_id(node).unwrap_or_else(|| {
let hir_id = self.node_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))
@ -248,13 +248,13 @@ impl<'hir> Map<'hir> {
}
#[inline]
pub fn opt_local_def_id_from_hir_id(&self, hir_id: HirId) -> Option<DefId> {
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<DefId> {
let node_id = self.hir_to_node_id(hir_id);
self.definitions.opt_local_def_id(node_id)
}
#[inline]
pub fn opt_local_def_id(&self, node: NodeId) -> Option<DefId> {
pub fn opt_local_def_id_from_node_id(&self, node: NodeId) -> Option<DefId> {
self.definitions.opt_local_def_id(node)
}

View file

@ -1217,7 +1217,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
let access = access_from!(self.save_ctxt, root_item, hir_id);
// The parent `DefId` of a given use tree is always the enclosing item.
let parent = self.save_ctxt.tcx.hir().opt_local_def_id(id)
let parent = self.save_ctxt.tcx.hir().opt_local_def_id_from_node_id(id)
.and_then(|id| self.save_ctxt.tcx.parent(id))
.map(id_from_def_id);
@ -1367,7 +1367,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
let name_span = item.ident.span;
if !self.span.filter_generated(name_span) {
let span = self.span_from_span(name_span);
let parent = self.save_ctxt.tcx.hir().opt_local_def_id(item.id)
let parent = self.save_ctxt.tcx.hir().opt_local_def_id_from_node_id(item.id)
.and_then(|id| self.save_ctxt.tcx.parent(id))
.map(id_from_def_id);
self.dumper.import(

View file

@ -1193,7 +1193,7 @@ fn id_from_def_id(id: DefId) -> rls_data::Id {
}
fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id {
let def_id = scx.tcx.hir().opt_local_def_id(id);
let def_id = scx.tcx.hir().opt_local_def_id_from_node_id(id);
def_id.map(|id| id_from_def_id(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*

View file

@ -66,12 +66,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
}
fn stability(&self, id: hir::HirId) -> Option<attr::Stability> {
self.cx.tcx.hir().opt_local_def_id_from_hir_id(id)
self.cx.tcx.hir().opt_local_def_id(id)
.and_then(|def_id| self.cx.tcx.lookup_stability(def_id)).cloned()
}
fn deprecation(&self, id: hir::HirId) -> Option<attr::Deprecation> {
self.cx.tcx.hir().opt_local_def_id_from_hir_id(id)
self.cx.tcx.hir().opt_local_def_id(id)
.and_then(|def_id| self.cx.tcx.lookup_deprecation(def_id))
}