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
|
@ -2207,14 +2207,14 @@ pub struct FnSig<'hir> {
|
|||
// so it can fetched later.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
|
||||
pub struct TraitItemId {
|
||||
pub def_id: OwnerId,
|
||||
pub owner_id: OwnerId,
|
||||
}
|
||||
|
||||
impl TraitItemId {
|
||||
#[inline]
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id.def_id)
|
||||
HirId::make_owner(self.owner_id.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2225,7 +2225,7 @@ impl TraitItemId {
|
|||
#[derive(Debug, HashStable_Generic)]
|
||||
pub struct TraitItem<'hir> {
|
||||
pub ident: Ident,
|
||||
pub def_id: OwnerId,
|
||||
pub owner_id: OwnerId,
|
||||
pub generics: &'hir Generics<'hir>,
|
||||
pub kind: TraitItemKind<'hir>,
|
||||
pub span: Span,
|
||||
|
@ -2236,11 +2236,11 @@ impl TraitItem<'_> {
|
|||
#[inline]
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id.def_id)
|
||||
HirId::make_owner(self.owner_id.def_id)
|
||||
}
|
||||
|
||||
pub fn trait_item_id(&self) -> TraitItemId {
|
||||
TraitItemId { def_id: self.def_id }
|
||||
TraitItemId { owner_id: self.owner_id }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2271,14 +2271,14 @@ pub enum TraitItemKind<'hir> {
|
|||
// so it can fetched later.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
|
||||
pub struct ImplItemId {
|
||||
pub def_id: OwnerId,
|
||||
pub owner_id: OwnerId,
|
||||
}
|
||||
|
||||
impl ImplItemId {
|
||||
#[inline]
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id.def_id)
|
||||
HirId::make_owner(self.owner_id.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2286,7 +2286,7 @@ impl ImplItemId {
|
|||
#[derive(Debug, HashStable_Generic)]
|
||||
pub struct ImplItem<'hir> {
|
||||
pub ident: Ident,
|
||||
pub def_id: OwnerId,
|
||||
pub owner_id: OwnerId,
|
||||
pub generics: &'hir Generics<'hir>,
|
||||
pub kind: ImplItemKind<'hir>,
|
||||
pub defaultness: Defaultness,
|
||||
|
@ -2298,11 +2298,11 @@ impl ImplItem<'_> {
|
|||
#[inline]
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id.def_id)
|
||||
HirId::make_owner(self.owner_id.def_id)
|
||||
}
|
||||
|
||||
pub fn impl_item_id(&self) -> ImplItemId {
|
||||
ImplItemId { def_id: self.def_id }
|
||||
ImplItemId { owner_id: self.owner_id }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2914,14 +2914,14 @@ impl<'hir> VariantData<'hir> {
|
|||
// so it can fetched later.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash, HashStable_Generic)]
|
||||
pub struct ItemId {
|
||||
pub def_id: OwnerId,
|
||||
pub owner_id: OwnerId,
|
||||
}
|
||||
|
||||
impl ItemId {
|
||||
#[inline]
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id.def_id)
|
||||
HirId::make_owner(self.owner_id.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2931,7 +2931,7 @@ impl ItemId {
|
|||
#[derive(Debug, HashStable_Generic)]
|
||||
pub struct Item<'hir> {
|
||||
pub ident: Ident,
|
||||
pub def_id: OwnerId,
|
||||
pub owner_id: OwnerId,
|
||||
pub kind: ItemKind<'hir>,
|
||||
pub span: Span,
|
||||
pub vis_span: Span,
|
||||
|
@ -2941,11 +2941,11 @@ impl Item<'_> {
|
|||
#[inline]
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id.def_id)
|
||||
HirId::make_owner(self.owner_id.def_id)
|
||||
}
|
||||
|
||||
pub fn item_id(&self) -> ItemId {
|
||||
ItemId { def_id: self.def_id }
|
||||
ItemId { owner_id: self.owner_id }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3158,14 +3158,14 @@ pub enum AssocItemKind {
|
|||
// so it can fetched later.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
|
||||
pub struct ForeignItemId {
|
||||
pub def_id: OwnerId,
|
||||
pub owner_id: OwnerId,
|
||||
}
|
||||
|
||||
impl ForeignItemId {
|
||||
#[inline]
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id.def_id)
|
||||
HirId::make_owner(self.owner_id.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3186,7 +3186,7 @@ pub struct ForeignItemRef {
|
|||
pub struct ForeignItem<'hir> {
|
||||
pub ident: Ident,
|
||||
pub kind: ForeignItemKind<'hir>,
|
||||
pub def_id: OwnerId,
|
||||
pub owner_id: OwnerId,
|
||||
pub span: Span,
|
||||
pub vis_span: Span,
|
||||
}
|
||||
|
@ -3195,11 +3195,11 @@ impl ForeignItem<'_> {
|
|||
#[inline]
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id.def_id)
|
||||
HirId::make_owner(self.owner_id.def_id)
|
||||
}
|
||||
|
||||
pub fn foreign_item_id(&self) -> ForeignItemId {
|
||||
ForeignItemId { def_id: self.def_id }
|
||||
ForeignItemId { owner_id: self.owner_id }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3291,10 +3291,10 @@ impl<'hir> OwnerNode<'hir> {
|
|||
|
||||
pub fn def_id(self) -> OwnerId {
|
||||
match self {
|
||||
OwnerNode::Item(Item { def_id, .. })
|
||||
| OwnerNode::TraitItem(TraitItem { def_id, .. })
|
||||
| OwnerNode::ImplItem(ImplItem { def_id, .. })
|
||||
| OwnerNode::ForeignItem(ForeignItem { def_id, .. }) => *def_id,
|
||||
OwnerNode::Item(Item { owner_id, .. })
|
||||
| OwnerNode::TraitItem(TraitItem { owner_id, .. })
|
||||
| OwnerNode::ImplItem(ImplItem { owner_id, .. })
|
||||
| OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
|
||||
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -912,7 +912,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(
|
|||
|
||||
pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem<'v>) {
|
||||
// N.B., deliberately force a compilation error if/when new fields are added.
|
||||
let TraitItem { ident, generics, ref defaultness, ref kind, span, def_id: _ } = *trait_item;
|
||||
let TraitItem { ident, generics, ref defaultness, ref kind, span, owner_id: _ } = *trait_item;
|
||||
let hir_id = trait_item.hir_id();
|
||||
visitor.visit_ident(ident);
|
||||
visitor.visit_generics(&generics);
|
||||
|
@ -952,7 +952,7 @@ pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref:
|
|||
pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem<'v>) {
|
||||
// N.B., deliberately force a compilation error if/when new fields are added.
|
||||
let ImplItem {
|
||||
def_id: _,
|
||||
owner_id: _,
|
||||
ident,
|
||||
ref generics,
|
||||
ref kind,
|
||||
|
|
|
@ -49,7 +49,7 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ItemId {
|
|||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash {
|
||||
self.def_id.def_id.to_stable_hash_key(hcx)
|
||||
self.owner_id.def_id.to_stable_hash_key(hcx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for TraitItemId {
|
|||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash {
|
||||
self.def_id.def_id.to_stable_hash_key(hcx)
|
||||
self.owner_id.def_id.to_stable_hash_key(hcx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ImplItemId {
|
|||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash {
|
||||
self.def_id.def_id.to_stable_hash_key(hcx)
|
||||
self.owner_id.def_id.to_stable_hash_key(hcx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ForeignItemId
|
|||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash {
|
||||
self.def_id.def_id.to_stable_hash_key(hcx)
|
||||
self.owner_id.def_id.to_stable_hash_key(hcx)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue