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
|
@ -177,7 +177,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxPointers {
|
|||
| hir::ItemKind::Enum(..)
|
||||
| hir::ItemKind::Struct(..)
|
||||
| hir::ItemKind::Union(..) => {
|
||||
self.check_heap_type(cx, it.span, cx.tcx.type_of(it.def_id))
|
||||
self.check_heap_type(cx, it.span, cx.tcx.type_of(it.owner_id))
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -606,9 +606,9 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
|||
match it.kind {
|
||||
hir::ItemKind::Trait(..) => {
|
||||
// Issue #11592: traits are always considered exported, even when private.
|
||||
if cx.tcx.visibility(it.def_id)
|
||||
if cx.tcx.visibility(it.owner_id)
|
||||
== ty::Visibility::Restricted(
|
||||
cx.tcx.parent_module_from_def_id(it.def_id.def_id).to_def_id(),
|
||||
cx.tcx.parent_module_from_def_id(it.owner_id.def_id).to_def_id(),
|
||||
)
|
||||
{
|
||||
return;
|
||||
|
@ -627,15 +627,15 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
|||
_ => return,
|
||||
};
|
||||
|
||||
let (article, desc) = cx.tcx.article_and_description(it.def_id.to_def_id());
|
||||
let (article, desc) = cx.tcx.article_and_description(it.owner_id.to_def_id());
|
||||
|
||||
self.check_missing_docs_attrs(cx, it.def_id.def_id, article, desc);
|
||||
self.check_missing_docs_attrs(cx, it.owner_id.def_id, article, desc);
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_>, trait_item: &hir::TraitItem<'_>) {
|
||||
let (article, desc) = cx.tcx.article_and_description(trait_item.def_id.to_def_id());
|
||||
let (article, desc) = cx.tcx.article_and_description(trait_item.owner_id.to_def_id());
|
||||
|
||||
self.check_missing_docs_attrs(cx, trait_item.def_id.def_id, article, desc);
|
||||
self.check_missing_docs_attrs(cx, trait_item.owner_id.def_id, article, desc);
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &hir::ImplItem<'_>) {
|
||||
|
@ -662,13 +662,13 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
|||
}
|
||||
}
|
||||
|
||||
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
|
||||
self.check_missing_docs_attrs(cx, impl_item.def_id.def_id, article, desc);
|
||||
let (article, desc) = cx.tcx.article_and_description(impl_item.owner_id.to_def_id());
|
||||
self.check_missing_docs_attrs(cx, impl_item.owner_id.def_id, article, desc);
|
||||
}
|
||||
|
||||
fn check_foreign_item(&mut self, cx: &LateContext<'_>, foreign_item: &hir::ForeignItem<'_>) {
|
||||
let (article, desc) = cx.tcx.article_and_description(foreign_item.def_id.to_def_id());
|
||||
self.check_missing_docs_attrs(cx, foreign_item.def_id.def_id, article, desc);
|
||||
let (article, desc) = cx.tcx.article_and_description(foreign_item.owner_id.to_def_id());
|
||||
self.check_missing_docs_attrs(cx, foreign_item.owner_id.def_id, article, desc);
|
||||
}
|
||||
|
||||
fn check_field_def(&mut self, cx: &LateContext<'_>, sf: &hir::FieldDef<'_>) {
|
||||
|
@ -721,7 +721,7 @@ declare_lint_pass!(MissingCopyImplementations => [MISSING_COPY_IMPLEMENTATIONS])
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
if !cx.effective_visibilities.is_reachable(item.def_id.def_id) {
|
||||
if !cx.effective_visibilities.is_reachable(item.owner_id.def_id) {
|
||||
return;
|
||||
}
|
||||
let (def, ty) = match item.kind {
|
||||
|
@ -729,21 +729,21 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
|
|||
if !ast_generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(item.def_id);
|
||||
let def = cx.tcx.adt_def(item.owner_id);
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
hir::ItemKind::Union(_, ref ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(item.def_id);
|
||||
let def = cx.tcx.adt_def(item.owner_id);
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
hir::ItemKind::Enum(_, ref ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(item.def_id);
|
||||
let def = cx.tcx.adt_def(item.owner_id);
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
_ => return,
|
||||
|
@ -814,7 +814,7 @@ impl_lint_pass!(MissingDebugImplementations => [MISSING_DEBUG_IMPLEMENTATIONS]);
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
if !cx.effective_visibilities.is_reachable(item.def_id.def_id) {
|
||||
if !cx.effective_visibilities.is_reachable(item.owner_id.def_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -841,7 +841,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
|
|||
debug!("{:?}", self.impling_types);
|
||||
}
|
||||
|
||||
if !self.impling_types.as_ref().unwrap().contains(&item.def_id.def_id) {
|
||||
if !self.impling_types.as_ref().unwrap().contains(&item.owner_id.def_id) {
|
||||
cx.struct_span_lint(
|
||||
MISSING_DEBUG_IMPLEMENTATIONS,
|
||||
item.span,
|
||||
|
@ -1226,7 +1226,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||
check_no_mangle_on_generic_fn(
|
||||
no_mangle_attr,
|
||||
Some(generics),
|
||||
cx.tcx.hir().get_generics(it.id.def_id.def_id).unwrap(),
|
||||
cx.tcx.hir().get_generics(it.id.owner_id.def_id).unwrap(),
|
||||
it.span,
|
||||
);
|
||||
}
|
||||
|
@ -1415,11 +1415,11 @@ impl<'tcx> LateLintPass<'tcx> for UnreachablePub {
|
|||
if let hir::ItemKind::Use(_, hir::UseKind::ListStem) = &item.kind {
|
||||
return;
|
||||
}
|
||||
self.perform_lint(cx, "item", item.def_id.def_id, item.vis_span, true);
|
||||
self.perform_lint(cx, "item", item.owner_id.def_id, item.vis_span, true);
|
||||
}
|
||||
|
||||
fn check_foreign_item(&mut self, cx: &LateContext<'_>, foreign_item: &hir::ForeignItem<'tcx>) {
|
||||
self.perform_lint(cx, "item", foreign_item.def_id.def_id, foreign_item.vis_span, true);
|
||||
self.perform_lint(cx, "item", foreign_item.owner_id.def_id, foreign_item.vis_span, true);
|
||||
}
|
||||
|
||||
fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) {
|
||||
|
@ -1429,8 +1429,8 @@ impl<'tcx> LateLintPass<'tcx> for UnreachablePub {
|
|||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &hir::ImplItem<'_>) {
|
||||
// Only lint inherent impl items.
|
||||
if cx.tcx.associated_item(impl_item.def_id).trait_item_def_id.is_none() {
|
||||
self.perform_lint(cx, "item", impl_item.def_id.def_id, impl_item.vis_span, false);
|
||||
if cx.tcx.associated_item(impl_item.owner_id).trait_item_def_id.is_none() {
|
||||
self.perform_lint(cx, "item", impl_item.owner_id.def_id, impl_item.vis_span, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1639,7 +1639,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
|
|||
use rustc_middle::ty::PredicateKind::*;
|
||||
|
||||
if cx.tcx.features().trivial_bounds {
|
||||
let predicates = cx.tcx.predicates_of(item.def_id);
|
||||
let predicates = cx.tcx.predicates_of(item.owner_id);
|
||||
for &(predicate, span) in predicates.predicates {
|
||||
let predicate_kind_name = match predicate.kind().skip_binder() {
|
||||
Trait(..) => "trait",
|
||||
|
@ -1882,7 +1882,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnameableTestItems {
|
|||
if let hir::ItemKind::Mod(..) = it.kind {
|
||||
} else {
|
||||
self.items_nameable = false;
|
||||
self.boundary = Some(it.def_id);
|
||||
self.boundary = Some(it.owner_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1899,7 +1899,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnameableTestItems {
|
|||
}
|
||||
|
||||
fn check_item_post(&mut self, _cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
if !self.items_nameable && self.boundary == Some(it.def_id) {
|
||||
if !self.items_nameable && self.boundary == Some(it.owner_id) {
|
||||
self.items_nameable = true;
|
||||
}
|
||||
}
|
||||
|
@ -2165,7 +2165,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
|||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
|
||||
use rustc_middle::middle::resolve_lifetime::Region;
|
||||
|
||||
let def_id = item.def_id.def_id;
|
||||
let def_id = item.owner_id.def_id;
|
||||
if let hir::ItemKind::Struct(_, ref hir_generics)
|
||||
| hir::ItemKind::Enum(_, ref hir_generics)
|
||||
| hir::ItemKind::Union(_, ref hir_generics) = item.kind
|
||||
|
@ -2744,7 +2744,7 @@ impl ClashingExternDeclarations {
|
|||
/// Insert a new foreign item into the seen set. If a symbol with the same name already exists
|
||||
/// for the item, return its HirId without updating the set.
|
||||
fn insert(&mut self, tcx: TyCtxt<'_>, fi: &hir::ForeignItem<'_>) -> Option<HirId> {
|
||||
let did = fi.def_id.to_def_id();
|
||||
let did = fi.owner_id.to_def_id();
|
||||
let instance = Instance::new(did, ty::List::identity_for_item(tcx, did));
|
||||
let name = Symbol::intern(tcx.symbol_name(instance).name);
|
||||
if let Some(&hir_id) = self.seen_decls.get(&name) {
|
||||
|
@ -2762,14 +2762,14 @@ impl ClashingExternDeclarations {
|
|||
/// symbol's name.
|
||||
fn name_of_extern_decl(tcx: TyCtxt<'_>, fi: &hir::ForeignItem<'_>) -> SymbolName {
|
||||
if let Some((overridden_link_name, overridden_link_name_span)) =
|
||||
tcx.codegen_fn_attrs(fi.def_id).link_name.map(|overridden_link_name| {
|
||||
tcx.codegen_fn_attrs(fi.owner_id).link_name.map(|overridden_link_name| {
|
||||
// FIXME: Instead of searching through the attributes again to get span
|
||||
// information, we could have codegen_fn_attrs also give span information back for
|
||||
// where the attribute was defined. However, until this is found to be a
|
||||
// bottleneck, this does just fine.
|
||||
(
|
||||
overridden_link_name,
|
||||
tcx.get_attr(fi.def_id.to_def_id(), sym::link_name).unwrap().span,
|
||||
tcx.get_attr(fi.owner_id.to_def_id(), sym::link_name).unwrap().span,
|
||||
)
|
||||
})
|
||||
{
|
||||
|
@ -2986,10 +2986,10 @@ impl<'tcx> LateLintPass<'tcx> for ClashingExternDeclarations {
|
|||
let tcx = cx.tcx;
|
||||
if let Some(existing_hid) = self.insert(tcx, this_fi) {
|
||||
let existing_decl_ty = tcx.type_of(tcx.hir().local_def_id(existing_hid));
|
||||
let this_decl_ty = tcx.type_of(this_fi.def_id);
|
||||
let this_decl_ty = tcx.type_of(this_fi.owner_id);
|
||||
debug!(
|
||||
"ClashingExternDeclarations: Comparing existing {:?}: {:?} to this {:?}: {:?}",
|
||||
existing_hid, existing_decl_ty, this_fi.def_id, this_decl_ty
|
||||
existing_hid, existing_decl_ty, this_fi.owner_id, this_decl_ty
|
||||
);
|
||||
// Check that the declarations match.
|
||||
if !Self::structurally_same_type(
|
||||
|
|
|
@ -61,7 +61,7 @@ declare_lint_pass!(OpaqueHiddenInferredBound => [OPAQUE_HIDDEN_INFERRED_BOUND]);
|
|||
impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
let hir::ItemKind::OpaqueTy(_) = &item.kind else { return; };
|
||||
let def_id = item.def_id.def_id.to_def_id();
|
||||
let def_id = item.owner_id.def_id.to_def_id();
|
||||
let infcx = &cx.tcx.infer_ctxt().build();
|
||||
// For every projection predicate in the opaque type's explicit bounds,
|
||||
// check that the type that we're assigning actually satisfies the bounds
|
||||
|
|
|
@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
|||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
use rustc_middle::ty::PredicateKind::*;
|
||||
|
||||
let predicates = cx.tcx.explicit_predicates_of(item.def_id);
|
||||
let predicates = cx.tcx.explicit_predicates_of(item.owner_id);
|
||||
for &(predicate, span) in predicates.predicates {
|
||||
let Trait(trait_predicate) = predicate.kind().skip_binder() else {
|
||||
continue
|
||||
|
|
|
@ -1360,7 +1360,7 @@ declare_lint_pass!(VariantSizeDifferences => [VARIANT_SIZE_DIFFERENCES]);
|
|||
impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
if let hir::ItemKind::Enum(ref enum_definition, _) = it.kind {
|
||||
let t = cx.tcx.type_of(it.def_id);
|
||||
let t = cx.tcx.type_of(it.owner_id);
|
||||
let ty = cx.tcx.erase_regions(t);
|
||||
let Ok(layout) = cx.layout_of(ty) else { return };
|
||||
let Variants::Multiple {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue