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
|
@ -1192,7 +1192,7 @@ struct RootCollector<'a, 'tcx> {
|
|||
|
||||
impl<'v> RootCollector<'_, 'v> {
|
||||
fn process_item(&mut self, id: hir::ItemId) {
|
||||
match self.tcx.def_kind(id.def_id) {
|
||||
match self.tcx.def_kind(id.owner_id) {
|
||||
DefKind::Enum | DefKind::Struct | DefKind::Union => {
|
||||
let item = self.tcx.hir().item(id);
|
||||
match item.kind {
|
||||
|
@ -1203,12 +1203,14 @@ impl<'v> RootCollector<'_, 'v> {
|
|||
if self.mode == MonoItemCollectionMode::Eager {
|
||||
debug!(
|
||||
"RootCollector: ADT drop-glue for {}",
|
||||
self.tcx.def_path_str(item.def_id.to_def_id())
|
||||
self.tcx.def_path_str(item.owner_id.to_def_id())
|
||||
);
|
||||
|
||||
let ty =
|
||||
Instance::new(item.def_id.to_def_id(), InternalSubsts::empty())
|
||||
.ty(self.tcx, ty::ParamEnv::reveal_all());
|
||||
let ty = Instance::new(
|
||||
item.owner_id.to_def_id(),
|
||||
InternalSubsts::empty(),
|
||||
)
|
||||
.ty(self.tcx, ty::ParamEnv::reveal_all());
|
||||
visit_drop_use(self.tcx, ty, true, DUMMY_SP, self.output);
|
||||
}
|
||||
}
|
||||
|
@ -1219,23 +1221,23 @@ impl<'v> RootCollector<'_, 'v> {
|
|||
DefKind::GlobalAsm => {
|
||||
debug!(
|
||||
"RootCollector: ItemKind::GlobalAsm({})",
|
||||
self.tcx.def_path_str(id.def_id.to_def_id())
|
||||
self.tcx.def_path_str(id.owner_id.to_def_id())
|
||||
);
|
||||
self.output.push(dummy_spanned(MonoItem::GlobalAsm(id)));
|
||||
}
|
||||
DefKind::Static(..) => {
|
||||
debug!(
|
||||
"RootCollector: ItemKind::Static({})",
|
||||
self.tcx.def_path_str(id.def_id.to_def_id())
|
||||
self.tcx.def_path_str(id.owner_id.to_def_id())
|
||||
);
|
||||
self.output.push(dummy_spanned(MonoItem::Static(id.def_id.to_def_id())));
|
||||
self.output.push(dummy_spanned(MonoItem::Static(id.owner_id.to_def_id())));
|
||||
}
|
||||
DefKind::Const => {
|
||||
// const items only generate mono items if they are
|
||||
// actually used somewhere. Just declaring them is insufficient.
|
||||
|
||||
// but even just declaring them must collect the items they refer to
|
||||
if let Ok(val) = self.tcx.const_eval_poly(id.def_id.to_def_id()) {
|
||||
if let Ok(val) = self.tcx.const_eval_poly(id.owner_id.to_def_id()) {
|
||||
collect_const_value(self.tcx, val, &mut self.output);
|
||||
}
|
||||
}
|
||||
|
@ -1246,15 +1248,15 @@ impl<'v> RootCollector<'_, 'v> {
|
|||
}
|
||||
}
|
||||
DefKind::Fn => {
|
||||
self.push_if_root(id.def_id.def_id);
|
||||
self.push_if_root(id.owner_id.def_id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn process_impl_item(&mut self, id: hir::ImplItemId) {
|
||||
if matches!(self.tcx.def_kind(id.def_id), DefKind::AssocFn) {
|
||||
self.push_if_root(id.def_id.def_id);
|
||||
if matches!(self.tcx.def_kind(id.owner_id), DefKind::AssocFn) {
|
||||
self.push_if_root(id.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1352,13 +1354,13 @@ fn create_mono_items_for_default_impls<'tcx>(
|
|||
|
||||
debug!(
|
||||
"create_mono_items_for_default_impls(item={})",
|
||||
tcx.def_path_str(item.def_id.to_def_id())
|
||||
tcx.def_path_str(item.owner_id.to_def_id())
|
||||
);
|
||||
|
||||
if let Some(trait_ref) = tcx.impl_trait_ref(item.def_id) {
|
||||
if let Some(trait_ref) = tcx.impl_trait_ref(item.owner_id) {
|
||||
let param_env = ty::ParamEnv::reveal_all();
|
||||
let trait_ref = tcx.normalize_erasing_regions(param_env, trait_ref);
|
||||
let overridden_methods = tcx.impl_item_implementor_ids(item.def_id);
|
||||
let overridden_methods = tcx.impl_item_implementor_ids(item.owner_id);
|
||||
for method in tcx.provided_trait_methods(trait_ref.def_id) {
|
||||
if overridden_methods.contains_key(&method.def_id) {
|
||||
continue;
|
||||
|
|
|
@ -319,7 +319,7 @@ fn characteristic_def_id_of_mono_item<'tcx>(
|
|||
Some(def_id)
|
||||
}
|
||||
MonoItem::Static(def_id) => Some(def_id),
|
||||
MonoItem::GlobalAsm(item_id) => Some(item_id.def_id.to_def_id()),
|
||||
MonoItem::GlobalAsm(item_id) => Some(item_id.owner_id.to_def_id()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -411,9 +411,9 @@ fn mono_item_visibility<'tcx>(
|
|||
};
|
||||
}
|
||||
MonoItem::GlobalAsm(item_id) => {
|
||||
return if tcx.is_reachable_non_generic(item_id.def_id) {
|
||||
return if tcx.is_reachable_non_generic(item_id.owner_id) {
|
||||
*can_be_internalized = false;
|
||||
default_visibility(tcx, item_id.def_id.to_def_id(), false)
|
||||
default_visibility(tcx, item_id.owner_id.to_def_id(), false)
|
||||
} else {
|
||||
Visibility::Hidden
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue