Rename some OwnerId
fields.
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
This commit is contained in:
parent
33b55ac39f
commit
c8c25ce5a1
107 changed files with 618 additions and 603 deletions
|
@ -345,14 +345,14 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
body: hir::BodyId,
|
||||
) {
|
||||
let map = self.tcx.hir();
|
||||
self.nest_typeck_results(item.def_id.def_id, |v| {
|
||||
self.nest_typeck_results(item.owner_id.def_id, |v| {
|
||||
let body = map.body(body);
|
||||
if let Some(fn_data) = v.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(fn_data, DefData, item.span);
|
||||
v.process_formals(body.params, &fn_data.qualname);
|
||||
v.process_generic_params(ty_params, &fn_data.qualname, item.hir_id());
|
||||
|
||||
v.dumper.dump_def(&access_from!(v.save_ctxt, item.def_id.def_id), fn_data);
|
||||
v.dumper.dump_def(&access_from!(v.save_ctxt, item.owner_id.def_id), fn_data);
|
||||
}
|
||||
|
||||
for arg in decl.inputs {
|
||||
|
@ -373,10 +373,10 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
typ: &'tcx hir::Ty<'tcx>,
|
||||
expr: &'tcx hir::Expr<'tcx>,
|
||||
) {
|
||||
self.nest_typeck_results(item.def_id.def_id, |v| {
|
||||
self.nest_typeck_results(item.owner_id.def_id, |v| {
|
||||
if let Some(var_data) = v.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(var_data, DefData, item.span);
|
||||
v.dumper.dump_def(&access_from!(v.save_ctxt, item.def_id.def_id), var_data);
|
||||
v.dumper.dump_def(&access_from!(v.save_ctxt, item.owner_id.def_id), var_data);
|
||||
}
|
||||
v.visit_ty(&typ);
|
||||
v.visit_expr(expr);
|
||||
|
@ -436,7 +436,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
) {
|
||||
debug!("process_struct {:?} {:?}", item, item.span);
|
||||
let name = item.ident.to_string();
|
||||
let qualname = format!("::{}", self.tcx.def_path_str(item.def_id.to_def_id()));
|
||||
let qualname = format!("::{}", self.tcx.def_path_str(item.owner_id.to_def_id()));
|
||||
|
||||
let kind = match item.kind {
|
||||
hir::ItemKind::Struct(_, _) => DefKind::Struct,
|
||||
|
@ -473,10 +473,10 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
let span = self.span_from_span(item.ident.span);
|
||||
let attrs = self.tcx.hir().attrs(item.hir_id());
|
||||
self.dumper.dump_def(
|
||||
&access_from!(self.save_ctxt, item.def_id.def_id),
|
||||
&access_from!(self.save_ctxt, item.owner_id.def_id),
|
||||
Def {
|
||||
kind,
|
||||
id: id_from_def_id(item.def_id.to_def_id()),
|
||||
id: id_from_def_id(item.owner_id.to_def_id()),
|
||||
span,
|
||||
name,
|
||||
qualname: qualname.clone(),
|
||||
|
@ -491,7 +491,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
self.nest_typeck_results(item.def_id.def_id, |v| {
|
||||
self.nest_typeck_results(item.owner_id.def_id, |v| {
|
||||
for field in def.fields() {
|
||||
v.process_struct_field_def(field, item.hir_id());
|
||||
v.visit_ty(&field.ty);
|
||||
|
@ -513,7 +513,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
};
|
||||
down_cast_data!(enum_data, DefData, item.span);
|
||||
|
||||
let access = access_from!(self.save_ctxt, item.def_id.def_id);
|
||||
let access = access_from!(self.save_ctxt, item.owner_id.def_id);
|
||||
|
||||
for variant in enum_definition.variants {
|
||||
let name = variant.ident.name.to_string();
|
||||
|
@ -528,7 +528,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
if !self.span.filter_generated(name_span) {
|
||||
let span = self.span_from_span(name_span);
|
||||
let id = id_from_hir_id(variant.id, &self.save_ctxt);
|
||||
let parent = Some(id_from_def_id(item.def_id.to_def_id()));
|
||||
let parent = Some(id_from_def_id(item.owner_id.to_def_id()));
|
||||
let attrs = self.tcx.hir().attrs(variant.id);
|
||||
|
||||
self.dumper.dump_def(
|
||||
|
@ -566,7 +566,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
if !self.span.filter_generated(name_span) {
|
||||
let span = self.span_from_span(name_span);
|
||||
let id = id_from_hir_id(variant.id, &self.save_ctxt);
|
||||
let parent = Some(id_from_def_id(item.def_id.to_def_id()));
|
||||
let parent = Some(id_from_def_id(item.owner_id.to_def_id()));
|
||||
let attrs = self.tcx.hir().attrs(variant.id);
|
||||
|
||||
self.dumper.dump_def(
|
||||
|
@ -612,14 +612,14 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
}
|
||||
|
||||
let map = self.tcx.hir();
|
||||
self.nest_typeck_results(item.def_id.def_id, |v| {
|
||||
self.nest_typeck_results(item.owner_id.def_id, |v| {
|
||||
v.visit_ty(&impl_.self_ty);
|
||||
if let Some(trait_ref) = &impl_.of_trait {
|
||||
v.process_path(trait_ref.hir_ref_id, &hir::QPath::Resolved(None, &trait_ref.path));
|
||||
}
|
||||
v.process_generic_params(&impl_.generics, "", item.hir_id());
|
||||
for impl_item in impl_.items {
|
||||
v.process_impl_item(map.impl_item(impl_item.id), item.def_id.to_def_id());
|
||||
v.process_impl_item(map.impl_item(impl_item.id), item.owner_id.to_def_id());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -632,7 +632,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
methods: &'tcx [hir::TraitItemRef],
|
||||
) {
|
||||
let name = item.ident.to_string();
|
||||
let qualname = format!("::{}", self.tcx.def_path_str(item.def_id.to_def_id()));
|
||||
let qualname = format!("::{}", self.tcx.def_path_str(item.owner_id.to_def_id()));
|
||||
let mut val = name.clone();
|
||||
if !generics.params.is_empty() {
|
||||
val.push_str(&generic_params_to_string(generics.params));
|
||||
|
@ -642,13 +642,13 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
val.push_str(&bounds_to_string(trait_refs));
|
||||
}
|
||||
if !self.span.filter_generated(item.ident.span) {
|
||||
let id = id_from_def_id(item.def_id.to_def_id());
|
||||
let id = id_from_def_id(item.owner_id.to_def_id());
|
||||
let span = self.span_from_span(item.ident.span);
|
||||
let children =
|
||||
methods.iter().map(|i| id_from_def_id(i.id.def_id.to_def_id())).collect();
|
||||
methods.iter().map(|i| id_from_def_id(i.id.owner_id.to_def_id())).collect();
|
||||
let attrs = self.tcx.hir().attrs(item.hir_id());
|
||||
self.dumper.dump_def(
|
||||
&access_from!(self.save_ctxt, item.def_id.def_id),
|
||||
&access_from!(self.save_ctxt, item.owner_id.def_id),
|
||||
Def {
|
||||
kind: DefKind::Trait,
|
||||
id,
|
||||
|
@ -692,7 +692,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
kind: RelationKind::SuperTrait,
|
||||
span,
|
||||
from: id_from_def_id(id),
|
||||
to: id_from_def_id(item.def_id.to_def_id()),
|
||||
to: id_from_def_id(item.owner_id.to_def_id()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
self.process_generic_params(generics, &qualname, item.hir_id());
|
||||
for method in methods {
|
||||
let map = self.tcx.hir();
|
||||
self.process_trait_item(map.trait_item(method.id), item.def_id.to_def_id())
|
||||
self.process_trait_item(map.trait_item(method.id), item.owner_id.to_def_id())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -710,7 +710,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
fn process_mod(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
if let Some(mod_data) = self.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(mod_data, DefData, item.span);
|
||||
self.dumper.dump_def(&access_from!(self.save_ctxt, item.def_id.def_id), mod_data);
|
||||
self.dumper.dump_def(&access_from!(self.save_ctxt, item.owner_id.def_id), mod_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -981,7 +981,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
let body = body.map(|b| self.tcx.hir().body(b).value);
|
||||
let attrs = self.tcx.hir().attrs(trait_item.hir_id());
|
||||
self.process_assoc_const(
|
||||
trait_item.def_id.def_id,
|
||||
trait_item.owner_id.def_id,
|
||||
trait_item.ident,
|
||||
&ty,
|
||||
body,
|
||||
|
@ -995,7 +995,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
self.process_method(
|
||||
sig,
|
||||
body,
|
||||
trait_item.def_id.def_id,
|
||||
trait_item.owner_id.def_id,
|
||||
trait_item.ident,
|
||||
&trait_item.generics,
|
||||
trait_item.span,
|
||||
|
@ -1005,11 +1005,11 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
// FIXME do something with _bounds (for type refs)
|
||||
let name = trait_item.ident.name.to_string();
|
||||
let qualname =
|
||||
format!("::{}", self.tcx.def_path_str(trait_item.def_id.to_def_id()));
|
||||
format!("::{}", self.tcx.def_path_str(trait_item.owner_id.to_def_id()));
|
||||
|
||||
if !self.span.filter_generated(trait_item.ident.span) {
|
||||
let span = self.span_from_span(trait_item.ident.span);
|
||||
let id = id_from_def_id(trait_item.def_id.to_def_id());
|
||||
let id = id_from_def_id(trait_item.owner_id.to_def_id());
|
||||
let attrs = self.tcx.hir().attrs(trait_item.hir_id());
|
||||
|
||||
self.dumper.dump_def(
|
||||
|
@ -1051,7 +1051,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
let body = self.tcx.hir().body(body);
|
||||
let attrs = self.tcx.hir().attrs(impl_item.hir_id());
|
||||
self.process_assoc_const(
|
||||
impl_item.def_id.def_id,
|
||||
impl_item.owner_id.def_id,
|
||||
impl_item.ident,
|
||||
&ty,
|
||||
Some(&body.value),
|
||||
|
@ -1063,7 +1063,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
self.process_method(
|
||||
sig,
|
||||
Some(body),
|
||||
impl_item.def_id.def_id,
|
||||
impl_item.owner_id.def_id,
|
||||
impl_item.ident,
|
||||
&impl_item.generics,
|
||||
impl_item.span,
|
||||
|
@ -1088,7 +1088,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
let filename = sm.span_to_filename(krate_mod.spans.inner_span);
|
||||
let data_id = id_from_hir_id(id, &self.save_ctxt);
|
||||
let children =
|
||||
krate_mod.item_ids.iter().map(|i| id_from_def_id(i.def_id.to_def_id())).collect();
|
||||
krate_mod.item_ids.iter().map(|i| id_from_def_id(i.owner_id.to_def_id())).collect();
|
||||
let span = self.span_from_span(krate_mod.spans.inner_span);
|
||||
let attrs = self.tcx.hir().attrs(id);
|
||||
|
||||
|
@ -1137,10 +1137,10 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
hir::ItemKind::Use(path, hir::UseKind::Single) => {
|
||||
let sub_span = path.segments.last().unwrap().ident.span;
|
||||
if !self.span.filter_generated(sub_span) {
|
||||
let access = access_from!(self.save_ctxt, item.def_id.def_id);
|
||||
let access = access_from!(self.save_ctxt, item.owner_id.def_id);
|
||||
let ref_id = self.lookup_def_id(item.hir_id()).map(id_from_def_id);
|
||||
let span = self.span_from_span(sub_span);
|
||||
let parent = self.save_ctxt.tcx.local_parent(item.def_id.def_id);
|
||||
let parent = self.save_ctxt.tcx.local_parent(item.owner_id.def_id);
|
||||
self.dumper.import(
|
||||
&access,
|
||||
Import {
|
||||
|
@ -1158,16 +1158,16 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
}
|
||||
hir::ItemKind::Use(path, hir::UseKind::Glob) => {
|
||||
// Make a comma-separated list of names of imported modules.
|
||||
let names = self.tcx.names_imported_by_glob_use(item.def_id.def_id);
|
||||
let names = self.tcx.names_imported_by_glob_use(item.owner_id.def_id);
|
||||
let names: Vec<_> = names.iter().map(|n| n.to_string()).collect();
|
||||
|
||||
// Otherwise it's a span with wrong macro expansion info, which
|
||||
// we don't want to track anyway, since it's probably macro-internal `use`
|
||||
if let Some(sub_span) = self.span.sub_span_of_star(item.span) {
|
||||
if !self.span.filter_generated(item.span) {
|
||||
let access = access_from!(self.save_ctxt, item.def_id.def_id);
|
||||
let access = access_from!(self.save_ctxt, item.owner_id.def_id);
|
||||
let span = self.span_from_span(sub_span);
|
||||
let parent = self.save_ctxt.tcx.local_parent(item.def_id.def_id);
|
||||
let parent = self.save_ctxt.tcx.local_parent(item.owner_id.def_id);
|
||||
self.dumper.import(
|
||||
&access,
|
||||
Import {
|
||||
|
@ -1188,7 +1188,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'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.local_parent(item.def_id.def_id);
|
||||
let parent = self.save_ctxt.tcx.local_parent(item.owner_id.def_id);
|
||||
self.dumper.import(
|
||||
&Access { public: false, reachable: false },
|
||||
Import {
|
||||
|
@ -1228,15 +1228,15 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
intravisit::walk_mod(self, m, item.hir_id());
|
||||
}
|
||||
hir::ItemKind::TyAlias(ty, ref generics) => {
|
||||
let qualname = format!("::{}", self.tcx.def_path_str(item.def_id.to_def_id()));
|
||||
let qualname = format!("::{}", self.tcx.def_path_str(item.owner_id.to_def_id()));
|
||||
let value = ty_to_string(&ty);
|
||||
if !self.span.filter_generated(item.ident.span) {
|
||||
let span = self.span_from_span(item.ident.span);
|
||||
let id = id_from_def_id(item.def_id.to_def_id());
|
||||
let id = id_from_def_id(item.owner_id.to_def_id());
|
||||
let attrs = self.tcx.hir().attrs(item.hir_id());
|
||||
|
||||
self.dumper.dump_def(
|
||||
&access_from!(self.save_ctxt, item.def_id.def_id),
|
||||
&access_from!(self.save_ctxt, item.owner_id.def_id),
|
||||
Def {
|
||||
kind: DefKind::Type,
|
||||
id,
|
||||
|
@ -1324,7 +1324,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
}
|
||||
hir::TyKind::OpaqueDef(item_id, _, _) => {
|
||||
let item = self.tcx.hir().item(item_id);
|
||||
self.nest_typeck_results(item_id.def_id.def_id, |v| v.visit_item(item));
|
||||
self.nest_typeck_results(item_id.owner_id.def_id, |v| v.visit_item(item));
|
||||
}
|
||||
_ => intravisit::walk_ty(self, t),
|
||||
}
|
||||
|
@ -1431,7 +1431,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
|
||||
let access = access_from!(self.save_ctxt, item.def_id.def_id);
|
||||
let access = access_from!(self.save_ctxt, item.owner_id.def_id);
|
||||
|
||||
match item.kind {
|
||||
hir::ForeignItemKind::Fn(decl, _, ref generics) => {
|
||||
|
|
|
@ -141,7 +141,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn get_extern_item_data(&self, item: &hir::ForeignItem<'_>) -> Option<Data> {
|
||||
let def_id = item.def_id.to_def_id();
|
||||
let def_id = item.owner_id.to_def_id();
|
||||
let qualname = format!("::{}", self.tcx.def_path_str(def_id));
|
||||
let attrs = self.tcx.hir().attrs(item.hir_id());
|
||||
match item.kind {
|
||||
|
@ -205,7 +205,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
|
||||
let def_id = item.def_id.to_def_id();
|
||||
let def_id = item.owner_id.to_def_id();
|
||||
let attrs = self.tcx.hir().attrs(item.hir_id());
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(ref sig, ref generics, _) => {
|
||||
|
@ -297,7 +297,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
children: m
|
||||
.item_ids
|
||||
.iter()
|
||||
.map(|i| id_from_def_id(i.def_id.to_def_id()))
|
||||
.map(|i| id_from_def_id(i.owner_id.to_def_id()))
|
||||
.collect(),
|
||||
decl_id: None,
|
||||
docs: self.docs_for_attrs(attrs),
|
||||
|
@ -363,7 +363,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
parent: None,
|
||||
children: items
|
||||
.iter()
|
||||
.map(|i| id_from_def_id(i.id.def_id.to_def_id()))
|
||||
.map(|i| id_from_def_id(i.id.owner_id.to_def_id()))
|
||||
.collect(),
|
||||
docs: String::new(),
|
||||
sig: None,
|
||||
|
|
|
@ -337,7 +337,7 @@ impl<'hir> Sig for hir::Item<'hir> {
|
|||
}
|
||||
let name = self.ident.to_string();
|
||||
let defs = vec![SigElement {
|
||||
id: id_from_def_id(self.def_id.to_def_id()),
|
||||
id: id_from_def_id(self.owner_id.to_def_id()),
|
||||
start: offset + text.len(),
|
||||
end: offset + text.len() + name.len(),
|
||||
}];
|
||||
|
@ -359,7 +359,7 @@ impl<'hir> Sig for hir::Item<'hir> {
|
|||
let mut text = "const ".to_owned();
|
||||
let name = self.ident.to_string();
|
||||
let defs = vec![SigElement {
|
||||
id: id_from_def_id(self.def_id.to_def_id()),
|
||||
id: id_from_def_id(self.owner_id.to_def_id()),
|
||||
start: offset + text.len(),
|
||||
end: offset + text.len() + name.len(),
|
||||
}];
|
||||
|
@ -428,7 +428,7 @@ impl<'hir> Sig for hir::Item<'hir> {
|
|||
let mut text = "mod ".to_owned();
|
||||
let name = self.ident.to_string();
|
||||
let defs = vec![SigElement {
|
||||
id: id_from_def_id(self.def_id.to_def_id()),
|
||||
id: id_from_def_id(self.owner_id.to_def_id()),
|
||||
start: offset + text.len(),
|
||||
end: offset + text.len() + name.len(),
|
||||
}];
|
||||
|
@ -764,7 +764,7 @@ impl<'hir> Sig for hir::ForeignItem<'hir> {
|
|||
}
|
||||
let name = self.ident.to_string();
|
||||
let defs = vec![SigElement {
|
||||
id: id_from_def_id(self.def_id.to_def_id()),
|
||||
id: id_from_def_id(self.owner_id.to_def_id()),
|
||||
start: offset + text.len(),
|
||||
end: offset + text.len() + name.len(),
|
||||
}];
|
||||
|
@ -780,7 +780,7 @@ impl<'hir> Sig for hir::ForeignItem<'hir> {
|
|||
let mut text = "type ".to_owned();
|
||||
let name = self.ident.to_string();
|
||||
let defs = vec![SigElement {
|
||||
id: id_from_def_id(self.def_id.to_def_id()),
|
||||
id: id_from_def_id(self.owner_id.to_def_id()),
|
||||
start: offset + text.len(),
|
||||
end: offset + text.len() + name.len(),
|
||||
}];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue