save-analysis: Deduplicate lookup_{d,r}ef_id functions
This commit is contained in:
parent
0fafd615e5
commit
30e39e871f
@ -130,6 +130,10 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
||||
self.save_ctxt.span_from_span(span)
|
||||
}
|
||||
|
||||
fn lookup_def_id(&self, ref_id: NodeId) -> Option<DefId> {
|
||||
self.save_ctxt.lookup_def_id(ref_id)
|
||||
}
|
||||
|
||||
pub fn dump_crate_info(&mut self, name: &str, krate: &ast::Crate) {
|
||||
let source_file = self.tcx.sess.local_crate_source_file.as_ref();
|
||||
let crate_root = source_file.map(|source_file| {
|
||||
@ -223,13 +227,6 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn lookup_def_id(&self, ref_id: NodeId) -> Option<DefId> {
|
||||
match self.save_ctxt.get_path_res(ref_id) {
|
||||
Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => None,
|
||||
def => Some(def.def_id()),
|
||||
}
|
||||
}
|
||||
|
||||
fn process_formals(&mut self, formals: &'l [ast::Param], qualname: &str) {
|
||||
for arg in formals {
|
||||
self.visit_pat(&arg.pat);
|
||||
|
@ -312,7 +312,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
let impl_id = self.next_impl_id();
|
||||
let span = self.span_from_span(sub_span);
|
||||
|
||||
let type_data = self.lookup_ref_id(typ.id);
|
||||
let type_data = self.lookup_def_id(typ.id);
|
||||
type_data.map(|type_data| {
|
||||
Data::RelationData(Relation {
|
||||
kind: RelationKind::Impl {
|
||||
@ -322,7 +322,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
from: id_from_def_id(type_data),
|
||||
to: trait_ref
|
||||
.as_ref()
|
||||
.and_then(|t| self.lookup_ref_id(t.ref_id))
|
||||
.and_then(|t| self.lookup_def_id(t.ref_id))
|
||||
.map(id_from_def_id)
|
||||
.unwrap_or_else(|| null_id()),
|
||||
},
|
||||
@ -495,7 +495,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn get_trait_ref_data(&self, trait_ref: &ast::TraitRef) -> Option<Ref> {
|
||||
self.lookup_ref_id(trait_ref.ref_id).and_then(|def_id| {
|
||||
self.lookup_def_id(trait_ref.ref_id).and_then(|def_id| {
|
||||
let span = trait_ref.path.span;
|
||||
if generated_code(span) {
|
||||
return None;
|
||||
@ -870,7 +870,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
fn lookup_ref_id(&self, ref_id: NodeId) -> Option<DefId> {
|
||||
fn lookup_def_id(&self, ref_id: NodeId) -> Option<DefId> {
|
||||
match self.get_path_res(ref_id) {
|
||||
Res::PrimTy(_) | Res::SelfTy(..) | Res::Err => None,
|
||||
def => Some(def.def_id()),
|
||||
|
Loading…
x
Reference in New Issue
Block a user