mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
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
@ -112,19 +112,19 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
|
||||
fn visit_nested_item(&mut self, item: ItemId) {
|
||||
debug!("visit_nested_item: {:?}", item);
|
||||
self.insert_nested(item.def_id.def_id);
|
||||
self.insert_nested(item.owner_id.def_id);
|
||||
}
|
||||
|
||||
fn visit_nested_trait_item(&mut self, item_id: TraitItemId) {
|
||||
self.insert_nested(item_id.def_id.def_id);
|
||||
self.insert_nested(item_id.owner_id.def_id);
|
||||
}
|
||||
|
||||
fn visit_nested_impl_item(&mut self, item_id: ImplItemId) {
|
||||
self.insert_nested(item_id.def_id.def_id);
|
||||
self.insert_nested(item_id.owner_id.def_id);
|
||||
}
|
||||
|
||||
fn visit_nested_foreign_item(&mut self, foreign_id: ForeignItemId) {
|
||||
self.insert_nested(foreign_id.def_id.def_id);
|
||||
self.insert_nested(foreign_id.owner_id.def_id);
|
||||
}
|
||||
|
||||
fn visit_nested_body(&mut self, id: BodyId) {
|
||||
@ -143,7 +143,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn visit_item(&mut self, i: &'hir Item<'hir>) {
|
||||
debug_assert_eq!(i.def_id, self.owner);
|
||||
debug_assert_eq!(i.owner_id, self.owner);
|
||||
self.with_parent(i.hir_id(), |this| {
|
||||
if let ItemKind::Struct(ref struct_def, _) = i.kind {
|
||||
// If this is a tuple or unit-like struct, register the constructor.
|
||||
@ -157,7 +157,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn visit_foreign_item(&mut self, fi: &'hir ForeignItem<'hir>) {
|
||||
debug_assert_eq!(fi.def_id, self.owner);
|
||||
debug_assert_eq!(fi.owner_id, self.owner);
|
||||
self.with_parent(fi.hir_id(), |this| {
|
||||
intravisit::walk_foreign_item(this, fi);
|
||||
});
|
||||
@ -176,7 +176,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
|
||||
debug_assert_eq!(ti.def_id, self.owner);
|
||||
debug_assert_eq!(ti.owner_id, self.owner);
|
||||
self.with_parent(ti.hir_id(), |this| {
|
||||
intravisit::walk_trait_item(this, ti);
|
||||
});
|
||||
@ -184,7 +184,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) {
|
||||
debug_assert_eq!(ii.def_id, self.owner);
|
||||
debug_assert_eq!(ii.owner_id, self.owner);
|
||||
self.with_parent(ii.hir_id(), |this| {
|
||||
intravisit::walk_impl_item(this, ii);
|
||||
});
|
||||
|
@ -178,7 +178,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
|
||||
pub(super) fn lower_item_ref(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
|
||||
let mut node_ids =
|
||||
smallvec![hir::ItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } }];
|
||||
smallvec![hir::ItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } }];
|
||||
if let ItemKind::Use(ref use_tree) = &i.kind {
|
||||
self.lower_item_id_use_tree(use_tree, i.id, &mut node_ids);
|
||||
}
|
||||
@ -195,7 +195,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
UseTreeKind::Nested(ref nested_vec) => {
|
||||
for &(ref nested, id) in nested_vec {
|
||||
vec.push(hir::ItemId {
|
||||
def_id: hir::OwnerId { def_id: self.local_def_id(id) },
|
||||
owner_id: hir::OwnerId { def_id: self.local_def_id(id) },
|
||||
});
|
||||
self.lower_item_id_use_tree(nested, id, vec);
|
||||
}
|
||||
@ -206,7 +206,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
iter::zip(self.expect_full_res_from_use(base_id).skip(1), &[id1, id2])
|
||||
{
|
||||
vec.push(hir::ItemId {
|
||||
def_id: hir::OwnerId { def_id: self.local_def_id(id) },
|
||||
owner_id: hir::OwnerId { def_id: self.local_def_id(id) },
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -220,7 +220,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let attrs = self.lower_attrs(hir_id, &i.attrs);
|
||||
let kind = self.lower_item_kind(i.span, i.id, hir_id, &mut ident, attrs, vis_span, &i.kind);
|
||||
let item = hir::Item {
|
||||
def_id: hir_id.expect_owner(),
|
||||
owner_id: hir_id.expect_owner(),
|
||||
ident: self.lower_ident(ident),
|
||||
kind,
|
||||
vis_span,
|
||||
@ -562,7 +562,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
}
|
||||
|
||||
let item = hir::Item {
|
||||
def_id: hir::OwnerId { def_id: new_id },
|
||||
owner_id: hir::OwnerId { def_id: new_id },
|
||||
ident: this.lower_ident(ident),
|
||||
kind,
|
||||
vis_span,
|
||||
@ -640,7 +640,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
}
|
||||
|
||||
let item = hir::Item {
|
||||
def_id: hir::OwnerId { def_id: new_hir_id },
|
||||
owner_id: hir::OwnerId { def_id: new_hir_id },
|
||||
ident: this.lower_ident(ident),
|
||||
kind,
|
||||
vis_span,
|
||||
@ -660,10 +660,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
|
||||
fn lower_foreign_item(&mut self, i: &ForeignItem) -> &'hir hir::ForeignItem<'hir> {
|
||||
let hir_id = self.lower_node_id(i.id);
|
||||
let def_id = hir_id.expect_owner();
|
||||
let owner_id = hir_id.expect_owner();
|
||||
self.lower_attrs(hir_id, &i.attrs);
|
||||
let item = hir::ForeignItem {
|
||||
def_id,
|
||||
owner_id,
|
||||
ident: self.lower_ident(i.ident),
|
||||
kind: match i.kind {
|
||||
ForeignItemKind::Fn(box Fn { ref sig, ref generics, .. }) => {
|
||||
@ -702,7 +702,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
|
||||
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef {
|
||||
hir::ForeignItemRef {
|
||||
id: hir::ForeignItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
|
||||
id: hir::ForeignItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
|
||||
ident: self.lower_ident(i.ident),
|
||||
span: self.lower_span(i.span),
|
||||
}
|
||||
@ -845,7 +845,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
|
||||
self.lower_attrs(hir_id, &i.attrs);
|
||||
let item = hir::TraitItem {
|
||||
def_id: trait_item_def_id,
|
||||
owner_id: trait_item_def_id,
|
||||
ident: self.lower_ident(i.ident),
|
||||
generics,
|
||||
kind,
|
||||
@ -864,7 +864,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
}
|
||||
AssocItemKind::MacCall(..) => unimplemented!(),
|
||||
};
|
||||
let id = hir::TraitItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } };
|
||||
let id = hir::TraitItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } };
|
||||
hir::TraitItemRef {
|
||||
id,
|
||||
ident: self.lower_ident(i.ident),
|
||||
@ -931,7 +931,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let hir_id = self.lower_node_id(i.id);
|
||||
self.lower_attrs(hir_id, &i.attrs);
|
||||
let item = hir::ImplItem {
|
||||
def_id: hir_id.expect_owner(),
|
||||
owner_id: hir_id.expect_owner(),
|
||||
ident: self.lower_ident(i.ident),
|
||||
generics,
|
||||
kind,
|
||||
@ -944,7 +944,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
|
||||
fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef {
|
||||
hir::ImplItemRef {
|
||||
id: hir::ImplItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
|
||||
id: hir::ImplItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
|
||||
ident: self.lower_ident(i.ident),
|
||||
span: self.lower_span(i.span),
|
||||
kind: match &i.kind {
|
||||
|
@ -1574,7 +1574,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
|
||||
// `impl Trait` now just becomes `Foo<'a, 'b, ..>`.
|
||||
hir::TyKind::OpaqueDef(
|
||||
hir::ItemId { def_id: hir::OwnerId { def_id: opaque_ty_def_id } },
|
||||
hir::ItemId { owner_id: hir::OwnerId { def_id: opaque_ty_def_id } },
|
||||
lifetimes,
|
||||
in_trait,
|
||||
)
|
||||
@ -1593,7 +1593,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
// Generate an `type Foo = impl Trait;` declaration.
|
||||
trace!("registering opaque type with id {:#?}", opaque_ty_id);
|
||||
let opaque_ty_item = hir::Item {
|
||||
def_id: hir::OwnerId { def_id: opaque_ty_id },
|
||||
owner_id: hir::OwnerId { def_id: opaque_ty_id },
|
||||
ident: Ident::empty(),
|
||||
kind: opaque_ty_item_kind,
|
||||
vis_span: self.lower_span(span.shrink_to_lo()),
|
||||
@ -2044,7 +2044,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
// async fn, so the *type parameters* are inherited. It's
|
||||
// only the lifetime parameters that we must supply.
|
||||
let opaque_ty_ref = hir::TyKind::OpaqueDef(
|
||||
hir::ItemId { def_id: hir::OwnerId { def_id: opaque_ty_def_id } },
|
||||
hir::ItemId { owner_id: hir::OwnerId { def_id: opaque_ty_def_id } },
|
||||
generic_args,
|
||||
in_trait,
|
||||
);
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2661,7 +2661,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
}
|
||||
hir::TyKind::OpaqueDef(item_id, lifetimes, in_trait) => {
|
||||
let opaque_ty = tcx.hir().item(item_id);
|
||||
let def_id = item_id.def_id.to_def_id();
|
||||
let def_id = item_id.owner_id.to_def_id();
|
||||
|
||||
match opaque_ty.kind {
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
|
||||
|
@ -227,17 +227,17 @@ fn check_opaque<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||
return;
|
||||
}
|
||||
|
||||
let substs = InternalSubsts::identity_for_item(tcx, item.def_id.to_def_id());
|
||||
let span = tcx.def_span(item.def_id.def_id);
|
||||
let substs = InternalSubsts::identity_for_item(tcx, item.owner_id.to_def_id());
|
||||
let span = tcx.def_span(item.owner_id.def_id);
|
||||
|
||||
check_opaque_for_inheriting_lifetimes(tcx, item.def_id.def_id, span);
|
||||
if tcx.type_of(item.def_id.def_id).references_error() {
|
||||
check_opaque_for_inheriting_lifetimes(tcx, item.owner_id.def_id, span);
|
||||
if tcx.type_of(item.owner_id.def_id).references_error() {
|
||||
return;
|
||||
}
|
||||
if check_opaque_for_cycles(tcx, item.def_id.def_id, substs, span, &origin).is_err() {
|
||||
if check_opaque_for_cycles(tcx, item.owner_id.def_id, substs, span, &origin).is_err() {
|
||||
return;
|
||||
}
|
||||
check_opaque_meets_bounds(tcx, item.def_id.def_id, substs, span, &origin);
|
||||
check_opaque_meets_bounds(tcx, item.owner_id.def_id, substs, span, &origin);
|
||||
}
|
||||
/// Checks that an opaque type does not use `Self` or `T::Foo` projections that would result
|
||||
/// in "inheriting lifetimes".
|
||||
@ -492,25 +492,25 @@ fn check_opaque_meets_bounds<'tcx>(
|
||||
fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||
debug!(
|
||||
"check_item_type(it.def_id={:?}, it.name={})",
|
||||
id.def_id,
|
||||
tcx.def_path_str(id.def_id.to_def_id())
|
||||
id.owner_id,
|
||||
tcx.def_path_str(id.owner_id.to_def_id())
|
||||
);
|
||||
let _indenter = indenter();
|
||||
match tcx.def_kind(id.def_id) {
|
||||
match tcx.def_kind(id.owner_id) {
|
||||
DefKind::Static(..) => {
|
||||
tcx.ensure().typeck(id.def_id.def_id);
|
||||
maybe_check_static_with_link_section(tcx, id.def_id.def_id);
|
||||
check_static_inhabited(tcx, id.def_id.def_id);
|
||||
tcx.ensure().typeck(id.owner_id.def_id);
|
||||
maybe_check_static_with_link_section(tcx, id.owner_id.def_id);
|
||||
check_static_inhabited(tcx, id.owner_id.def_id);
|
||||
}
|
||||
DefKind::Const => {
|
||||
tcx.ensure().typeck(id.def_id.def_id);
|
||||
tcx.ensure().typeck(id.owner_id.def_id);
|
||||
}
|
||||
DefKind::Enum => {
|
||||
let item = tcx.hir().item(id);
|
||||
let hir::ItemKind::Enum(ref enum_definition, _) = item.kind else {
|
||||
return;
|
||||
};
|
||||
check_enum(tcx, &enum_definition.variants, item.def_id.def_id);
|
||||
check_enum(tcx, &enum_definition.variants, item.owner_id.def_id);
|
||||
}
|
||||
DefKind::Fn => {} // entirely within check_item_body
|
||||
DefKind::Impl => {
|
||||
@ -518,12 +518,12 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||
let hir::ItemKind::Impl(ref impl_) = it.kind else {
|
||||
return;
|
||||
};
|
||||
debug!("ItemKind::Impl {} with id {:?}", it.ident, it.def_id);
|
||||
if let Some(impl_trait_ref) = tcx.impl_trait_ref(it.def_id) {
|
||||
debug!("ItemKind::Impl {} with id {:?}", it.ident, it.owner_id);
|
||||
if let Some(impl_trait_ref) = tcx.impl_trait_ref(it.owner_id) {
|
||||
check_impl_items_against_trait(
|
||||
tcx,
|
||||
it.span,
|
||||
it.def_id.def_id,
|
||||
it.owner_id.def_id,
|
||||
impl_trait_ref,
|
||||
&impl_.items,
|
||||
);
|
||||
@ -545,15 +545,15 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||
fn_maybe_err(tcx, item.ident.span, abi);
|
||||
}
|
||||
hir::TraitItemKind::Type(.., Some(default)) => {
|
||||
let assoc_item = tcx.associated_item(item.def_id);
|
||||
let assoc_item = tcx.associated_item(item.owner_id);
|
||||
let trait_substs =
|
||||
InternalSubsts::identity_for_item(tcx, it.def_id.to_def_id());
|
||||
InternalSubsts::identity_for_item(tcx, it.owner_id.to_def_id());
|
||||
let _: Result<_, rustc_errors::ErrorGuaranteed> = check_type_bounds(
|
||||
tcx,
|
||||
assoc_item,
|
||||
assoc_item,
|
||||
default.span,
|
||||
ty::TraitRef { def_id: it.def_id.to_def_id(), substs: trait_substs },
|
||||
ty::TraitRef { def_id: it.owner_id.to_def_id(), substs: trait_substs },
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
@ -561,16 +561,16 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||
}
|
||||
}
|
||||
DefKind::Struct => {
|
||||
check_struct(tcx, id.def_id.def_id);
|
||||
check_struct(tcx, id.owner_id.def_id);
|
||||
}
|
||||
DefKind::Union => {
|
||||
check_union(tcx, id.def_id.def_id);
|
||||
check_union(tcx, id.owner_id.def_id);
|
||||
}
|
||||
DefKind::OpaqueTy => {
|
||||
check_opaque(tcx, id);
|
||||
}
|
||||
DefKind::ImplTraitPlaceholder => {
|
||||
let parent = tcx.impl_trait_in_trait_parent(id.def_id.to_def_id());
|
||||
let parent = tcx.impl_trait_in_trait_parent(id.owner_id.to_def_id());
|
||||
// Only check the validity of this opaque type if the function has a default body
|
||||
if let hir::Node::TraitItem(hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)),
|
||||
@ -581,8 +581,8 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||
}
|
||||
}
|
||||
DefKind::TyAlias => {
|
||||
let pty_ty = tcx.type_of(id.def_id);
|
||||
let generics = tcx.generics_of(id.def_id);
|
||||
let pty_ty = tcx.type_of(id.owner_id);
|
||||
let generics = tcx.generics_of(id.owner_id);
|
||||
check_type_params_are_used(tcx, &generics, pty_ty);
|
||||
}
|
||||
DefKind::ForeignMod => {
|
||||
@ -604,7 +604,7 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||
}
|
||||
} else {
|
||||
for item in items {
|
||||
let def_id = item.id.def_id.def_id;
|
||||
let def_id = item.id.owner_id.def_id;
|
||||
let generics = tcx.generics_of(def_id);
|
||||
let own_counts = generics.own_counts();
|
||||
if generics.params.len() - own_counts.lifetimes != 0 {
|
||||
@ -659,7 +659,7 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
|
||||
|
||||
pub(super) fn check_on_unimplemented(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
|
||||
// an error would be reported if this fails.
|
||||
let _ = traits::OnUnimplementedDirective::of_item(tcx, item.def_id.to_def_id());
|
||||
let _ = traits::OnUnimplementedDirective::of_item(tcx, item.owner_id.to_def_id());
|
||||
}
|
||||
|
||||
pub(super) fn check_specialization_validity<'tcx>(
|
||||
@ -746,7 +746,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||
let trait_def = tcx.trait_def(impl_trait_ref.def_id);
|
||||
|
||||
for impl_item in impl_item_refs {
|
||||
let ty_impl_item = tcx.associated_item(impl_item.id.def_id);
|
||||
let ty_impl_item = tcx.associated_item(impl_item.id.owner_id);
|
||||
let ty_trait_item = if let Some(trait_item_id) = ty_impl_item.trait_item_def_id {
|
||||
tcx.associated_item(trait_item_id)
|
||||
} else {
|
||||
@ -758,7 +758,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||
match impl_item_full.kind {
|
||||
hir::ImplItemKind::Const(..) => {
|
||||
let _ = tcx.compare_assoc_const_impl_item_with_trait_item((
|
||||
impl_item.id.def_id.def_id,
|
||||
impl_item.id.owner_id.def_id,
|
||||
ty_impl_item.trait_item_def_id.unwrap(),
|
||||
));
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ fn equate_intrinsic_type<'tcx>(
|
||||
) {
|
||||
let (own_counts, span) = match &it.kind {
|
||||
hir::ForeignItemKind::Fn(.., generics) => {
|
||||
let own_counts = tcx.generics_of(it.def_id.to_def_id()).own_counts();
|
||||
let own_counts = tcx.generics_of(it.owner_id.to_def_id()).own_counts();
|
||||
(own_counts, generics.span)
|
||||
}
|
||||
_ => {
|
||||
@ -57,7 +57,7 @@ fn equate_intrinsic_type<'tcx>(
|
||||
{
|
||||
let fty = tcx.mk_fn_ptr(sig);
|
||||
let cause = ObligationCause::new(it.span, it.hir_id(), ObligationCauseCode::IntrinsicType);
|
||||
require_same_types(tcx, &cause, tcx.mk_fn_ptr(tcx.fn_sig(it.def_id)), fty);
|
||||
require_same_types(tcx, &cause, tcx.mk_fn_ptr(tcx.fn_sig(it.owner_id)), fty);
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: DefId) -> hir
|
||||
/// and in `library/core/src/intrinsics.rs`.
|
||||
pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
||||
let param = |n| tcx.mk_ty_param(n, Symbol::intern(&format!("P{}", n)));
|
||||
let intrinsic_id = it.def_id.to_def_id();
|
||||
let intrinsic_id = it.owner_id.to_def_id();
|
||||
let intrinsic_name = tcx.item_name(intrinsic_id);
|
||||
let name_str = intrinsic_name.as_str();
|
||||
|
||||
|
@ -147,10 +147,10 @@ fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) {
|
||||
/// the types first.
|
||||
#[instrument(skip(tcx), level = "debug")]
|
||||
fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
let def_id = item.def_id.def_id;
|
||||
let def_id = item.owner_id.def_id;
|
||||
|
||||
debug!(
|
||||
?item.def_id,
|
||||
?item.owner_id,
|
||||
item.name = ? tcx.def_path_str(def_id.to_def_id())
|
||||
);
|
||||
|
||||
@ -246,10 +246,10 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
}
|
||||
|
||||
fn check_foreign_item(tcx: TyCtxt<'_>, item: &hir::ForeignItem<'_>) {
|
||||
let def_id = item.def_id.def_id;
|
||||
let def_id = item.owner_id.def_id;
|
||||
|
||||
debug!(
|
||||
?item.def_id,
|
||||
?item.owner_id,
|
||||
item.name = ? tcx.def_path_str(def_id.to_def_id())
|
||||
);
|
||||
|
||||
@ -263,7 +263,7 @@ fn check_foreign_item(tcx: TyCtxt<'_>, item: &hir::ForeignItem<'_>) {
|
||||
}
|
||||
|
||||
fn check_trait_item(tcx: TyCtxt<'_>, trait_item: &hir::TraitItem<'_>) {
|
||||
let def_id = trait_item.def_id.def_id;
|
||||
let def_id = trait_item.owner_id.def_id;
|
||||
|
||||
let (method_sig, span) = match trait_item.kind {
|
||||
hir::TraitItemKind::Fn(ref sig, _) => (Some(sig), trait_item.span),
|
||||
@ -275,7 +275,7 @@ fn check_trait_item(tcx: TyCtxt<'_>, trait_item: &hir::TraitItem<'_>) {
|
||||
|
||||
let encl_trait_def_id = tcx.local_parent(def_id);
|
||||
let encl_trait = tcx.hir().expect_item(encl_trait_def_id);
|
||||
let encl_trait_def_id = encl_trait.def_id.to_def_id();
|
||||
let encl_trait_def_id = encl_trait.owner_id.to_def_id();
|
||||
let fn_lang_item_name = if Some(encl_trait_def_id) == tcx.lang_items().fn_trait() {
|
||||
Some("fn")
|
||||
} else if Some(encl_trait_def_id) == tcx.lang_items().fn_mut_trait() {
|
||||
@ -348,7 +348,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
|
||||
loop {
|
||||
let mut should_continue = false;
|
||||
for gat_item in associated_items {
|
||||
let gat_def_id = gat_item.id.def_id;
|
||||
let gat_def_id = gat_item.id.owner_id;
|
||||
let gat_item = tcx.associated_item(gat_def_id);
|
||||
// If this item is not an assoc ty, or has no substs, then it's not a GAT
|
||||
if gat_item.kind != ty::AssocKind::Type {
|
||||
@ -365,7 +365,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
|
||||
// constrains the GAT with individually.
|
||||
let mut new_required_bounds: Option<FxHashSet<ty::Predicate<'_>>> = None;
|
||||
for item in associated_items {
|
||||
let item_def_id = item.id.def_id;
|
||||
let item_def_id = item.id.owner_id;
|
||||
// Skip our own GAT, since it does not constrain itself at all.
|
||||
if item_def_id == gat_def_id {
|
||||
continue;
|
||||
@ -790,7 +790,7 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
|
||||
let (trait_name, trait_def_id) =
|
||||
match tcx.hir().get_by_def_id(tcx.hir().get_parent_item(item.hir_id()).def_id) {
|
||||
hir::Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Trait(..) => (item.ident, item.def_id),
|
||||
hir::ItemKind::Trait(..) => (item.ident, item.owner_id),
|
||||
_ => return,
|
||||
},
|
||||
_ => return,
|
||||
@ -845,7 +845,7 @@ fn check_impl_item(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>) {
|
||||
_ => (None, impl_item.span),
|
||||
};
|
||||
|
||||
check_associated_item(tcx, impl_item.def_id.def_id, span, method_sig);
|
||||
check_associated_item(tcx, impl_item.owner_id.def_id, span, method_sig);
|
||||
}
|
||||
|
||||
fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
|
||||
@ -1045,11 +1045,11 @@ fn check_type_defn<'tcx, F>(
|
||||
) where
|
||||
F: FnMut(&WfCheckingCtxt<'_, 'tcx>) -> Vec<AdtVariant<'tcx>>,
|
||||
{
|
||||
let _ = tcx.representability(item.def_id.def_id);
|
||||
let _ = tcx.representability(item.owner_id.def_id);
|
||||
|
||||
enter_wf_checking_ctxt(tcx, item.span, item.def_id.def_id, |wfcx| {
|
||||
enter_wf_checking_ctxt(tcx, item.span, item.owner_id.def_id, |wfcx| {
|
||||
let variants = lookup_fields(wfcx);
|
||||
let packed = tcx.adt_def(item.def_id).repr().packed();
|
||||
let packed = tcx.adt_def(item.owner_id).repr().packed();
|
||||
|
||||
for variant in &variants {
|
||||
// All field types must be well-formed.
|
||||
@ -1073,7 +1073,7 @@ fn check_type_defn<'tcx, F>(
|
||||
// Just treat unresolved type expression as if it needs drop.
|
||||
true
|
||||
} else {
|
||||
ty.needs_drop(tcx, tcx.param_env(item.def_id))
|
||||
ty.needs_drop(tcx, tcx.param_env(item.owner_id))
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1121,15 +1121,15 @@ fn check_type_defn<'tcx, F>(
|
||||
}
|
||||
}
|
||||
|
||||
check_where_clauses(wfcx, item.span, item.def_id.def_id);
|
||||
check_where_clauses(wfcx, item.span, item.owner_id.def_id);
|
||||
});
|
||||
}
|
||||
|
||||
#[instrument(skip(tcx, item))]
|
||||
fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
|
||||
debug!(?item.def_id);
|
||||
debug!(?item.owner_id);
|
||||
|
||||
let def_id = item.def_id.def_id;
|
||||
let def_id = item.owner_id.def_id;
|
||||
let trait_def = tcx.trait_def(def_id);
|
||||
if trait_def.is_marker
|
||||
|| matches!(trait_def.specialization_kind, TraitSpecializationKind::Marker)
|
||||
@ -1240,13 +1240,13 @@ fn check_impl<'tcx>(
|
||||
ast_trait_ref: &Option<hir::TraitRef<'_>>,
|
||||
constness: hir::Constness,
|
||||
) {
|
||||
enter_wf_checking_ctxt(tcx, item.span, item.def_id.def_id, |wfcx| {
|
||||
enter_wf_checking_ctxt(tcx, item.span, item.owner_id.def_id, |wfcx| {
|
||||
match *ast_trait_ref {
|
||||
Some(ref ast_trait_ref) => {
|
||||
// `#[rustc_reservation_impl]` impls are not real impls and
|
||||
// therefore don't need to be WF (the trait's `Self: Trait` predicate
|
||||
// won't hold).
|
||||
let trait_ref = tcx.impl_trait_ref(item.def_id).unwrap();
|
||||
let trait_ref = tcx.impl_trait_ref(item.owner_id).unwrap();
|
||||
let trait_ref = wfcx.normalize(ast_trait_ref.path.span, None, trait_ref);
|
||||
let trait_pred = ty::TraitPredicate {
|
||||
trait_ref,
|
||||
@ -1268,7 +1268,7 @@ fn check_impl<'tcx>(
|
||||
wfcx.register_obligations(obligations);
|
||||
}
|
||||
None => {
|
||||
let self_ty = tcx.type_of(item.def_id);
|
||||
let self_ty = tcx.type_of(item.owner_id);
|
||||
let self_ty = wfcx.normalize(
|
||||
item.span,
|
||||
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
|
||||
@ -1282,7 +1282,7 @@ fn check_impl<'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
check_where_clauses(wfcx, item.span, item.def_id.def_id);
|
||||
check_where_clauses(wfcx, item.span, item.owner_id.def_id);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1778,14 +1778,14 @@ fn check_variances_for_type_defn<'tcx>(
|
||||
item: &hir::Item<'tcx>,
|
||||
hir_generics: &hir::Generics<'_>,
|
||||
) {
|
||||
let ty = tcx.type_of(item.def_id);
|
||||
let ty = tcx.type_of(item.owner_id);
|
||||
if tcx.has_error_field(ty) {
|
||||
return;
|
||||
}
|
||||
|
||||
let ty_predicates = tcx.predicates_of(item.def_id);
|
||||
let ty_predicates = tcx.predicates_of(item.owner_id);
|
||||
assert_eq!(ty_predicates.parent, None);
|
||||
let variances = tcx.variances_of(item.def_id);
|
||||
let variances = tcx.variances_of(item.owner_id);
|
||||
|
||||
let mut constrained_parameters: FxHashSet<_> = variances
|
||||
.iter()
|
||||
@ -1798,7 +1798,7 @@ fn check_variances_for_type_defn<'tcx>(
|
||||
|
||||
// Lazily calculated because it is only needed in case of an error.
|
||||
let explicitly_bounded_params = LazyCell::new(|| {
|
||||
let icx = crate::collect::ItemCtxt::new(tcx, item.def_id.to_def_id());
|
||||
let icx = crate::collect::ItemCtxt::new(tcx, item.owner_id.to_def_id());
|
||||
hir_generics
|
||||
.predicates
|
||||
.iter()
|
||||
@ -1919,10 +1919,10 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
|
||||
|
||||
fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalDefId) {
|
||||
let items = tcx.hir_module_items(module);
|
||||
items.par_items(|item| tcx.ensure().check_well_formed(item.def_id));
|
||||
items.par_impl_items(|item| tcx.ensure().check_well_formed(item.def_id));
|
||||
items.par_trait_items(|item| tcx.ensure().check_well_formed(item.def_id));
|
||||
items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.def_id));
|
||||
items.par_items(|item| tcx.ensure().check_well_formed(item.owner_id));
|
||||
items.par_impl_items(|item| tcx.ensure().check_well_formed(item.owner_id));
|
||||
items.par_trait_items(|item| tcx.ensure().check_well_formed(item.owner_id));
|
||||
items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.owner_id));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -89,11 +89,11 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
|
||||
let mut crates_to_lint = vec![];
|
||||
|
||||
for id in tcx.hir().items() {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::ExternCrate) {
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::ExternCrate) {
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::ExternCrate(orig_name) = item.kind {
|
||||
crates_to_lint.push(ExternCrateToLint {
|
||||
def_id: item.def_id.to_def_id(),
|
||||
def_id: item.owner_id.to_def_id(),
|
||||
span: item.span,
|
||||
orig_name,
|
||||
warn_if_unused: !item.ident.as_str().starts_with('_'),
|
||||
|
@ -58,7 +58,7 @@ const ADD_ATTR: &str =
|
||||
|
||||
impl<'tcx> InherentCollect<'tcx> {
|
||||
fn check_def_id(&mut self, item: &hir::Item<'_>, self_ty: Ty<'tcx>, def_id: DefId) {
|
||||
let impl_def_id = item.def_id;
|
||||
let impl_def_id = item.owner_id;
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
// Add the implementation to the mapping from implementation to base
|
||||
// type def ID, if there is a base type for this implementation and
|
||||
@ -89,7 +89,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
||||
for impl_item in items {
|
||||
if !self
|
||||
.tcx
|
||||
.has_attr(impl_item.id.def_id.to_def_id(), sym::rustc_allow_incoherent_impl)
|
||||
.has_attr(impl_item.id.owner_id.to_def_id(), sym::rustc_allow_incoherent_impl)
|
||||
{
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
@ -135,7 +135,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
||||
for item in items {
|
||||
if !self
|
||||
.tcx
|
||||
.has_attr(item.id.def_id.to_def_id(), sym::rustc_allow_incoherent_impl)
|
||||
.has_attr(item.id.owner_id.to_def_id(), sym::rustc_allow_incoherent_impl)
|
||||
{
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
@ -177,7 +177,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
||||
}
|
||||
|
||||
fn check_item(&mut self, id: hir::ItemId) {
|
||||
if !matches!(self.tcx.def_kind(id.def_id), DefKind::Impl) {
|
||||
if !matches!(self.tcx.def_kind(id.owner_id), DefKind::Impl) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
||||
return;
|
||||
};
|
||||
|
||||
let self_ty = self.tcx.type_of(item.def_id);
|
||||
let self_ty = self.tcx.type_of(item.owner_id);
|
||||
match *self_ty.kind() {
|
||||
ty::Adt(def, _) => {
|
||||
self.check_def_id(item, self_ty, def.did());
|
||||
@ -221,7 +221,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
||||
| ty::Never
|
||||
| ty::FnPtr(_)
|
||||
| ty::Tuple(..) => {
|
||||
self.check_primitive_impl(item.def_id.def_id, self_ty, items, ty.span)
|
||||
self.check_primitive_impl(item.owner_id.def_id, self_ty, items, ty.span)
|
||||
}
|
||||
ty::Projection(..) | ty::Opaque(..) | ty::Param(_) => {
|
||||
let mut err = struct_span_err!(
|
||||
@ -243,7 +243,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
||||
| ty::Bound(..)
|
||||
| ty::Placeholder(_)
|
||||
| ty::Infer(_) => {
|
||||
bug!("unexpected impl self type of impl: {:?} {:?}", item.def_id, self_ty);
|
||||
bug!("unexpected impl self type of impl: {:?} {:?}", item.owner_id, self_ty);
|
||||
}
|
||||
ty::Error(_) => {}
|
||||
}
|
||||
|
@ -156,14 +156,14 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
|
||||
}
|
||||
|
||||
fn check_item(&mut self, id: hir::ItemId) {
|
||||
let def_kind = self.tcx.def_kind(id.def_id);
|
||||
let def_kind = self.tcx.def_kind(id.owner_id);
|
||||
if !matches!(def_kind, DefKind::Enum | DefKind::Struct | DefKind::Trait | DefKind::Union) {
|
||||
return;
|
||||
}
|
||||
|
||||
let impls = self.tcx.inherent_impls(id.def_id);
|
||||
let impls = self.tcx.inherent_impls(id.owner_id);
|
||||
|
||||
let overlap_mode = OverlapMode::get(self.tcx, id.def_id.to_def_id());
|
||||
let overlap_mode = OverlapMode::get(self.tcx, id.owner_id.to_def_id());
|
||||
|
||||
let impls_items = impls
|
||||
.iter()
|
||||
|
@ -101,7 +101,7 @@ fn do_orphan_check_impl<'tcx>(
|
||||
span_bug!(sp, "opaque type not found, but `has_opaque_types` is set")
|
||||
}
|
||||
|
||||
match traits::orphan_check(tcx, item.def_id.to_def_id()) {
|
||||
match traits::orphan_check(tcx, item.owner_id.to_def_id()) {
|
||||
Ok(()) => {}
|
||||
Err(err) => emit_orphan_check_error(
|
||||
tcx,
|
||||
|
@ -13,7 +13,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
let item = tcx.hir().expect_item(def_id);
|
||||
let hir::ItemKind::Impl(ref impl_) = item.kind else { bug!() };
|
||||
|
||||
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 trait_def = tcx.trait_def(trait_ref.def_id);
|
||||
let unsafe_attr =
|
||||
impl_.generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle");
|
||||
|
@ -571,7 +571,7 @@ fn get_new_lifetime_name<'tcx>(
|
||||
fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
|
||||
let it = tcx.hir().item(item_id);
|
||||
debug!("convert: item {} with id {}", it.ident, it.hir_id());
|
||||
let def_id = item_id.def_id.def_id;
|
||||
let def_id = item_id.owner_id.def_id;
|
||||
|
||||
match it.kind {
|
||||
// These don't define types.
|
||||
@ -583,11 +583,11 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
|
||||
hir::ItemKind::ForeignMod { items, .. } => {
|
||||
for item in items {
|
||||
let item = tcx.hir().foreign_item(item.id);
|
||||
tcx.ensure().generics_of(item.def_id);
|
||||
tcx.ensure().type_of(item.def_id);
|
||||
tcx.ensure().predicates_of(item.def_id);
|
||||
tcx.ensure().generics_of(item.owner_id);
|
||||
tcx.ensure().type_of(item.owner_id);
|
||||
tcx.ensure().predicates_of(item.owner_id);
|
||||
match item.kind {
|
||||
hir::ForeignItemKind::Fn(..) => tcx.ensure().fn_sig(item.def_id),
|
||||
hir::ForeignItemKind::Fn(..) => tcx.ensure().fn_sig(item.owner_id),
|
||||
hir::ForeignItemKind::Static(..) => {
|
||||
let mut visitor = HirPlaceholderCollector::default();
|
||||
visitor.visit_foreign_item(item);
|
||||
@ -683,7 +683,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
|
||||
|
||||
fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
||||
let trait_item = tcx.hir().trait_item(trait_item_id);
|
||||
let def_id = trait_item_id.def_id;
|
||||
let def_id = trait_item_id.owner_id;
|
||||
tcx.ensure().generics_of(def_id);
|
||||
|
||||
match trait_item.kind {
|
||||
@ -730,7 +730,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
||||
}
|
||||
|
||||
fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::ImplItemId) {
|
||||
let def_id = impl_item_id.def_id;
|
||||
let def_id = impl_item_id.owner_id;
|
||||
tcx.ensure().generics_of(def_id);
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().predicates_of(def_id);
|
||||
@ -1010,7 +1010,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
|
||||
|
||||
match item {
|
||||
Some(item) if matches!(item.kind, hir::AssocItemKind::Fn { .. }) => {
|
||||
if !tcx.impl_defaultness(item.id.def_id).has_value() {
|
||||
if !tcx.impl_defaultness(item.id.owner_id).has_value() {
|
||||
tcx.sess
|
||||
.struct_span_err(
|
||||
item.span,
|
||||
|
@ -331,8 +331,8 @@ fn convert_named_region_map(named_region_map: NamedRegionMap) -> ResolveLifetime
|
||||
/// `resolve_lifetimes`.
|
||||
fn resolve_lifetimes_for<'tcx>(tcx: TyCtxt<'tcx>, def_id: hir::OwnerId) -> &'tcx ResolveLifetimes {
|
||||
let item_id = item_for(tcx, def_id.def_id);
|
||||
let local_def_id = item_id.def_id.def_id;
|
||||
if item_id.def_id == def_id {
|
||||
let local_def_id = item_id.owner_id.def_id;
|
||||
if item_id.owner_id == def_id {
|
||||
let item = tcx.hir().item(item_id);
|
||||
match item.kind {
|
||||
hir::ItemKind::Trait(..) => tcx.resolve_lifetimes_trait_definition(local_def_id),
|
||||
@ -557,11 +557,11 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
// their owner, we can keep going until we find the Item that owns that. We then
|
||||
// conservatively add all resolved lifetimes. Otherwise we run into problems in
|
||||
// cases like `type Foo<'a> = impl Bar<As = impl Baz + 'a>`.
|
||||
for (_hir_id, node) in self.tcx.hir().parent_iter(item.def_id.into()) {
|
||||
for (_hir_id, node) in self.tcx.hir().parent_iter(item.owner_id.into()) {
|
||||
match node {
|
||||
hir::Node::Item(parent_item) => {
|
||||
let resolved_lifetimes: &ResolveLifetimes = self.tcx.resolve_lifetimes(
|
||||
item_for(self.tcx, parent_item.def_id.def_id).def_id.def_id,
|
||||
item_for(self.tcx, parent_item.owner_id.def_id).owner_id.def_id,
|
||||
);
|
||||
// We need to add *all* deps, since opaque tys may want them from *us*
|
||||
for (&owner, defs) in resolved_lifetimes.defs.iter() {
|
||||
|
@ -643,24 +643,24 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
|
||||
intravisit::walk_expr(self, ex);
|
||||
}
|
||||
fn visit_item(&mut self, it: &'tcx Item<'tcx>) {
|
||||
trace!(?it.def_id);
|
||||
trace!(?it.owner_id);
|
||||
// The opaque type itself or its children are not within its reveal scope.
|
||||
if it.def_id.def_id != self.def_id {
|
||||
self.check(it.def_id.def_id);
|
||||
if it.owner_id.def_id != self.def_id {
|
||||
self.check(it.owner_id.def_id);
|
||||
intravisit::walk_item(self, it);
|
||||
}
|
||||
}
|
||||
fn visit_impl_item(&mut self, it: &'tcx ImplItem<'tcx>) {
|
||||
trace!(?it.def_id);
|
||||
trace!(?it.owner_id);
|
||||
// The opaque type itself or its children are not within its reveal scope.
|
||||
if it.def_id.def_id != self.def_id {
|
||||
self.check(it.def_id.def_id);
|
||||
if it.owner_id.def_id != self.def_id {
|
||||
self.check(it.owner_id.def_id);
|
||||
intravisit::walk_impl_item(self, it);
|
||||
}
|
||||
}
|
||||
fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
|
||||
trace!(?it.def_id);
|
||||
self.check(it.def_id.def_id);
|
||||
trace!(?it.owner_id);
|
||||
self.check(it.owner_id.def_id);
|
||||
intravisit::walk_trait_item(self, it);
|
||||
}
|
||||
}
|
||||
@ -772,24 +772,24 @@ fn find_opaque_ty_constraints_for_rpit(
|
||||
intravisit::walk_expr(self, ex);
|
||||
}
|
||||
fn visit_item(&mut self, it: &'tcx Item<'tcx>) {
|
||||
trace!(?it.def_id);
|
||||
trace!(?it.owner_id);
|
||||
// The opaque type itself or its children are not within its reveal scope.
|
||||
if it.def_id.def_id != self.def_id {
|
||||
self.check(it.def_id.def_id);
|
||||
if it.owner_id.def_id != self.def_id {
|
||||
self.check(it.owner_id.def_id);
|
||||
intravisit::walk_item(self, it);
|
||||
}
|
||||
}
|
||||
fn visit_impl_item(&mut self, it: &'tcx ImplItem<'tcx>) {
|
||||
trace!(?it.def_id);
|
||||
trace!(?it.owner_id);
|
||||
// The opaque type itself or its children are not within its reveal scope.
|
||||
if it.def_id.def_id != self.def_id {
|
||||
self.check(it.def_id.def_id);
|
||||
if it.owner_id.def_id != self.def_id {
|
||||
self.check(it.owner_id.def_id);
|
||||
intravisit::walk_impl_item(self, it);
|
||||
}
|
||||
}
|
||||
fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
|
||||
trace!(?it.def_id);
|
||||
self.check(it.def_id.def_id);
|
||||
trace!(?it.owner_id);
|
||||
self.check(it.owner_id.def_id);
|
||||
intravisit::walk_trait_item(self, it);
|
||||
}
|
||||
}
|
||||
|
@ -55,10 +55,10 @@ fn check_mod_impl_wf(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||
let min_specialization = tcx.features().min_specialization;
|
||||
let module = tcx.hir_module_items(module_def_id);
|
||||
for id in module.items() {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::Impl) {
|
||||
enforce_impl_params_are_constrained(tcx, id.def_id.def_id);
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
|
||||
enforce_impl_params_are_constrained(tcx, id.owner_id.def_id);
|
||||
if min_specialization {
|
||||
check_min_specialization(tcx, id.def_id.def_id);
|
||||
check_min_specialization(tcx, id.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
||||
error = true;
|
||||
}
|
||||
if let hir::IsAsync::Async = sig.header.asyncness {
|
||||
let span = tcx.def_span(it.def_id);
|
||||
let span = tcx.def_span(it.owner_id);
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
span,
|
||||
|
@ -29,7 +29,7 @@ pub(super) fn infer_predicates<'tcx>(
|
||||
|
||||
// Visit all the crates and infer predicates
|
||||
for id in tcx.hir().items() {
|
||||
let item_did = id.def_id;
|
||||
let item_did = id.owner_id;
|
||||
|
||||
debug!("InferVisitor::visit_item(item={:?})", item_did);
|
||||
|
||||
|
@ -6,11 +6,11 @@ pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
|
||||
for id in tcx.hir().items() {
|
||||
// For unit testing: check for a special "rustc_outlives"
|
||||
// attribute and report an error with various results if found.
|
||||
if tcx.has_attr(id.def_id.to_def_id(), sym::rustc_outlives) {
|
||||
let inferred_outlives_of = tcx.inferred_outlives_of(id.def_id);
|
||||
if tcx.has_attr(id.owner_id.to_def_id(), sym::rustc_outlives) {
|
||||
let inferred_outlives_of = tcx.inferred_outlives_of(id.owner_id);
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.def_span(id.def_id),
|
||||
tcx.def_span(id.owner_id),
|
||||
E0640,
|
||||
"{:?}",
|
||||
inferred_outlives_of
|
||||
|
@ -6,9 +6,10 @@ pub fn test_variance(tcx: TyCtxt<'_>) {
|
||||
// For unit testing: check for a special "rustc_variance"
|
||||
// attribute and report an error with various results if found.
|
||||
for id in tcx.hir().items() {
|
||||
if tcx.has_attr(id.def_id.to_def_id(), sym::rustc_variance) {
|
||||
let variances_of = tcx.variances_of(id.def_id);
|
||||
struct_span_err!(tcx.sess, tcx.def_span(id.def_id), E0208, "{:?}", variances_of).emit();
|
||||
if tcx.has_attr(id.owner_id.to_def_id(), sym::rustc_variance) {
|
||||
let variances_of = tcx.variances_of(id.owner_id);
|
||||
struct_span_err!(tcx.sess, tcx.def_span(id.owner_id), E0208, "{:?}", variances_of)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,19 +149,19 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
dirty_clean_visitor.check_item(id.def_id.def_id);
|
||||
dirty_clean_visitor.check_item(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.trait_items() {
|
||||
dirty_clean_visitor.check_item(id.def_id.def_id);
|
||||
dirty_clean_visitor.check_item(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.impl_items() {
|
||||
dirty_clean_visitor.check_item(id.def_id.def_id);
|
||||
dirty_clean_visitor.check_item(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.foreign_items() {
|
||||
dirty_clean_visitor.check_item(id.def_id.def_id);
|
||||
dirty_clean_visitor.check_item(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
let mut all_attrs = FindAllAttrs { tcx, found_attrs: vec![] };
|
||||
|
@ -306,7 +306,7 @@ pub fn suggest_new_region_bound(
|
||||
};
|
||||
|
||||
// Get the identity type for this RPIT
|
||||
let did = item_id.def_id.to_def_id();
|
||||
let did = item_id.owner_id.to_def_id();
|
||||
let ty = tcx.mk_opaque(did, ty::InternalSubsts::identity_for_item(tcx, did));
|
||||
|
||||
if let Some(span) = opaque
|
||||
|
@ -9,7 +9,7 @@ fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
||||
for id in tcx.hir().items() {
|
||||
let attrs = finder.tcx.hir().attrs(id.hir_id());
|
||||
if finder.tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
|
||||
finder.decls = Some(id.def_id.def_id);
|
||||
finder.decls = Some(id.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -6,13 +6,13 @@ use rustc_session::cstore::ForeignModule;
|
||||
pub(crate) fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> {
|
||||
let mut modules = Vec::new();
|
||||
for id in tcx.hir().items() {
|
||||
if !matches!(tcx.def_kind(id.def_id), DefKind::ForeignMod) {
|
||||
if !matches!(tcx.def_kind(id.owner_id), DefKind::ForeignMod) {
|
||||
continue;
|
||||
}
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::ForeignMod { items, .. } = item.kind {
|
||||
let foreign_items = items.iter().map(|it| it.id.def_id.to_def_id()).collect();
|
||||
modules.push(ForeignModule { foreign_items, def_id: id.def_id.to_def_id() });
|
||||
let foreign_items = items.iter().map(|it| it.id.owner_id.to_def_id()).collect();
|
||||
modules.push(ForeignModule { foreign_items, def_id: id.owner_id.to_def_id() });
|
||||
}
|
||||
}
|
||||
modules
|
||||
|
@ -98,7 +98,7 @@ struct Collector<'tcx> {
|
||||
|
||||
impl<'tcx> Collector<'tcx> {
|
||||
fn process_item(&mut self, id: rustc_hir::ItemId) {
|
||||
if !matches!(self.tcx.def_kind(id.def_id), DefKind::ForeignMod) {
|
||||
if !matches!(self.tcx.def_kind(id.owner_id), DefKind::ForeignMod) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -372,17 +372,17 @@ impl<'tcx> Collector<'tcx> {
|
||||
}
|
||||
_ => {
|
||||
for child_item in foreign_mod_items {
|
||||
if self.tcx.def_kind(child_item.id.def_id).has_codegen_attrs()
|
||||
if self.tcx.def_kind(child_item.id.owner_id).has_codegen_attrs()
|
||||
&& self
|
||||
.tcx
|
||||
.codegen_fn_attrs(child_item.id.def_id)
|
||||
.codegen_fn_attrs(child_item.id.owner_id)
|
||||
.link_ordinal
|
||||
.is_some()
|
||||
{
|
||||
let link_ordinal_attr = self
|
||||
.tcx
|
||||
.hir()
|
||||
.attrs(child_item.id.def_id.into())
|
||||
.attrs(child_item.id.owner_id.into())
|
||||
.iter()
|
||||
.find(|a| a.has_name(sym::link_ordinal))
|
||||
.unwrap();
|
||||
@ -402,7 +402,7 @@ impl<'tcx> Collector<'tcx> {
|
||||
filename,
|
||||
kind,
|
||||
cfg,
|
||||
foreign_module: Some(it.def_id.to_def_id()),
|
||||
foreign_module: Some(it.owner_id.to_def_id()),
|
||||
wasm_import_module: wasm_import_module.map(|(name, _)| name),
|
||||
verbatim,
|
||||
dll_imports,
|
||||
@ -505,7 +505,7 @@ impl<'tcx> Collector<'tcx> {
|
||||
fn i686_arg_list_size(&self, item: &hir::ForeignItemRef) -> usize {
|
||||
let argument_types: &List<Ty<'_>> = self.tcx.erase_late_bound_regions(
|
||||
self.tcx
|
||||
.type_of(item.id.def_id)
|
||||
.type_of(item.id.owner_id)
|
||||
.fn_sig(self.tcx)
|
||||
.inputs()
|
||||
.map_bound(|slice| self.tcx.mk_type_list(slice.iter())),
|
||||
@ -557,7 +557,7 @@ impl<'tcx> Collector<'tcx> {
|
||||
}
|
||||
};
|
||||
|
||||
let codegen_fn_attrs = self.tcx.codegen_fn_attrs(item.id.def_id);
|
||||
let codegen_fn_attrs = self.tcx.codegen_fn_attrs(item.id.owner_id);
|
||||
let import_name_type = codegen_fn_attrs
|
||||
.link_ordinal
|
||||
.map_or(import_name_type, |ord| Some(PeImportNameType::Ordinal(ord)));
|
||||
@ -567,7 +567,7 @@ impl<'tcx> Collector<'tcx> {
|
||||
import_name_type,
|
||||
calling_convention,
|
||||
span: item.span,
|
||||
is_fn: self.tcx.def_kind(item.id.def_id).is_fn_like(),
|
||||
is_fn: self.tcx.def_kind(item.id.owner_id).is_fn_like(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1290,21 +1290,21 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
// from name resolution point of view.
|
||||
hir::ItemKind::ForeignMod { items, .. } => {
|
||||
for foreign_item in items {
|
||||
yield foreign_item.id.def_id.def_id.local_def_index;
|
||||
yield foreign_item.id.owner_id.def_id.local_def_index;
|
||||
}
|
||||
}
|
||||
// Only encode named non-reexport children, reexports are encoded
|
||||
// separately and unnamed items are not used by name resolution.
|
||||
hir::ItemKind::ExternCrate(..) => continue,
|
||||
hir::ItemKind::Struct(ref vdata, _) => {
|
||||
yield item_id.def_id.def_id.local_def_index;
|
||||
yield item_id.owner_id.def_id.local_def_index;
|
||||
// Encode constructors which take a separate slot in value namespace.
|
||||
if let Some(ctor_hir_id) = vdata.ctor_hir_id() {
|
||||
yield tcx.hir().local_def_id(ctor_hir_id).local_def_index;
|
||||
}
|
||||
}
|
||||
_ if tcx.def_key(item_id.def_id.to_def_id()).get_opt_name().is_some() => {
|
||||
yield item_id.def_id.def_id.local_def_index;
|
||||
_ if tcx.def_key(item_id.owner_id.to_def_id()).get_opt_name().is_some() => {
|
||||
yield item_id.owner_id.def_id.local_def_index;
|
||||
}
|
||||
_ => continue,
|
||||
}
|
||||
@ -1541,7 +1541,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
record!(self.tables.macro_definition[def_id] <- &*macro_def.body);
|
||||
}
|
||||
hir::ItemKind::Mod(ref m) => {
|
||||
return self.encode_info_for_mod(item.def_id.def_id, m);
|
||||
return self.encode_info_for_mod(item.owner_id.def_id, m);
|
||||
}
|
||||
hir::ItemKind::OpaqueTy(..) => {
|
||||
self.encode_explicit_item_bounds(def_id);
|
||||
@ -1673,7 +1673,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
// normally in the visitor walk.
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(..) => {
|
||||
let def = self.tcx.adt_def(item.def_id.to_def_id());
|
||||
let def = self.tcx.adt_def(item.owner_id.to_def_id());
|
||||
for (i, variant) in def.variants().iter_enumerated() {
|
||||
self.encode_enum_variant_info(def, i);
|
||||
|
||||
@ -1683,7 +1683,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Struct(ref struct_def, _) => {
|
||||
let def = self.tcx.adt_def(item.def_id.to_def_id());
|
||||
let def = self.tcx.adt_def(item.owner_id.to_def_id());
|
||||
// If the struct has a constructor, encode it.
|
||||
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
|
||||
let ctor_def_id = self.tcx.hir().local_def_id(ctor_hir_id);
|
||||
@ -1692,13 +1692,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
hir::ItemKind::Impl { .. } => {
|
||||
for &trait_item_def_id in
|
||||
self.tcx.associated_item_def_ids(item.def_id.to_def_id()).iter()
|
||||
self.tcx.associated_item_def_ids(item.owner_id.to_def_id()).iter()
|
||||
{
|
||||
self.encode_info_for_impl_item(trait_item_def_id);
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Trait(..) => {
|
||||
for &item_def_id in self.tcx.associated_item_def_ids(item.def_id.to_def_id()).iter()
|
||||
for &item_def_id in
|
||||
self.tcx.associated_item_def_ids(item.owner_id.to_def_id()).iter()
|
||||
{
|
||||
self.encode_info_for_trait_item(item_def_id);
|
||||
}
|
||||
@ -1939,8 +1940,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
FxHashMap::default();
|
||||
|
||||
for id in tcx.hir().items() {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::Impl) {
|
||||
if let Some(trait_ref) = tcx.impl_trait_ref(id.def_id) {
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
|
||||
if let Some(trait_ref) = tcx.impl_trait_ref(id.owner_id) {
|
||||
let simplified_self_ty = fast_reject::simplify_type(
|
||||
self.tcx,
|
||||
trait_ref.self_ty(),
|
||||
@ -1950,7 +1951,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
fx_hash_map
|
||||
.entry(trait_ref.def_id)
|
||||
.or_default()
|
||||
.push((id.def_id.def_id.local_def_index, simplified_self_ty));
|
||||
.push((id.owner_id.def_id.local_def_index, simplified_self_ty));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2091,12 +2092,12 @@ impl<'a, 'tcx> Visitor<'tcx> for EncodeContext<'a, 'tcx> {
|
||||
intravisit::walk_item(self, item);
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) => {} // ignore these
|
||||
_ => self.encode_info_for_item(item.def_id.to_def_id(), item),
|
||||
_ => self.encode_info_for_item(item.owner_id.to_def_id(), item),
|
||||
}
|
||||
}
|
||||
fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem<'tcx>) {
|
||||
intravisit::walk_foreign_item(self, ni);
|
||||
self.encode_info_for_foreign_item(ni.def_id.to_def_id(), ni);
|
||||
self.encode_info_for_foreign_item(ni.owner_id.to_def_id(), ni);
|
||||
}
|
||||
fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) {
|
||||
intravisit::walk_generics(self, generics);
|
||||
@ -2315,8 +2316,8 @@ pub fn provide(providers: &mut Providers) {
|
||||
|
||||
let mut traits = Vec::new();
|
||||
for id in tcx.hir().items() {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::Trait | DefKind::TraitAlias) {
|
||||
traits.push(id.def_id.to_def_id())
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Trait | DefKind::TraitAlias) {
|
||||
traits.push(id.owner_id.to_def_id())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,19 +354,19 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
pub fn item(self, id: ItemId) -> &'hir Item<'hir> {
|
||||
self.tcx.hir_owner(id.def_id).unwrap().node.expect_item()
|
||||
self.tcx.hir_owner(id.owner_id).unwrap().node.expect_item()
|
||||
}
|
||||
|
||||
pub fn trait_item(self, id: TraitItemId) -> &'hir TraitItem<'hir> {
|
||||
self.tcx.hir_owner(id.def_id).unwrap().node.expect_trait_item()
|
||||
self.tcx.hir_owner(id.owner_id).unwrap().node.expect_trait_item()
|
||||
}
|
||||
|
||||
pub fn impl_item(self, id: ImplItemId) -> &'hir ImplItem<'hir> {
|
||||
self.tcx.hir_owner(id.def_id).unwrap().node.expect_impl_item()
|
||||
self.tcx.hir_owner(id.owner_id).unwrap().node.expect_impl_item()
|
||||
}
|
||||
|
||||
pub fn foreign_item(self, id: ForeignItemId) -> &'hir ForeignItem<'hir> {
|
||||
self.tcx.hir_owner(id.def_id).unwrap().node.expect_foreign_item()
|
||||
self.tcx.hir_owner(id.owner_id).unwrap().node.expect_foreign_item()
|
||||
}
|
||||
|
||||
pub fn body(self, id: BodyId) -> &'hir Body<'hir> {
|
||||
@ -1377,14 +1377,14 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
|
||||
|
||||
fn visit_item(&mut self, item: &'hir Item<'hir>) {
|
||||
if associated_body(Node::Item(item)).is_some() {
|
||||
self.body_owners.push(item.def_id.def_id);
|
||||
self.body_owners.push(item.owner_id.def_id);
|
||||
}
|
||||
|
||||
self.items.push(item.item_id());
|
||||
|
||||
// Items that are modules are handled here instead of in visit_mod.
|
||||
if let ItemKind::Mod(module) = &item.kind {
|
||||
self.submodules.push(item.def_id);
|
||||
self.submodules.push(item.owner_id);
|
||||
// A module collector does not recurse inside nested modules.
|
||||
if self.crate_collector {
|
||||
intravisit::walk_mod(self, module, item.hir_id());
|
||||
@ -1413,7 +1413,7 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
|
||||
|
||||
fn visit_trait_item(&mut self, item: &'hir TraitItem<'hir>) {
|
||||
if associated_body(Node::TraitItem(item)).is_some() {
|
||||
self.body_owners.push(item.def_id.def_id);
|
||||
self.body_owners.push(item.owner_id.def_id);
|
||||
}
|
||||
|
||||
self.trait_items.push(item.trait_item_id());
|
||||
@ -1422,7 +1422,7 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
|
||||
|
||||
fn visit_impl_item(&mut self, item: &'hir ImplItem<'hir>) {
|
||||
if associated_body(Node::ImplItem(item)).is_some() {
|
||||
self.body_owners.push(item.def_id.def_id);
|
||||
self.body_owners.push(item.owner_id.def_id);
|
||||
}
|
||||
|
||||
self.impl_items.push(item.impl_item_id());
|
||||
|
@ -67,10 +67,10 @@ impl ModuleItems {
|
||||
pub fn definitions(&self) -> impl Iterator<Item = LocalDefId> + '_ {
|
||||
self.items
|
||||
.iter()
|
||||
.map(|id| id.def_id.def_id)
|
||||
.chain(self.trait_items.iter().map(|id| id.def_id.def_id))
|
||||
.chain(self.impl_items.iter().map(|id| id.def_id.def_id))
|
||||
.chain(self.foreign_items.iter().map(|id| id.def_id.def_id))
|
||||
.map(|id| id.owner_id.def_id)
|
||||
.chain(self.trait_items.iter().map(|id| id.owner_id.def_id))
|
||||
.chain(self.impl_items.iter().map(|id| id.owner_id.def_id))
|
||||
.chain(self.foreign_items.iter().map(|id| id.owner_id.def_id))
|
||||
}
|
||||
|
||||
pub fn par_items(&self, f: impl Fn(ItemId) + Send + Sync) {
|
||||
|
@ -81,7 +81,7 @@ impl<'tcx> MonoItem<'tcx> {
|
||||
MonoItem::Fn(instance) => tcx.symbol_name(instance),
|
||||
MonoItem::Static(def_id) => tcx.symbol_name(Instance::mono(tcx, def_id)),
|
||||
MonoItem::GlobalAsm(item_id) => {
|
||||
SymbolName::new(tcx, &format!("global_asm_{:?}", item_id.def_id))
|
||||
SymbolName::new(tcx, &format!("global_asm_{:?}", item_id.owner_id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ impl<'tcx> MonoItem<'tcx> {
|
||||
match *self {
|
||||
MonoItem::Fn(Instance { def, .. }) => def.def_id().as_local(),
|
||||
MonoItem::Static(def_id) => def_id.as_local(),
|
||||
MonoItem::GlobalAsm(item_id) => Some(item_id.def_id.def_id),
|
||||
MonoItem::GlobalAsm(item_id) => Some(item_id.owner_id.def_id),
|
||||
}
|
||||
.map(|def_id| tcx.def_span(def_id))
|
||||
}
|
||||
@ -373,7 +373,7 @@ impl<'tcx> CodegenUnit<'tcx> {
|
||||
}
|
||||
}
|
||||
MonoItem::Static(def_id) => def_id.as_local().map(Idx::index),
|
||||
MonoItem::GlobalAsm(item_id) => Some(item_id.def_id.def_id.index()),
|
||||
MonoItem::GlobalAsm(item_id) => Some(item_id.owner_id.def_id.index()),
|
||||
},
|
||||
item.symbol_name(tcx),
|
||||
)
|
||||
|
@ -872,9 +872,9 @@ fn foo(&self) -> Self::T { String::new() }
|
||||
// FIXME: account for returning some type in a trait fn impl that has
|
||||
// an assoc type as a return type (#72076).
|
||||
if let hir::Defaultness::Default { has_value: true } =
|
||||
self.impl_defaultness(item.id.def_id)
|
||||
self.impl_defaultness(item.id.owner_id)
|
||||
{
|
||||
if self.type_of(item.id.def_id) == found {
|
||||
if self.type_of(item.id.owner_id) == found {
|
||||
diag.span_label(
|
||||
item.span,
|
||||
"associated type defaults can't be assumed inside the \
|
||||
@ -894,7 +894,7 @@ fn foo(&self) -> Self::T { String::new() }
|
||||
})) => {
|
||||
for item in &items[..] {
|
||||
if let hir::AssocItemKind::Type = item.kind {
|
||||
if self.type_of(item.id.def_id) == found {
|
||||
if self.type_of(item.id.owner_id) == found {
|
||||
diag.span_label(item.span, "expected this associated type");
|
||||
return true;
|
||||
}
|
||||
|
@ -2740,7 +2740,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
|
||||
// Iterate all local crate items no matter where they are defined.
|
||||
let hir = tcx.hir();
|
||||
for id in hir.items() {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::Use) {
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Use) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2749,7 +2749,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
|
||||
continue;
|
||||
}
|
||||
|
||||
let def_id = item.def_id.to_def_id();
|
||||
let def_id = item.owner_id.to_def_id();
|
||||
let ns = tcx.def_kind(def_id).ns().unwrap_or(Namespace::TypeNS);
|
||||
collect_fn(&item.ident, ns, def_id);
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -2062,7 +2062,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
||||
// so this lets us continue to run them while maintaining backwards compatibility.
|
||||
// In the long run, the checks should be harmonized.
|
||||
if let ItemKind::Macro(ref macro_def, _) = item.kind {
|
||||
let def_id = item.def_id.to_def_id();
|
||||
let def_id = item.owner_id.to_def_id();
|
||||
if macro_def.macro_rules && !self.tcx.has_attr(def_id, sym::macro_export) {
|
||||
check_non_exported_macro_for_invalid_attrs(self.tcx, item);
|
||||
}
|
||||
|
@ -280,8 +280,8 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_node(&mut self, node: Node<'tcx>) {
|
||||
if let Node::ImplItem(hir::ImplItem { def_id, .. }) = node
|
||||
&& self.should_ignore_item(def_id.to_def_id())
|
||||
if let Node::ImplItem(hir::ImplItem { owner_id, .. }) = node
|
||||
&& self.should_ignore_item(owner_id.to_def_id())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -293,7 +293,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
||||
match node {
|
||||
Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
|
||||
let def = self.tcx.adt_def(item.def_id);
|
||||
let def = self.tcx.adt_def(item.owner_id);
|
||||
self.repr_has_repr_c = def.repr().c();
|
||||
self.repr_has_repr_simd = def.repr().simd();
|
||||
|
||||
@ -306,7 +306,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
Node::ImplItem(impl_item) => {
|
||||
let item = self.tcx.local_parent(impl_item.def_id.def_id);
|
||||
let item = self.tcx.local_parent(impl_item.owner_id.def_id);
|
||||
if self.tcx.impl_trait_ref(item).is_none() {
|
||||
//// If it's a type whose items are live, then it's live, too.
|
||||
//// This is done to handle the case where, for example, the static
|
||||
@ -517,10 +517,10 @@ fn check_item<'tcx>(
|
||||
) {
|
||||
let allow_dead_code = has_allow_dead_code_or_lang_attr(tcx, id.hir_id());
|
||||
if allow_dead_code {
|
||||
worklist.push(id.def_id.def_id);
|
||||
worklist.push(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
match tcx.def_kind(id.def_id) {
|
||||
match tcx.def_kind(id.owner_id) {
|
||||
DefKind::Enum => {
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::Enum(ref enum_def, _) = item.kind {
|
||||
@ -540,15 +540,15 @@ fn check_item<'tcx>(
|
||||
}
|
||||
}
|
||||
DefKind::Impl => {
|
||||
let of_trait = tcx.impl_trait_ref(id.def_id);
|
||||
let of_trait = tcx.impl_trait_ref(id.owner_id);
|
||||
|
||||
if of_trait.is_some() {
|
||||
worklist.push(id.def_id.def_id);
|
||||
worklist.push(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
// get DefIds from another query
|
||||
let local_def_ids = tcx
|
||||
.associated_item_def_ids(id.def_id)
|
||||
.associated_item_def_ids(id.owner_id)
|
||||
.iter()
|
||||
.filter_map(|def_id| def_id.as_local());
|
||||
|
||||
@ -566,12 +566,12 @@ fn check_item<'tcx>(
|
||||
if let hir::ItemKind::Struct(ref variant_data, _) = item.kind
|
||||
&& let Some(ctor_hir_id) = variant_data.ctor_hir_id()
|
||||
{
|
||||
struct_constructors.insert(tcx.hir().local_def_id(ctor_hir_id), item.def_id.def_id);
|
||||
struct_constructors.insert(tcx.hir().local_def_id(ctor_hir_id), item.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
DefKind::GlobalAsm => {
|
||||
// global_asm! is always live.
|
||||
worklist.push(id.def_id.def_id);
|
||||
worklist.push(id.owner_id.def_id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@ -579,12 +579,12 @@ fn check_item<'tcx>(
|
||||
|
||||
fn check_trait_item<'tcx>(tcx: TyCtxt<'tcx>, worklist: &mut Vec<LocalDefId>, id: hir::TraitItemId) {
|
||||
use hir::TraitItemKind::{Const, Fn};
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::AssocConst | DefKind::AssocFn) {
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::AssocConst | DefKind::AssocFn) {
|
||||
let trait_item = tcx.hir().trait_item(id);
|
||||
if matches!(trait_item.kind, Const(_, Some(_)) | Fn(_, hir::TraitFn::Provided(_)))
|
||||
&& has_allow_dead_code_or_lang_attr(tcx, trait_item.hir_id())
|
||||
{
|
||||
worklist.push(trait_item.def_id.def_id);
|
||||
worklist.push(trait_item.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -594,10 +594,10 @@ fn check_foreign_item<'tcx>(
|
||||
worklist: &mut Vec<LocalDefId>,
|
||||
id: hir::ForeignItemId,
|
||||
) {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::Static(_) | DefKind::Fn)
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Static(_) | DefKind::Fn)
|
||||
&& has_allow_dead_code_or_lang_attr(tcx, id.hir_id())
|
||||
{
|
||||
worklist.push(id.def_id.def_id);
|
||||
worklist.push(id.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -861,19 +861,19 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
|
||||
let module_items = tcx.hir_module_items(module);
|
||||
|
||||
for item in module_items.items() {
|
||||
if !live_symbols.contains(&item.def_id.def_id) {
|
||||
let parent = tcx.local_parent(item.def_id.def_id);
|
||||
if !live_symbols.contains(&item.owner_id.def_id) {
|
||||
let parent = tcx.local_parent(item.owner_id.def_id);
|
||||
if parent != module && !live_symbols.contains(&parent) {
|
||||
// We already have diagnosed something.
|
||||
continue;
|
||||
}
|
||||
visitor.check_definition(item.def_id.def_id);
|
||||
visitor.check_definition(item.owner_id.def_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
let def_kind = tcx.def_kind(item.def_id);
|
||||
let def_kind = tcx.def_kind(item.owner_id);
|
||||
if let DefKind::Struct | DefKind::Union | DefKind::Enum = def_kind {
|
||||
let adt = tcx.adt_def(item.def_id);
|
||||
let adt = tcx.adt_def(item.owner_id);
|
||||
let mut dead_variants = Vec::new();
|
||||
|
||||
for variant in adt.variants() {
|
||||
@ -917,7 +917,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
|
||||
}
|
||||
|
||||
visitor.warn_dead_fields_and_variants(
|
||||
item.def_id.def_id,
|
||||
item.owner_id.def_id,
|
||||
"constructed",
|
||||
dead_variants,
|
||||
false,
|
||||
@ -926,11 +926,11 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
|
||||
}
|
||||
|
||||
for impl_item in module_items.impl_items() {
|
||||
visitor.check_definition(impl_item.def_id.def_id);
|
||||
visitor.check_definition(impl_item.owner_id.def_id);
|
||||
}
|
||||
|
||||
for foreign_item in module_items.foreign_items() {
|
||||
visitor.check_definition(foreign_item.def_id.def_id);
|
||||
visitor.check_definition(foreign_item.owner_id.def_id);
|
||||
}
|
||||
|
||||
// We do not warn trait items.
|
||||
|
@ -73,19 +73,19 @@ fn diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> DiagnosticItems
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
observe_item(tcx, &mut diagnostic_items, id.def_id.def_id);
|
||||
observe_item(tcx, &mut diagnostic_items, id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.trait_items() {
|
||||
observe_item(tcx, &mut diagnostic_items, id.def_id.def_id);
|
||||
observe_item(tcx, &mut diagnostic_items, id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.impl_items() {
|
||||
observe_item(tcx, &mut diagnostic_items, id.def_id.def_id);
|
||||
observe_item(tcx, &mut diagnostic_items, id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.foreign_items() {
|
||||
observe_item(tcx, &mut diagnostic_items, id.def_id.def_id);
|
||||
observe_item(tcx, &mut diagnostic_items, id.owner_id.def_id);
|
||||
}
|
||||
|
||||
diagnostic_items
|
||||
|
@ -62,7 +62,7 @@ fn entry_point_type(ctxt: &EntryContext<'_>, id: ItemId, at_root: bool) -> Entry
|
||||
} else if ctxt.tcx.sess.contains_name(attrs, sym::rustc_main) {
|
||||
EntryPointType::RustcMainAttr
|
||||
} else {
|
||||
if let Some(name) = ctxt.tcx.opt_item_name(id.def_id.to_def_id())
|
||||
if let Some(name) = ctxt.tcx.opt_item_name(id.owner_id.to_def_id())
|
||||
&& name == sym::main {
|
||||
if at_root {
|
||||
// This is a top-level function so can be `main`.
|
||||
@ -82,7 +82,7 @@ fn attr_span_by_symbol(ctxt: &EntryContext<'_>, id: ItemId, sym: Symbol) -> Opti
|
||||
}
|
||||
|
||||
fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
|
||||
let at_root = ctxt.tcx.opt_local_parent(id.def_id.def_id) == Some(CRATE_DEF_ID);
|
||||
let at_root = ctxt.tcx.opt_local_parent(id.owner_id.def_id) == Some(CRATE_DEF_ID);
|
||||
|
||||
match entry_point_type(ctxt, id, at_root) {
|
||||
EntryPointType::None => {
|
||||
@ -90,7 +90,7 @@ fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
|
||||
ctxt.tcx.sess.emit_err(AttrOnlyOnMain { span, attr: sym::unix_sigpipe });
|
||||
}
|
||||
}
|
||||
_ if !matches!(ctxt.tcx.def_kind(id.def_id), DefKind::Fn) => {
|
||||
_ if !matches!(ctxt.tcx.def_kind(id.owner_id), DefKind::Fn) => {
|
||||
for attr in [sym::start, sym::rustc_main] {
|
||||
if let Some(span) = attr_span_by_symbol(ctxt, id, attr) {
|
||||
ctxt.tcx.sess.emit_err(AttrOnlyInFunctions { span, attr });
|
||||
@ -102,16 +102,16 @@ fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
|
||||
if let Some(span) = attr_span_by_symbol(ctxt, id, sym::unix_sigpipe) {
|
||||
ctxt.tcx.sess.emit_err(AttrOnlyOnRootMain { span, attr: sym::unix_sigpipe });
|
||||
}
|
||||
ctxt.non_main_fns.push(ctxt.tcx.def_span(id.def_id));
|
||||
ctxt.non_main_fns.push(ctxt.tcx.def_span(id.owner_id));
|
||||
}
|
||||
EntryPointType::RustcMainAttr => {
|
||||
if ctxt.attr_main_fn.is_none() {
|
||||
ctxt.attr_main_fn = Some((id.def_id.def_id, ctxt.tcx.def_span(id.def_id)));
|
||||
ctxt.attr_main_fn = Some((id.owner_id.def_id, ctxt.tcx.def_span(id.owner_id)));
|
||||
} else {
|
||||
ctxt.tcx.sess.emit_err(MultipleRustcMain {
|
||||
span: ctxt.tcx.def_span(id.def_id.to_def_id()),
|
||||
span: ctxt.tcx.def_span(id.owner_id.to_def_id()),
|
||||
first: ctxt.attr_main_fn.unwrap().1,
|
||||
additional: ctxt.tcx.def_span(id.def_id.to_def_id()),
|
||||
additional: ctxt.tcx.def_span(id.owner_id.to_def_id()),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -120,11 +120,11 @@ fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
|
||||
ctxt.tcx.sess.emit_err(AttrOnlyOnMain { span, attr: sym::unix_sigpipe });
|
||||
}
|
||||
if ctxt.start_fn.is_none() {
|
||||
ctxt.start_fn = Some((id.def_id.def_id, ctxt.tcx.def_span(id.def_id)));
|
||||
ctxt.start_fn = Some((id.owner_id.def_id, ctxt.tcx.def_span(id.owner_id)));
|
||||
} else {
|
||||
ctxt.tcx.sess.emit_err(MultipleStartFunctions {
|
||||
span: ctxt.tcx.def_span(id.def_id),
|
||||
labeled: ctxt.tcx.def_span(id.def_id.to_def_id()),
|
||||
span: ctxt.tcx.def_span(id.owner_id),
|
||||
labeled: ctxt.tcx.def_span(id.owner_id.to_def_id()),
|
||||
previous: ctxt.start_fn.unwrap().1,
|
||||
});
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
|
||||
|
||||
fn visit_item(&mut self, i: &'hir hir::Item<'hir>) {
|
||||
let mut inner_visitor = self.new_visitor(self.hir_map);
|
||||
inner_visitor.check(i.def_id, |this| intravisit::walk_item(this, i));
|
||||
inner_visitor.check(i.owner_id, |this| intravisit::walk_item(this, i));
|
||||
}
|
||||
|
||||
fn visit_id(&mut self, hir_id: HirId) {
|
||||
@ -148,16 +148,16 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
|
||||
|
||||
fn visit_foreign_item(&mut self, i: &'hir hir::ForeignItem<'hir>) {
|
||||
let mut inner_visitor = self.new_visitor(self.hir_map);
|
||||
inner_visitor.check(i.def_id, |this| intravisit::walk_foreign_item(this, i));
|
||||
inner_visitor.check(i.owner_id, |this| intravisit::walk_foreign_item(this, i));
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, i: &'hir hir::TraitItem<'hir>) {
|
||||
let mut inner_visitor = self.new_visitor(self.hir_map);
|
||||
inner_visitor.check(i.def_id, |this| intravisit::walk_trait_item(this, i));
|
||||
inner_visitor.check(i.owner_id, |this| intravisit::walk_trait_item(this, i));
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, i: &'hir hir::ImplItem<'hir>) {
|
||||
let mut inner_visitor = self.new_visitor(self.hir_map);
|
||||
inner_visitor.check(i.def_id, |this| intravisit::walk_impl_item(this, i));
|
||||
inner_visitor.check(i.owner_id, |this| intravisit::walk_impl_item(this, i));
|
||||
}
|
||||
}
|
||||
|
@ -217,9 +217,9 @@ fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems {
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
collector.check_for_lang(Target::from_def_kind(tcx.def_kind(id.def_id)), id.hir_id());
|
||||
collector.check_for_lang(Target::from_def_kind(tcx.def_kind(id.owner_id)), id.hir_id());
|
||||
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::Enum) {
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Enum) {
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::Enum(def, ..) = &item.kind {
|
||||
for variant in def.variants {
|
||||
|
@ -15,11 +15,11 @@ pub fn test_layout(tcx: TyCtxt<'_>) {
|
||||
// if the `rustc_attrs` feature is not enabled, don't bother testing layout
|
||||
for id in tcx.hir().items() {
|
||||
if matches!(
|
||||
tcx.def_kind(id.def_id),
|
||||
tcx.def_kind(id.owner_id),
|
||||
DefKind::TyAlias | DefKind::Enum | DefKind::Struct | DefKind::Union
|
||||
) {
|
||||
for attr in tcx.get_attrs(id.def_id.to_def_id(), sym::rustc_layout) {
|
||||
dump_layout_of(tcx, id.def_id.def_id, attr);
|
||||
for attr in tcx.get_attrs(id.owner_id.to_def_id(), sym::rustc_layout) {
|
||||
dump_layout_of(tcx, id.owner_id.def_id, attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'_>, item: &hir::Item<'_>, attrs: &CodegenF
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => true,
|
||||
hir::ItemKind::Impl { .. } | hir::ItemKind::Fn(..) => {
|
||||
let generics = tcx.generics_of(item.def_id);
|
||||
let generics = tcx.generics_of(item.owner_id);
|
||||
generics.requires_monomorphization(tcx)
|
||||
}
|
||||
_ => false,
|
||||
@ -42,7 +42,7 @@ fn method_might_be_inlined(
|
||||
impl_src: LocalDefId,
|
||||
) -> bool {
|
||||
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id().owner.to_def_id());
|
||||
let generics = tcx.generics_of(impl_item.def_id);
|
||||
let generics = tcx.generics_of(impl_item.owner_id);
|
||||
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
||||
return true;
|
||||
}
|
||||
@ -216,7 +216,7 @@ impl<'tcx> ReachableContext<'tcx> {
|
||||
if item_might_be_inlined(
|
||||
self.tcx,
|
||||
&item,
|
||||
self.tcx.codegen_fn_attrs(item.def_id),
|
||||
self.tcx.codegen_fn_attrs(item.owner_id),
|
||||
) {
|
||||
self.visit_nested_body(body);
|
||||
}
|
||||
@ -305,11 +305,11 @@ fn check_item<'tcx>(
|
||||
worklist: &mut Vec<LocalDefId>,
|
||||
effective_visibilities: &privacy::EffectiveVisibilities,
|
||||
) {
|
||||
if has_custom_linkage(tcx, id.def_id.def_id) {
|
||||
worklist.push(id.def_id.def_id);
|
||||
if has_custom_linkage(tcx, id.owner_id.def_id) {
|
||||
worklist.push(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
if !matches!(tcx.def_kind(id.def_id), DefKind::Impl) {
|
||||
if !matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -318,8 +318,8 @@ fn check_item<'tcx>(
|
||||
if let hir::ItemKind::Impl(hir::Impl { of_trait: Some(ref trait_ref), ref items, .. }) =
|
||||
item.kind
|
||||
{
|
||||
if !effective_visibilities.is_reachable(item.def_id.def_id) {
|
||||
worklist.extend(items.iter().map(|ii_ref| ii_ref.id.def_id.def_id));
|
||||
if !effective_visibilities.is_reachable(item.owner_id.def_id) {
|
||||
worklist.extend(items.iter().map(|ii_ref| ii_ref.id.owner_id.def_id));
|
||||
|
||||
let Res::Def(DefKind::Trait, trait_def_id) = trait_ref.path.res else {
|
||||
unreachable!();
|
||||
@ -403,8 +403,8 @@ fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> FxHashSet<LocalDefId> {
|
||||
}
|
||||
|
||||
for id in crate_items.impl_items() {
|
||||
if has_custom_linkage(tcx, id.def_id.def_id) {
|
||||
reachable_context.worklist.push(id.def_id.def_id);
|
||||
if has_custom_linkage(tcx, id.owner_id.def_id) {
|
||||
reachable_context.worklist.push(id.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
||||
}
|
||||
|
||||
self.annotate(
|
||||
i.def_id.def_id,
|
||||
i.owner_id.def_id,
|
||||
i.span,
|
||||
fn_sig,
|
||||
kind,
|
||||
@ -397,7 +397,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
||||
};
|
||||
|
||||
self.annotate(
|
||||
ti.def_id.def_id,
|
||||
ti.owner_id.def_id,
|
||||
ti.span,
|
||||
fn_sig,
|
||||
AnnotationKind::Required,
|
||||
@ -420,7 +420,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
||||
};
|
||||
|
||||
self.annotate(
|
||||
ii.def_id.def_id,
|
||||
ii.owner_id.def_id,
|
||||
ii.span,
|
||||
fn_sig,
|
||||
kind,
|
||||
@ -478,7 +478,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
||||
|
||||
fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) {
|
||||
self.annotate(
|
||||
i.def_id.def_id,
|
||||
i.owner_id.def_id,
|
||||
i.span,
|
||||
None,
|
||||
AnnotationKind::Required,
|
||||
@ -569,25 +569,25 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
|
||||
hir::ItemKind::Impl(hir::Impl { of_trait: None, .. })
|
||||
| hir::ItemKind::ForeignMod { .. }
|
||||
) {
|
||||
self.check_missing_stability(i.def_id.def_id, i.span);
|
||||
self.check_missing_stability(i.owner_id.def_id, i.span);
|
||||
}
|
||||
|
||||
// Ensure stable `const fn` have a const stability attribute.
|
||||
self.check_missing_const_stability(i.def_id.def_id, i.span);
|
||||
self.check_missing_const_stability(i.owner_id.def_id, i.span);
|
||||
|
||||
intravisit::walk_item(self, i)
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem<'tcx>) {
|
||||
self.check_missing_stability(ti.def_id.def_id, ti.span);
|
||||
self.check_missing_stability(ti.owner_id.def_id, ti.span);
|
||||
intravisit::walk_trait_item(self, ti);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) {
|
||||
let impl_def_id = self.tcx.hir().get_parent_item(ii.hir_id());
|
||||
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
|
||||
self.check_missing_stability(ii.def_id.def_id, ii.span);
|
||||
self.check_missing_const_stability(ii.def_id.def_id, ii.span);
|
||||
self.check_missing_stability(ii.owner_id.def_id, ii.span);
|
||||
self.check_missing_const_stability(ii.owner_id.def_id, ii.span);
|
||||
}
|
||||
intravisit::walk_impl_item(self, ii);
|
||||
}
|
||||
@ -606,7 +606,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) {
|
||||
self.check_missing_stability(i.def_id.def_id, i.span);
|
||||
self.check_missing_stability(i.owner_id.def_id, i.span);
|
||||
intravisit::walk_foreign_item(self, i);
|
||||
}
|
||||
// Note that we don't need to `check_missing_stability` for default generic parameters,
|
||||
@ -712,7 +712,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(cnum) = self.tcx.extern_mod_stmt_cnum(item.def_id.def_id) else {
|
||||
let Some(cnum) = self.tcx.extern_mod_stmt_cnum(item.owner_id.def_id) else {
|
||||
return;
|
||||
};
|
||||
let def_id = cnum.as_def_id();
|
||||
@ -765,7 +765,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
|
||||
}
|
||||
|
||||
for impl_item_ref in *items {
|
||||
let impl_item = self.tcx.associated_item(impl_item_ref.id.def_id);
|
||||
let impl_item = self.tcx.associated_item(impl_item_ref.id.owner_id);
|
||||
|
||||
if let Some(def_id) = impl_item.trait_item_def_id {
|
||||
// Pass `None` to skip deprecation warnings.
|
||||
|
@ -34,7 +34,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
|
||||
items.missing.push(item);
|
||||
}
|
||||
} else {
|
||||
let span = tcx.def_span(id.def_id);
|
||||
let span = tcx.def_span(id.owner_id);
|
||||
tcx.sess.emit_err(UnknownExternLangItem { span, lang_item });
|
||||
}
|
||||
}
|
||||
|
@ -505,9 +505,9 @@ impl<'tcx> EmbargoVisitor<'tcx> {
|
||||
fn update_macro_reachable_mod(&mut self, module_def_id: LocalDefId, defining_mod: LocalDefId) {
|
||||
let module = self.tcx.hir().get_module(module_def_id).0;
|
||||
for item_id in module.item_ids {
|
||||
let def_kind = self.tcx.def_kind(item_id.def_id);
|
||||
let vis = self.tcx.local_visibility(item_id.def_id.def_id);
|
||||
self.update_macro_reachable_def(item_id.def_id.def_id, def_kind, vis, defining_mod);
|
||||
let def_kind = self.tcx.def_kind(item_id.owner_id);
|
||||
let vis = self.tcx.local_visibility(item_id.owner_id.def_id);
|
||||
self.update_macro_reachable_def(item_id.owner_id.def_id, def_kind, vis, defining_mod);
|
||||
}
|
||||
if let Some(exports) = self.tcx.module_reexports(module_def_id) {
|
||||
for export in exports {
|
||||
@ -628,13 +628,13 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
let item_level = match item.kind {
|
||||
hir::ItemKind::Impl { .. } => {
|
||||
let impl_level = Option::<Level>::of_impl(
|
||||
item.def_id.def_id,
|
||||
item.owner_id.def_id,
|
||||
self.tcx,
|
||||
&self.effective_visibilities,
|
||||
);
|
||||
self.update(item.def_id.def_id, impl_level)
|
||||
self.update(item.owner_id.def_id, impl_level)
|
||||
}
|
||||
_ => self.get(item.def_id.def_id),
|
||||
_ => self.get(item.owner_id.def_id),
|
||||
};
|
||||
|
||||
// Update levels of nested things.
|
||||
@ -653,15 +653,15 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
hir::ItemKind::Impl(ref impl_) => {
|
||||
for impl_item_ref in impl_.items {
|
||||
if impl_.of_trait.is_some()
|
||||
|| self.tcx.visibility(impl_item_ref.id.def_id).is_public()
|
||||
|| self.tcx.visibility(impl_item_ref.id.owner_id).is_public()
|
||||
{
|
||||
self.update(impl_item_ref.id.def_id.def_id, item_level);
|
||||
self.update(impl_item_ref.id.owner_id.def_id, item_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Trait(.., trait_item_refs) => {
|
||||
for trait_item_ref in trait_item_refs {
|
||||
self.update(trait_item_ref.id.def_id.def_id, item_level);
|
||||
self.update(trait_item_ref.id.owner_id.def_id, item_level);
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Struct(ref def, _) | hir::ItemKind::Union(ref def, _) => {
|
||||
@ -677,12 +677,12 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Macro(ref macro_def, _) => {
|
||||
self.update_reachability_from_macro(item.def_id.def_id, macro_def);
|
||||
self.update_reachability_from_macro(item.owner_id.def_id, macro_def);
|
||||
}
|
||||
hir::ItemKind::ForeignMod { items, .. } => {
|
||||
for foreign_item in items {
|
||||
if self.tcx.visibility(foreign_item.id.def_id).is_public() {
|
||||
self.update(foreign_item.id.def_id.def_id, item_level);
|
||||
if self.tcx.visibility(foreign_item.id.owner_id).is_public() {
|
||||
self.update(foreign_item.id.owner_id.def_id, item_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -719,7 +719,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
// in the reachability pass (`middle/reachable.rs`). Types are marked as link-time
|
||||
// reachable if they are returned via `impl Trait`, even from private functions.
|
||||
let exist_level = cmp::max(item_level, Some(Level::ReachableThroughImplTrait));
|
||||
self.reach(item.def_id.def_id, exist_level).generics().predicates().ty();
|
||||
self.reach(item.owner_id.def_id, exist_level).generics().predicates().ty();
|
||||
}
|
||||
}
|
||||
// Visit everything.
|
||||
@ -728,20 +728,20 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
| hir::ItemKind::Fn(..)
|
||||
| hir::ItemKind::TyAlias(..) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.def_id.def_id, item_level).generics().predicates().ty();
|
||||
self.reach(item.owner_id.def_id, item_level).generics().predicates().ty();
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Trait(.., trait_item_refs) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.def_id.def_id, item_level).generics().predicates();
|
||||
self.reach(item.owner_id.def_id, item_level).generics().predicates();
|
||||
|
||||
for trait_item_ref in trait_item_refs {
|
||||
let tcx = self.tcx;
|
||||
let mut reach = self.reach(trait_item_ref.id.def_id.def_id, item_level);
|
||||
let mut reach = self.reach(trait_item_ref.id.owner_id.def_id, item_level);
|
||||
reach.generics().predicates();
|
||||
|
||||
if trait_item_ref.kind == AssocItemKind::Type
|
||||
&& !tcx.impl_defaultness(trait_item_ref.id.def_id).has_value()
|
||||
&& !tcx.impl_defaultness(trait_item_ref.id.owner_id).has_value()
|
||||
{
|
||||
// No type to visit.
|
||||
} else {
|
||||
@ -752,22 +752,22 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
}
|
||||
hir::ItemKind::TraitAlias(..) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.def_id.def_id, item_level).generics().predicates();
|
||||
self.reach(item.owner_id.def_id, item_level).generics().predicates();
|
||||
}
|
||||
}
|
||||
// Visit everything except for private impl items.
|
||||
hir::ItemKind::Impl(ref impl_) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.def_id.def_id, item_level)
|
||||
self.reach(item.owner_id.def_id, item_level)
|
||||
.generics()
|
||||
.predicates()
|
||||
.ty()
|
||||
.trait_ref();
|
||||
|
||||
for impl_item_ref in impl_.items {
|
||||
let impl_item_level = self.get(impl_item_ref.id.def_id.def_id);
|
||||
let impl_item_level = self.get(impl_item_ref.id.owner_id.def_id);
|
||||
if impl_item_level.is_some() {
|
||||
self.reach(impl_item_ref.id.def_id.def_id, impl_item_level)
|
||||
self.reach(impl_item_ref.id.owner_id.def_id, impl_item_level)
|
||||
.generics()
|
||||
.predicates()
|
||||
.ty();
|
||||
@ -779,7 +779,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
// Visit everything, but enum variants have their own levels.
|
||||
hir::ItemKind::Enum(ref def, _) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.def_id.def_id, item_level).generics().predicates();
|
||||
self.reach(item.owner_id.def_id, item_level).generics().predicates();
|
||||
}
|
||||
for variant in def.variants {
|
||||
let variant_level = self.get(self.tcx.hir().local_def_id(variant.id));
|
||||
@ -790,13 +790,13 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
}
|
||||
// Corner case: if the variant is reachable, but its
|
||||
// enum is not, make the enum reachable as well.
|
||||
self.reach(item.def_id.def_id, variant_level).ty();
|
||||
self.reach(item.owner_id.def_id, variant_level).ty();
|
||||
}
|
||||
if let Some(hir_id) = variant.data.ctor_hir_id() {
|
||||
let ctor_def_id = self.tcx.hir().local_def_id(hir_id);
|
||||
let ctor_level = self.get(ctor_def_id);
|
||||
if ctor_level.is_some() {
|
||||
self.reach(item.def_id.def_id, ctor_level).ty();
|
||||
self.reach(item.owner_id.def_id, ctor_level).ty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -804,9 +804,9 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
// Visit everything, but foreign items have their own levels.
|
||||
hir::ItemKind::ForeignMod { items, .. } => {
|
||||
for foreign_item in items {
|
||||
let foreign_item_level = self.get(foreign_item.id.def_id.def_id);
|
||||
let foreign_item_level = self.get(foreign_item.id.owner_id.def_id);
|
||||
if foreign_item_level.is_some() {
|
||||
self.reach(foreign_item.id.def_id.def_id, foreign_item_level)
|
||||
self.reach(foreign_item.id.owner_id.def_id, foreign_item_level)
|
||||
.generics()
|
||||
.predicates()
|
||||
.ty();
|
||||
@ -816,7 +816,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
// Visit everything except for private fields.
|
||||
hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.def_id.def_id, item_level).generics().predicates();
|
||||
self.reach(item.owner_id.def_id, item_level).generics().predicates();
|
||||
for field in struct_def.fields() {
|
||||
let def_id = self.tcx.hir().local_def_id(field.hir_id);
|
||||
let field_level = self.get(def_id);
|
||||
@ -829,7 +829,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
let ctor_def_id = self.tcx.hir().local_def_id(hir_id);
|
||||
let ctor_level = self.get(ctor_def_id);
|
||||
if ctor_level.is_some() {
|
||||
self.reach(item.def_id.def_id, ctor_level).ty();
|
||||
self.reach(item.owner_id.def_id, ctor_level).ty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -952,7 +952,7 @@ impl<'tcx, 'a> TestReachabilityVisitor<'tcx, 'a> {
|
||||
|
||||
impl<'tcx, 'a> Visitor<'tcx> for TestReachabilityVisitor<'tcx, 'a> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
self.effective_visibility_diagnostic(item.def_id.def_id);
|
||||
self.effective_visibility_diagnostic(item.owner_id.def_id);
|
||||
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(ref def, _) => {
|
||||
@ -976,13 +976,13 @@ impl<'tcx, 'a> Visitor<'tcx> for TestReachabilityVisitor<'tcx, 'a> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, item: &'tcx hir::TraitItem<'tcx>) {
|
||||
self.effective_visibility_diagnostic(item.def_id.def_id);
|
||||
self.effective_visibility_diagnostic(item.owner_id.def_id);
|
||||
}
|
||||
fn visit_impl_item(&mut self, item: &'tcx hir::ImplItem<'tcx>) {
|
||||
self.effective_visibility_diagnostic(item.def_id.def_id);
|
||||
self.effective_visibility_diagnostic(item.owner_id.def_id);
|
||||
}
|
||||
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
|
||||
self.effective_visibility_diagnostic(item.def_id.def_id);
|
||||
self.effective_visibility_diagnostic(item.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1065,7 +1065,7 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
let orig_current_item = mem::replace(&mut self.current_item, item.def_id.def_id);
|
||||
let orig_current_item = mem::replace(&mut self.current_item, item.owner_id.def_id);
|
||||
intravisit::walk_item(self, item);
|
||||
self.current_item = orig_current_item;
|
||||
}
|
||||
@ -1368,7 +1368,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
|
||||
|
||||
// Check types in item interfaces.
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
let orig_current_item = mem::replace(&mut self.current_item, item.def_id.def_id);
|
||||
let orig_current_item = mem::replace(&mut self.current_item, item.owner_id.def_id);
|
||||
let old_maybe_typeck_results = self.maybe_typeck_results.take();
|
||||
intravisit::walk_item(self, item);
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
@ -1512,7 +1512,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
hir::ItemKind::ForeignMod { .. } => {}
|
||||
|
||||
hir::ItemKind::Trait(.., bounds, _) => {
|
||||
if !self.trait_is_public(item.def_id.def_id) {
|
||||
if !self.trait_is_public(item.owner_id.def_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1574,7 +1574,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(..) | hir::ImplItemKind::Fn(..) => self
|
||||
.effective_visibilities
|
||||
.is_reachable(impl_item_ref.id.def_id.def_id),
|
||||
.is_reachable(impl_item_ref.id.owner_id.def_id),
|
||||
hir::ImplItemKind::Type(_) => false,
|
||||
}
|
||||
});
|
||||
@ -1593,7 +1593,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(..) | hir::ImplItemKind::Fn(..)
|
||||
if self.item_is_public(impl_item.def_id.def_id) =>
|
||||
if self.item_is_public(impl_item.owner_id.def_id) =>
|
||||
{
|
||||
intravisit::walk_impl_item(self, impl_item)
|
||||
}
|
||||
@ -1634,8 +1634,10 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
// methods will be visible as `Public::foo`.
|
||||
let mut found_pub_static = false;
|
||||
for impl_item_ref in impl_.items {
|
||||
if self.effective_visibilities.is_reachable(impl_item_ref.id.def_id.def_id)
|
||||
|| self.tcx.visibility(impl_item_ref.id.def_id).is_public()
|
||||
if self
|
||||
.effective_visibilities
|
||||
.is_reachable(impl_item_ref.id.owner_id.def_id)
|
||||
|| self.tcx.visibility(impl_item_ref.id.owner_id).is_public()
|
||||
{
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
match impl_item_ref.kind {
|
||||
@ -1663,7 +1665,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
hir::ItemKind::TyAlias(..) => return,
|
||||
|
||||
// Not at all public, so we don't care.
|
||||
_ if !self.item_is_public(item.def_id.def_id) => {
|
||||
_ if !self.item_is_public(item.owner_id.def_id) => {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1694,7 +1696,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
|
||||
if self.effective_visibilities.is_reachable(item.def_id.def_id) {
|
||||
if self.effective_visibilities.is_reachable(item.owner_id.def_id) {
|
||||
intravisit::walk_foreign_item(self, item)
|
||||
}
|
||||
}
|
||||
@ -1931,7 +1933,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx> {
|
||||
|
||||
pub fn check_item(&mut self, id: ItemId) {
|
||||
let tcx = self.tcx;
|
||||
let def_id = id.def_id.def_id;
|
||||
let def_id = id.owner_id.def_id;
|
||||
let item_visibility = tcx.local_visibility(def_id);
|
||||
let def_kind = tcx.def_kind(def_id);
|
||||
|
||||
@ -1947,17 +1949,17 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx> {
|
||||
DefKind::Trait => {
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::Trait(.., trait_item_refs) = item.kind {
|
||||
self.check(item.def_id.def_id, item_visibility).generics().predicates();
|
||||
self.check(item.owner_id.def_id, item_visibility).generics().predicates();
|
||||
|
||||
for trait_item_ref in trait_item_refs {
|
||||
self.check_assoc_item(
|
||||
trait_item_ref.id.def_id.def_id,
|
||||
trait_item_ref.id.owner_id.def_id,
|
||||
trait_item_ref.kind,
|
||||
item_visibility,
|
||||
);
|
||||
|
||||
if let AssocItemKind::Type = trait_item_ref.kind {
|
||||
self.check(trait_item_ref.id.def_id.def_id, item_visibility).bounds();
|
||||
self.check(trait_item_ref.id.owner_id.def_id, item_visibility).bounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1968,7 +1970,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx> {
|
||||
DefKind::Enum => {
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::Enum(ref def, _) = item.kind {
|
||||
self.check(item.def_id.def_id, item_visibility).generics().predicates();
|
||||
self.check(item.owner_id.def_id, item_visibility).generics().predicates();
|
||||
|
||||
for variant in def.variants {
|
||||
for field in variant.data.fields() {
|
||||
@ -1983,8 +1985,11 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx> {
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::ForeignMod { items, .. } = item.kind {
|
||||
for foreign_item in items {
|
||||
let vis = tcx.local_visibility(foreign_item.id.def_id.def_id);
|
||||
self.check(foreign_item.id.def_id.def_id, vis).generics().predicates().ty();
|
||||
let vis = tcx.local_visibility(foreign_item.id.owner_id.def_id);
|
||||
self.check(foreign_item.id.owner_id.def_id, vis)
|
||||
.generics()
|
||||
.predicates()
|
||||
.ty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1994,7 +1999,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx> {
|
||||
if let hir::ItemKind::Struct(ref struct_def, _)
|
||||
| hir::ItemKind::Union(ref struct_def, _) = item.kind
|
||||
{
|
||||
self.check(item.def_id.def_id, item_visibility).generics().predicates();
|
||||
self.check(item.owner_id.def_id, item_visibility).generics().predicates();
|
||||
|
||||
for field in struct_def.fields() {
|
||||
let def_id = tcx.hir().local_def_id(field.hir_id);
|
||||
@ -2011,20 +2016,24 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx> {
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::Impl(ref impl_) = item.kind {
|
||||
let impl_vis =
|
||||
ty::Visibility::of_impl(item.def_id.def_id, tcx, &Default::default());
|
||||
ty::Visibility::of_impl(item.owner_id.def_id, tcx, &Default::default());
|
||||
// check that private components do not appear in the generics or predicates of inherent impls
|
||||
// this check is intentionally NOT performed for impls of traits, per #90586
|
||||
if impl_.of_trait.is_none() {
|
||||
self.check(item.def_id.def_id, impl_vis).generics().predicates();
|
||||
self.check(item.owner_id.def_id, impl_vis).generics().predicates();
|
||||
}
|
||||
for impl_item_ref in impl_.items {
|
||||
let impl_item_vis = if impl_.of_trait.is_none() {
|
||||
min(tcx.local_visibility(impl_item_ref.id.def_id.def_id), impl_vis, tcx)
|
||||
min(
|
||||
tcx.local_visibility(impl_item_ref.id.owner_id.def_id),
|
||||
impl_vis,
|
||||
tcx,
|
||||
)
|
||||
} else {
|
||||
impl_vis
|
||||
};
|
||||
self.check_assoc_item(
|
||||
impl_item_ref.id.def_id.def_id,
|
||||
impl_item_ref.id.owner_id.def_id,
|
||||
impl_item_ref.kind,
|
||||
impl_item_vis,
|
||||
);
|
||||
|
@ -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(),
|
||||
}];
|
||||
|
@ -26,19 +26,19 @@ pub fn report_symbol_names(tcx: TyCtxt<'_>) {
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
symbol_names.process_attrs(id.def_id.def_id);
|
||||
symbol_names.process_attrs(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.trait_items() {
|
||||
symbol_names.process_attrs(id.def_id.def_id);
|
||||
symbol_names.process_attrs(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.impl_items() {
|
||||
symbol_names.process_attrs(id.def_id.def_id);
|
||||
symbol_names.process_attrs(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
for id in crate_items.foreign_items() {
|
||||
symbol_names.process_attrs(id.def_id.def_id);
|
||||
symbol_names.process_attrs(id.owner_id.def_id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -214,7 +214,9 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||
trait_ref, item, cause, pred
|
||||
);
|
||||
let (items, impl_def_id) = match item {
|
||||
Some(hir::Item { kind: hir::ItemKind::Impl(impl_), def_id, .. }) => (impl_.items, *def_id),
|
||||
Some(hir::Item { kind: hir::ItemKind::Impl(impl_), owner_id, .. }) => {
|
||||
(impl_.items, *owner_id)
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
let fix_span =
|
||||
@ -236,7 +238,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||
tcx.impl_item_implementor_ids(impl_def_id).get(&projection_ty.item_def_id)
|
||||
&& let Some(impl_item_span) = items
|
||||
.iter()
|
||||
.find(|item| item.id.def_id.to_def_id() == impl_item_id)
|
||||
.find(|item| item.id.owner_id.to_def_id() == impl_item_id)
|
||||
.map(fix_span)
|
||||
{
|
||||
cause.span = impl_item_span;
|
||||
@ -251,7 +253,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||
tcx.impl_item_implementor_ids(impl_def_id).get(&item_def_id)
|
||||
&& let Some(impl_item_span) = items
|
||||
.iter()
|
||||
.find(|item| item.id.def_id.to_def_id() == impl_item_id)
|
||||
.find(|item| item.id.owner_id.to_def_id() == impl_item_id)
|
||||
.map(fix_span)
|
||||
{
|
||||
cause.span = impl_item_span;
|
||||
|
@ -17,10 +17,10 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
||||
let item = tcx.hir().expect_item(def_id.expect_local());
|
||||
match item.kind {
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => tcx.arena.alloc_from_iter(
|
||||
trait_item_refs.iter().map(|trait_item_ref| trait_item_ref.id.def_id.to_def_id()),
|
||||
trait_item_refs.iter().map(|trait_item_ref| trait_item_ref.id.owner_id.to_def_id()),
|
||||
),
|
||||
hir::ItemKind::Impl(ref impl_) => tcx.arena.alloc_from_iter(
|
||||
impl_.items.iter().map(|impl_item_ref| impl_item_ref.id.def_id.to_def_id()),
|
||||
impl_.items.iter().map(|impl_item_ref| impl_item_ref.id.owner_id.to_def_id()),
|
||||
),
|
||||
hir::ItemKind::TraitAlias(..) => &[],
|
||||
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait"),
|
||||
@ -46,7 +46,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
match parent_item.kind {
|
||||
hir::ItemKind::Impl(ref impl_) => {
|
||||
if let Some(impl_item_ref) =
|
||||
impl_.items.iter().find(|i| i.id.def_id.to_def_id() == def_id)
|
||||
impl_.items.iter().find(|i| i.id.owner_id.to_def_id() == def_id)
|
||||
{
|
||||
let assoc_item = associated_item_from_impl_item_ref(impl_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
@ -56,7 +56,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
if let Some(trait_item_ref) =
|
||||
trait_item_refs.iter().find(|i| i.id.def_id.to_def_id() == def_id)
|
||||
trait_item_refs.iter().find(|i| i.id.owner_id.to_def_id() == def_id)
|
||||
{
|
||||
let assoc_item = associated_item_from_trait_item_ref(trait_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
@ -75,7 +75,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
}
|
||||
|
||||
fn associated_item_from_trait_item_ref(trait_item_ref: &hir::TraitItemRef) -> ty::AssocItem {
|
||||
let def_id = trait_item_ref.id.def_id;
|
||||
let owner_id = trait_item_ref.id.owner_id;
|
||||
let (kind, has_self) = match trait_item_ref.kind {
|
||||
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
|
||||
hir::AssocItemKind::Fn { has_self } => (ty::AssocKind::Fn, has_self),
|
||||
@ -85,15 +85,15 @@ fn associated_item_from_trait_item_ref(trait_item_ref: &hir::TraitItemRef) -> ty
|
||||
ty::AssocItem {
|
||||
name: trait_item_ref.ident.name,
|
||||
kind,
|
||||
def_id: def_id.to_def_id(),
|
||||
trait_item_def_id: Some(def_id.to_def_id()),
|
||||
def_id: owner_id.to_def_id(),
|
||||
trait_item_def_id: Some(owner_id.to_def_id()),
|
||||
container: ty::TraitContainer,
|
||||
fn_has_self_parameter: has_self,
|
||||
}
|
||||
}
|
||||
|
||||
fn associated_item_from_impl_item_ref(impl_item_ref: &hir::ImplItemRef) -> ty::AssocItem {
|
||||
let def_id = impl_item_ref.id.def_id;
|
||||
let def_id = impl_item_ref.id.owner_id;
|
||||
let (kind, has_self) = match impl_item_ref.kind {
|
||||
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
|
||||
hir::AssocItemKind::Fn { has_self } => (ty::AssocKind::Fn, has_self),
|
||||
|
@ -1042,7 +1042,7 @@ fn clean_poly_trait_ref<'tcx>(
|
||||
}
|
||||
|
||||
fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext<'tcx>) -> Item {
|
||||
let local_did = trait_item.def_id.to_def_id();
|
||||
let local_did = trait_item.owner_id.to_def_id();
|
||||
cx.with_param_env(local_did, |cx| {
|
||||
let inner = match trait_item.kind {
|
||||
hir::TraitItemKind::Const(ty, Some(default)) => AssocConstItem(
|
||||
@ -1094,7 +1094,7 @@ pub(crate) fn clean_impl_item<'tcx>(
|
||||
impl_: &hir::ImplItem<'tcx>,
|
||||
cx: &mut DocContext<'tcx>,
|
||||
) -> Item {
|
||||
let local_did = impl_.def_id.to_def_id();
|
||||
let local_did = impl_.owner_id.to_def_id();
|
||||
cx.with_param_env(local_did, |cx| {
|
||||
let inner = match impl_.kind {
|
||||
hir::ImplItemKind::Const(ty, expr) => {
|
||||
@ -1103,7 +1103,7 @@ pub(crate) fn clean_impl_item<'tcx>(
|
||||
}
|
||||
hir::ImplItemKind::Fn(ref sig, body) => {
|
||||
let m = clean_function(cx, sig, impl_.generics, body);
|
||||
let defaultness = cx.tcx.impl_defaultness(impl_.def_id);
|
||||
let defaultness = cx.tcx.impl_defaultness(impl_.owner_id);
|
||||
MethodItem(m, Some(defaultness))
|
||||
}
|
||||
hir::ImplItemKind::Type(hir_ty) => {
|
||||
@ -1120,7 +1120,7 @@ pub(crate) fn clean_impl_item<'tcx>(
|
||||
let mut what_rustc_thinks =
|
||||
Item::from_def_id_and_parts(local_did, Some(impl_.ident.name), inner, cx);
|
||||
|
||||
let impl_ref = cx.tcx.impl_trait_ref(cx.tcx.local_parent(impl_.def_id.def_id));
|
||||
let impl_ref = cx.tcx.impl_trait_ref(cx.tcx.local_parent(impl_.owner_id.def_id));
|
||||
|
||||
// Trait impl items always inherit the impl's visibility --
|
||||
// we don't want to show `pub`.
|
||||
@ -1958,7 +1958,7 @@ fn clean_maybe_renamed_item<'tcx>(
|
||||
) -> Vec<Item> {
|
||||
use hir::ItemKind;
|
||||
|
||||
let def_id = item.def_id.to_def_id();
|
||||
let def_id = item.owner_id.to_def_id();
|
||||
let mut name = renamed.unwrap_or_else(|| cx.tcx.hir().name(item.hir_id()));
|
||||
cx.with_param_env(def_id, |cx| {
|
||||
let kind = match item.kind {
|
||||
@ -2100,11 +2100,11 @@ fn clean_extern_crate<'tcx>(
|
||||
cx: &mut DocContext<'tcx>,
|
||||
) -> Vec<Item> {
|
||||
// this is the ID of the `extern crate` statement
|
||||
let cnum = cx.tcx.extern_mod_stmt_cnum(krate.def_id.def_id).unwrap_or(LOCAL_CRATE);
|
||||
let cnum = cx.tcx.extern_mod_stmt_cnum(krate.owner_id.def_id).unwrap_or(LOCAL_CRATE);
|
||||
// this is the ID of the crate itself
|
||||
let crate_def_id = cnum.as_def_id();
|
||||
let attrs = cx.tcx.hir().attrs(krate.hir_id());
|
||||
let ty_vis = cx.tcx.visibility(krate.def_id);
|
||||
let ty_vis = cx.tcx.visibility(krate.owner_id);
|
||||
let please_inline = ty_vis.is_public()
|
||||
&& attrs.iter().any(|a| {
|
||||
a.has_name(sym::doc)
|
||||
@ -2122,7 +2122,7 @@ fn clean_extern_crate<'tcx>(
|
||||
if let Some(items) = inline::try_inline(
|
||||
cx,
|
||||
cx.tcx.parent_module(krate.hir_id()).to_def_id(),
|
||||
Some(krate.def_id.to_def_id()),
|
||||
Some(krate.owner_id.to_def_id()),
|
||||
res,
|
||||
name,
|
||||
Some(attrs),
|
||||
@ -2158,11 +2158,11 @@ fn clean_use_statement<'tcx>(
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let visibility = cx.tcx.visibility(import.def_id);
|
||||
let visibility = cx.tcx.visibility(import.owner_id);
|
||||
let attrs = cx.tcx.hir().attrs(import.hir_id());
|
||||
let inline_attr = attrs.lists(sym::doc).get_word_attr(sym::inline);
|
||||
let pub_underscore = visibility.is_public() && name == kw::Underscore;
|
||||
let current_mod = cx.tcx.parent_module_from_def_id(import.def_id.def_id);
|
||||
let current_mod = cx.tcx.parent_module_from_def_id(import.owner_id.def_id);
|
||||
|
||||
// The parent of the module in which this import resides. This
|
||||
// is the same as `current_mod` if that's already the top
|
||||
@ -2233,7 +2233,7 @@ fn clean_use_statement<'tcx>(
|
||||
}
|
||||
if !denied {
|
||||
let mut visited = FxHashSet::default();
|
||||
let import_def_id = import.def_id.to_def_id();
|
||||
let import_def_id = import.owner_id.to_def_id();
|
||||
|
||||
if let Some(mut items) = inline::try_inline(
|
||||
cx,
|
||||
@ -2256,7 +2256,7 @@ fn clean_use_statement<'tcx>(
|
||||
Import::new_simple(name, resolve_use_source(cx, path), true)
|
||||
};
|
||||
|
||||
vec![Item::from_def_id_and_parts(import.def_id.to_def_id(), None, ImportItem(inner), cx)]
|
||||
vec![Item::from_def_id_and_parts(import.owner_id.to_def_id(), None, ImportItem(inner), cx)]
|
||||
}
|
||||
|
||||
fn clean_maybe_renamed_foreign_item<'tcx>(
|
||||
@ -2264,7 +2264,7 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
|
||||
item: &hir::ForeignItem<'tcx>,
|
||||
renamed: Option<Symbol>,
|
||||
) -> Item {
|
||||
let def_id = item.def_id.to_def_id();
|
||||
let def_id = item.owner_id.to_def_id();
|
||||
cx.with_param_env(def_id, |cx| {
|
||||
let kind = match item.kind {
|
||||
hir::ForeignItemKind::Fn(decl, names, generics) => {
|
||||
|
@ -240,13 +240,13 @@ impl ExternalCrate {
|
||||
let item = tcx.hir().item(id);
|
||||
match item.kind {
|
||||
hir::ItemKind::Mod(_) => {
|
||||
as_keyword(Res::Def(DefKind::Mod, id.def_id.to_def_id()))
|
||||
as_keyword(Res::Def(DefKind::Mod, id.owner_id.to_def_id()))
|
||||
}
|
||||
hir::ItemKind::Use(path, hir::UseKind::Single)
|
||||
if tcx.visibility(id.def_id).is_public() =>
|
||||
if tcx.visibility(id.owner_id).is_public() =>
|
||||
{
|
||||
as_keyword(path.res.expect_non_local())
|
||||
.map(|(_, prim)| (id.def_id.to_def_id(), prim))
|
||||
.map(|(_, prim)| (id.owner_id.to_def_id(), prim))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
@ -308,14 +308,14 @@ impl ExternalCrate {
|
||||
let item = tcx.hir().item(id);
|
||||
match item.kind {
|
||||
hir::ItemKind::Mod(_) => {
|
||||
as_primitive(Res::Def(DefKind::Mod, id.def_id.to_def_id()))
|
||||
as_primitive(Res::Def(DefKind::Mod, id.owner_id.to_def_id()))
|
||||
}
|
||||
hir::ItemKind::Use(path, hir::UseKind::Single)
|
||||
if tcx.visibility(id.def_id).is_public() =>
|
||||
if tcx.visibility(id.owner_id).is_public() =>
|
||||
{
|
||||
as_primitive(path.res.expect_non_local()).map(|(_, prim)| {
|
||||
// Pretend the primitive is local.
|
||||
(id.def_id.to_def_id(), prim)
|
||||
(id.owner_id.to_def_id(), prim)
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
|
@ -295,11 +295,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
debug!("visiting item {:?}", item);
|
||||
let name = renamed.unwrap_or(item.ident.name);
|
||||
|
||||
let def_id = item.def_id.to_def_id();
|
||||
let def_id = item.owner_id.to_def_id();
|
||||
let is_pub = self.cx.tcx.visibility(def_id).is_public();
|
||||
|
||||
if is_pub {
|
||||
self.store_path(item.def_id.to_def_id());
|
||||
self.store_path(item.owner_id.to_def_id());
|
||||
}
|
||||
|
||||
match item.kind {
|
||||
@ -360,7 +360,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
// 3. We're inlining, since a reexport where inlining has been requested
|
||||
// should be inlined even if it is also documented at the top level.
|
||||
|
||||
let def_id = item.def_id.to_def_id();
|
||||
let def_id = item.owner_id.to_def_id();
|
||||
let is_macro_2_0 = !macro_def.macro_rules;
|
||||
let nonexported = !self.cx.tcx.has_attr(def_id, sym::macro_export);
|
||||
|
||||
@ -405,7 +405,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
om: &mut Module<'tcx>,
|
||||
) {
|
||||
// If inlining we only want to include public functions.
|
||||
if !self.inlining || self.cx.tcx.visibility(item.def_id).is_public() {
|
||||
if !self.inlining || self.cx.tcx.visibility(item.owner_id).is_public() {
|
||||
om.foreigns.push((item, renamed));
|
||||
}
|
||||
}
|
||||
|
@ -69,25 +69,25 @@ impl rustc_driver::Callbacks for CompilerCalls {
|
||||
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
for id in crate_items.items() {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::Fn) {
|
||||
bodies.push(id.def_id);
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Fn) {
|
||||
bodies.push(id.owner_id);
|
||||
}
|
||||
}
|
||||
|
||||
for id in crate_items.trait_items() {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::AssocFn) {
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::AssocFn) {
|
||||
let trait_item = hir.trait_item(id);
|
||||
if let rustc_hir::TraitItemKind::Fn(_, trait_fn) = &trait_item.kind {
|
||||
if let rustc_hir::TraitFn::Provided(_) = trait_fn {
|
||||
bodies.push(trait_item.def_id);
|
||||
bodies.push(trait_item.owner_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for id in crate_items.impl_items() {
|
||||
if matches!(tcx.def_kind(id.def_id), DefKind::AssocFn) {
|
||||
bodies.push(id.def_id);
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::AssocFn) {
|
||||
bodies.push(id.owner_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for CopyIterator {
|
||||
of_trait: Some(ref trait_ref),
|
||||
..
|
||||
}) = item.kind;
|
||||
let ty = cx.tcx.type_of(item.def_id);
|
||||
let ty = cx.tcx.type_of(item.owner_id);
|
||||
if is_copy(cx, ty);
|
||||
if let Some(trait_id) = trait_ref.trait_def_id();
|
||||
if cx.tcx.is_diagnostic_item(sym::Iterator, trait_id);
|
||||
|
@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation {
|
||||
None,
|
||||
&format!(
|
||||
"consider annotating `{}` with `#[repr(C)]` to explicitly specify memory layout",
|
||||
cx.tcx.def_path_str(item.def_id.to_def_id())
|
||||
cx.tcx.def_path_str(item.owner_id.to_def_id())
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -715,47 +715,47 @@ fn walk_parents<'tcx>(
|
||||
},
|
||||
Node::Item(&Item {
|
||||
kind: ItemKind::Static(..) | ItemKind::Const(..),
|
||||
def_id,
|
||||
owner_id,
|
||||
span,
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&TraitItem {
|
||||
kind: TraitItemKind::Const(..),
|
||||
def_id,
|
||||
owner_id,
|
||||
span,
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&ImplItem {
|
||||
kind: ImplItemKind::Const(..),
|
||||
def_id,
|
||||
owner_id,
|
||||
span,
|
||||
..
|
||||
}) if span.ctxt() == ctxt => {
|
||||
let ty = cx.tcx.type_of(def_id.def_id);
|
||||
let ty = cx.tcx.type_of(owner_id.def_id);
|
||||
Some(ty_auto_deref_stability(cx, ty, precedence).position_for_result(cx))
|
||||
},
|
||||
|
||||
Node::Item(&Item {
|
||||
kind: ItemKind::Fn(..),
|
||||
def_id,
|
||||
owner_id,
|
||||
span,
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&TraitItem {
|
||||
kind: TraitItemKind::Fn(..),
|
||||
def_id,
|
||||
owner_id,
|
||||
span,
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&ImplItem {
|
||||
kind: ImplItemKind::Fn(..),
|
||||
def_id,
|
||||
owner_id,
|
||||
span,
|
||||
..
|
||||
}) if span.ctxt() == ctxt => {
|
||||
let output = cx
|
||||
.tcx
|
||||
.erase_late_bound_regions(cx.tcx.fn_sig(def_id.to_def_id()).output());
|
||||
.erase_late_bound_regions(cx.tcx.fn_sig(owner_id.to_def_id()).output());
|
||||
Some(ty_auto_deref_stability(cx, output, precedence).position_for_result(cx))
|
||||
},
|
||||
|
||||
|
@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
|
||||
self_ty,
|
||||
..
|
||||
}) = item.kind;
|
||||
if !cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
|
||||
if !cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
|
||||
if !item.span.from_expansion();
|
||||
if let Some(def_id) = trait_ref.trait_def_id();
|
||||
if cx.tcx.is_diagnostic_item(sym::Default, def_id);
|
||||
@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
|
||||
if let Some(Node::ImplItem(impl_item)) = cx.tcx.hir().find(impl_item_hir);
|
||||
if let ImplItemKind::Fn(_, b) = &impl_item.kind;
|
||||
if let Body { value: func_expr, .. } = cx.tcx.hir().body(*b);
|
||||
if let Some(adt_def) = cx.tcx.type_of(item.def_id).ty_adt_def();
|
||||
if let Some(adt_def) = cx.tcx.type_of(item.owner_id).ty_adt_def();
|
||||
if let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
if !attrs.iter().any(|attr| attr.doc_str().is_some());
|
||||
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);
|
||||
|
@ -210,8 +210,8 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
|
||||
..
|
||||
}) = item.kind
|
||||
{
|
||||
let ty = cx.tcx.type_of(item.def_id);
|
||||
let is_automatically_derived = cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
|
||||
let ty = cx.tcx.type_of(item.owner_id);
|
||||
let is_automatically_derived = cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
|
||||
|
||||
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
|
||||
check_ord_partial_ord(cx, item.span, trait_ref, ty, is_automatically_derived);
|
||||
|
@ -257,17 +257,17 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
|
||||
let headers = check_attrs(cx, &self.valid_idents, attrs);
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(ref sig, _, body_id) => {
|
||||
if !(is_entrypoint_fn(cx, item.def_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
|
||||
if !(is_entrypoint_fn(cx, item.owner_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
|
||||
let body = cx.tcx.hir().body(body_id);
|
||||
let mut fpu = FindPanicUnwrap {
|
||||
cx,
|
||||
typeck_results: cx.tcx.typeck(item.def_id.def_id),
|
||||
typeck_results: cx.tcx.typeck(item.owner_id.def_id),
|
||||
panic_span: None,
|
||||
};
|
||||
fpu.visit_expr(body.value);
|
||||
lint_for_missing_headers(
|
||||
cx,
|
||||
item.def_id.def_id,
|
||||
item.owner_id.def_id,
|
||||
item.span,
|
||||
sig,
|
||||
headers,
|
||||
@ -304,7 +304,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
|
||||
let headers = check_attrs(cx, &self.valid_idents, attrs);
|
||||
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
|
||||
if !in_external_macro(cx.tcx.sess, item.span) {
|
||||
lint_for_missing_headers(cx, item.def_id.def_id, item.span, sig, headers, None, None);
|
||||
lint_for_missing_headers(cx, item.owner_id.def_id, item.span, sig, headers, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -319,13 +319,13 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
|
||||
let body = cx.tcx.hir().body(body_id);
|
||||
let mut fpu = FindPanicUnwrap {
|
||||
cx,
|
||||
typeck_results: cx.tcx.typeck(item.def_id.def_id),
|
||||
typeck_results: cx.tcx.typeck(item.owner_id.def_id),
|
||||
panic_span: None,
|
||||
};
|
||||
fpu.visit_expr(body.value);
|
||||
lint_for_missing_headers(
|
||||
cx,
|
||||
item.def_id.def_id,
|
||||
item.owner_id.def_id,
|
||||
item.span,
|
||||
sig,
|
||||
headers,
|
||||
|
@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for EmptyEnum {
|
||||
}
|
||||
|
||||
if let ItemKind::Enum(..) = item.kind {
|
||||
let ty = cx.tcx.type_of(item.def_id);
|
||||
let ty = cx.tcx.type_of(item.owner_id);
|
||||
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
|
||||
if adt.variants().is_empty() {
|
||||
span_lint_and_help(
|
||||
|
@ -265,7 +265,7 @@ impl LateLintPass<'_> for EnumVariantNames {
|
||||
}
|
||||
// The `module_name_repetitions` lint should only trigger if the item has the module in its
|
||||
// name. Having the same name is accepted.
|
||||
if cx.tcx.visibility(item.def_id).is_public() && item_camel.len() > mod_camel.len() {
|
||||
if cx.tcx.visibility(item.owner_id).is_public() && item_camel.len() > mod_camel.len() {
|
||||
let matching = count_match_start(mod_camel, &item_camel);
|
||||
let rmatching = count_match_end(mod_camel, &item_camel);
|
||||
let nchars = mod_camel.chars().count();
|
||||
@ -296,7 +296,7 @@ impl LateLintPass<'_> for EnumVariantNames {
|
||||
}
|
||||
}
|
||||
if let ItemKind::Enum(ref def, _) = item.kind {
|
||||
if !(self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(item.def_id.def_id)) {
|
||||
if !(self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(item.owner_id.def_id)) {
|
||||
check_variant(cx, self.threshold, def, item_name, item.span);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
|
||||
// be sure we have `self` parameter in this function
|
||||
if trait_item.kind == (AssocItemKind::Fn { has_self: true }) {
|
||||
trait_self_ty = Some(
|
||||
TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id())
|
||||
TraitRef::identity(cx.tcx, trait_item.id.owner_id.to_def_id())
|
||||
.self_ty()
|
||||
.skip_binder(),
|
||||
);
|
||||
|
@ -73,7 +73,7 @@ impl LateLintPass<'_> for ExhaustiveItems {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
|
||||
if_chain! {
|
||||
if let ItemKind::Enum(..) | ItemKind::Struct(..) = item.kind;
|
||||
if cx.effective_visibilities.is_exported(item.def_id.def_id);
|
||||
if cx.effective_visibilities.is_exported(item.owner_id.def_id);
|
||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
if !attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
|
||||
then {
|
||||
|
@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for FallibleImplFrom {
|
||||
// check for `impl From<???> for ..`
|
||||
if_chain! {
|
||||
if let hir::ItemKind::Impl(impl_) = &item.kind;
|
||||
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(item.def_id);
|
||||
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(item.owner_id);
|
||||
if cx.tcx.is_diagnostic_item(sym::From, impl_trait_ref.def_id);
|
||||
then {
|
||||
lint_impl_body(cx, item.span, impl_.items);
|
||||
@ -107,7 +107,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h
|
||||
let body = cx.tcx.hir().body(body_id);
|
||||
let mut fpu = FindPanicUnwrap {
|
||||
lcx: cx,
|
||||
typeck_results: cx.tcx.typeck(impl_item.id.def_id.def_id),
|
||||
typeck_results: cx.tcx.typeck(impl_item.id.owner_id.def_id),
|
||||
result: Vec::new(),
|
||||
};
|
||||
fpu.visit_expr(body.value);
|
||||
|
@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for FromOverInto {
|
||||
&& let Some(into_trait_seg) = hir_trait_ref.path.segments.last()
|
||||
// `impl Into<target_ty> for self_ty`
|
||||
&& let Some(GenericArgs { args: [GenericArg::Type(target_ty)], .. }) = into_trait_seg.args
|
||||
&& let Some(middle_trait_ref) = cx.tcx.impl_trait_ref(item.def_id)
|
||||
&& let Some(middle_trait_ref) = cx.tcx.impl_trait_ref(item.owner_id)
|
||||
&& cx.tcx.is_diagnostic_item(sym::Into, middle_trait_ref.def_id)
|
||||
{
|
||||
span_lint_and_then(
|
||||
|
@ -22,9 +22,9 @@ use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
|
||||
|
||||
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
|
||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
|
||||
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
|
||||
if let hir::ItemKind::Fn(ref sig, _generics, ref body_id) = item.kind {
|
||||
let is_public = cx.effective_visibilities.is_exported(item.def_id.def_id);
|
||||
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
|
||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
||||
if let Some(attr) = attr {
|
||||
check_needless_must_use(cx, sig.decl, item.hir_id(), item.span, fn_header_span, attr);
|
||||
@ -34,7 +34,7 @@ pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>
|
||||
sig.decl,
|
||||
cx.tcx.hir().body(*body_id),
|
||||
item.span,
|
||||
item.def_id.def_id,
|
||||
item.owner_id.def_id,
|
||||
item.span.with_hi(sig.decl.output.span().hi()),
|
||||
"this function could have a `#[must_use]` attribute",
|
||||
);
|
||||
@ -44,20 +44,20 @@ pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>
|
||||
|
||||
pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
|
||||
if let hir::ImplItemKind::Fn(ref sig, ref body_id) = item.kind {
|
||||
let is_public = cx.effective_visibilities.is_exported(item.def_id.def_id);
|
||||
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
|
||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
|
||||
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
|
||||
if let Some(attr) = attr {
|
||||
check_needless_must_use(cx, sig.decl, item.hir_id(), item.span, fn_header_span, attr);
|
||||
} else if is_public && !is_proc_macro(cx.sess(), attrs) && trait_ref_of_method(cx, item.def_id.def_id).is_none()
|
||||
} else if is_public && !is_proc_macro(cx.sess(), attrs) && trait_ref_of_method(cx, item.owner_id.def_id).is_none()
|
||||
{
|
||||
check_must_use_candidate(
|
||||
cx,
|
||||
sig.decl,
|
||||
cx.tcx.hir().body(*body_id),
|
||||
item.span,
|
||||
item.def_id.def_id,
|
||||
item.owner_id.def_id,
|
||||
item.span.with_hi(sig.decl.output.span().hi()),
|
||||
"this method could have a `#[must_use]` attribute",
|
||||
);
|
||||
@ -67,11 +67,11 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
|
||||
|
||||
pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
|
||||
if let hir::TraitItemKind::Fn(ref sig, ref eid) = item.kind {
|
||||
let is_public = cx.effective_visibilities.is_exported(item.def_id.def_id);
|
||||
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
|
||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
||||
|
||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
|
||||
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
|
||||
if let Some(attr) = attr {
|
||||
check_needless_must_use(cx, sig.decl, item.hir_id(), item.span, fn_header_span, attr);
|
||||
} else if let hir::TraitFn::Provided(eid) = *eid {
|
||||
@ -82,7 +82,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
|
||||
sig.decl,
|
||||
body,
|
||||
item.span,
|
||||
item.def_id.def_id,
|
||||
item.owner_id.def_id,
|
||||
item.span.with_hi(sig.decl.output.span().hi()),
|
||||
"this method could have a `#[must_use]` attribute",
|
||||
);
|
||||
|
@ -31,7 +31,7 @@ pub(super) fn check_fn<'tcx>(
|
||||
pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
|
||||
if let hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(eid)) = item.kind {
|
||||
let body = cx.tcx.hir().body(eid);
|
||||
check_raw_ptr(cx, sig.header.unsafety, sig.decl, body, item.def_id.def_id);
|
||||
check_raw_ptr(cx, sig.header.unsafety, sig.decl, body, item.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,9 @@ fn result_err_ty<'tcx>(
|
||||
|
||||
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &hir::Item<'tcx>, large_err_threshold: u64) {
|
||||
if let hir::ItemKind::Fn(ref sig, _generics, _) = item.kind
|
||||
&& let Some((hir_ty, err_ty)) = result_err_ty(cx, sig.decl, item.def_id.def_id, item.span)
|
||||
&& let Some((hir_ty, err_ty)) = result_err_ty(cx, sig.decl, item.owner_id.def_id, item.span)
|
||||
{
|
||||
if cx.effective_visibilities.is_exported(item.def_id.def_id) {
|
||||
if cx.effective_visibilities.is_exported(item.owner_id.def_id) {
|
||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
||||
check_result_unit_err(cx, err_ty, fn_header_span);
|
||||
}
|
||||
@ -47,10 +47,10 @@ pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &hir::Item<'tcx>, l
|
||||
pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &hir::ImplItem<'tcx>, large_err_threshold: u64) {
|
||||
// Don't lint if method is a trait's implementation, we can't do anything about those
|
||||
if let hir::ImplItemKind::Fn(ref sig, _) = item.kind
|
||||
&& let Some((hir_ty, err_ty)) = result_err_ty(cx, sig.decl, item.def_id.def_id, item.span)
|
||||
&& trait_ref_of_method(cx, item.def_id.def_id).is_none()
|
||||
&& let Some((hir_ty, err_ty)) = result_err_ty(cx, sig.decl, item.owner_id.def_id, item.span)
|
||||
&& trait_ref_of_method(cx, item.owner_id.def_id).is_none()
|
||||
{
|
||||
if cx.effective_visibilities.is_exported(item.def_id.def_id) {
|
||||
if cx.effective_visibilities.is_exported(item.owner_id.def_id) {
|
||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
||||
check_result_unit_err(cx, err_ty, fn_header_span);
|
||||
}
|
||||
@ -61,8 +61,8 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &hir::ImplItem
|
||||
pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &hir::TraitItem<'tcx>, large_err_threshold: u64) {
|
||||
if let hir::TraitItemKind::Fn(ref sig, _) = item.kind {
|
||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
||||
if let Some((hir_ty, err_ty)) = result_err_ty(cx, sig.decl, item.def_id.def_id, item.span) {
|
||||
if cx.effective_visibilities.is_exported(item.def_id.def_id) {
|
||||
if let Some((hir_ty, err_ty)) = result_err_ty(cx, sig.decl, item.owner_id.def_id, item.span) {
|
||||
if cx.effective_visibilities.is_exported(item.owner_id.def_id) {
|
||||
check_result_unit_err(cx, err_ty, fn_header_span);
|
||||
}
|
||||
check_result_large_err(cx, err_ty, hir_ty.span, large_err_threshold);
|
||||
|
@ -111,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
|
||||
}
|
||||
}
|
||||
|
||||
if !cx.effective_visibilities.is_exported(item.def_id.def_id) {
|
||||
if !cx.effective_visibilities.is_exported(item.owner_id.def_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
|
||||
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::String);
|
||||
|
||||
// Filters instances of to_string which are required by a trait
|
||||
if trait_ref_of_method(cx, impl_item.def_id.def_id).is_none();
|
||||
if trait_ref_of_method(cx, impl_item.owner_id.def_id).is_none();
|
||||
|
||||
then {
|
||||
show_lint(cx, impl_item);
|
||||
@ -124,7 +124,7 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
|
||||
.expect("Failed to get trait ID of `Display`!");
|
||||
|
||||
// Get the real type of 'self'
|
||||
let self_type = cx.tcx.fn_sig(item.def_id).input(0);
|
||||
let self_type = cx.tcx.fn_sig(item.owner_id).input(0);
|
||||
let self_type = self_type.skip_binder().peel_refs();
|
||||
|
||||
// Emit either a warning or an error
|
||||
|
@ -44,7 +44,7 @@ impl<'tcx> LateLintPass<'tcx> for IterNotReturningIterator {
|
||||
let name = item.ident.name.as_str();
|
||||
if matches!(name, "iter" | "iter_mut") {
|
||||
if let TraitItemKind::Fn(fn_sig, _) = &item.kind {
|
||||
check_sig(cx, name, fn_sig, item.def_id.def_id);
|
||||
check_sig(cx, name, fn_sig, item.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for IterNotReturningIterator {
|
||||
)
|
||||
{
|
||||
if let ImplItemKind::Fn(fn_sig, _) = &item.kind {
|
||||
check_sig(cx, name, fn_sig, item.def_id.def_id);
|
||||
check_sig(cx, name, fn_sig, item.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
|
||||
return;
|
||||
}
|
||||
if let ItemKind::Enum(ref def, _) = item.kind {
|
||||
let ty = cx.tcx.type_of(item.def_id);
|
||||
let ty = cx.tcx.type_of(item.owner_id);
|
||||
let Adt(adt, subst) = ty.kind() else {
|
||||
panic!("already checked whether this is an enum")
|
||||
};
|
||||
|
@ -134,7 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
|
||||
if item.ident.name == sym::len;
|
||||
if let ImplItemKind::Fn(sig, _) = &item.kind;
|
||||
if sig.decl.implicit_self.has_implicit_self();
|
||||
if cx.effective_visibilities.is_exported(item.def_id.def_id);
|
||||
if cx.effective_visibilities.is_exported(item.owner_id.def_id);
|
||||
if matches!(sig.decl.output, FnRetTy::Return(_));
|
||||
if let Some(imp) = get_parent_as_impl(cx.tcx, item.hir_id());
|
||||
if imp.of_trait.is_none();
|
||||
@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
|
||||
if let Some(local_id) = ty_id.as_local();
|
||||
let ty_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id);
|
||||
if !is_lint_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id);
|
||||
if let Some(output) = parse_len_output(cx, cx.tcx.fn_sig(item.def_id).skip_binder());
|
||||
if let Some(output) = parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).skip_binder());
|
||||
then {
|
||||
let (name, kind) = match cx.tcx.hir().find(ty_hir_id) {
|
||||
Some(Node::ForeignItem(x)) => (x.ident.name, "extern type"),
|
||||
@ -195,7 +195,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
|
||||
fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: Symbol) -> bool {
|
||||
item.ident.name == name
|
||||
&& if let AssocItemKind::Fn { has_self } = item.kind {
|
||||
has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1 }
|
||||
has_self && { cx.tcx.fn_sig(item.id.owner_id).inputs().skip_binder().len() == 1 }
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@ -210,11 +210,11 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
|
||||
}
|
||||
}
|
||||
|
||||
if cx.effective_visibilities.is_exported(visited_trait.def_id.def_id)
|
||||
if cx.effective_visibilities.is_exported(visited_trait.owner_id.def_id)
|
||||
&& trait_items.iter().any(|i| is_named_self(cx, i, sym::len))
|
||||
{
|
||||
let mut current_and_super_traits = DefIdSet::default();
|
||||
fill_trait_set(visited_trait.def_id.to_def_id(), &mut current_and_super_traits, cx);
|
||||
fill_trait_set(visited_trait.owner_id.to_def_id(), &mut current_and_super_traits, cx);
|
||||
let is_empty = sym!(is_empty);
|
||||
|
||||
let is_empty_method_found = current_and_super_traits
|
||||
|
@ -102,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for Lifetimes {
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
|
||||
if let ImplItemKind::Fn(ref sig, id) = item.kind {
|
||||
let report_extra_lifetimes = trait_ref_of_method(cx, item.def_id.def_id).is_none();
|
||||
let report_extra_lifetimes = trait_ref_of_method(cx, item.owner_id.def_id).is_none();
|
||||
check_fn_inner(
|
||||
cx,
|
||||
sig.decl,
|
||||
|
@ -166,7 +166,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum {
|
||||
if let Some((id, span)) = iter.next()
|
||||
&& iter.next().is_none()
|
||||
{
|
||||
self.potential_enums.push((item.def_id.def_id, id, item.span, span));
|
||||
self.potential_enums.push((item.owner_id.def_id, id, item.span, span));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3250,15 +3250,15 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
let name = impl_item.ident.name.as_str();
|
||||
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
|
||||
let item = cx.tcx.hir().expect_item(parent);
|
||||
let self_ty = cx.tcx.type_of(item.def_id);
|
||||
let self_ty = cx.tcx.type_of(item.owner_id);
|
||||
|
||||
let implements_trait = matches!(item.kind, hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }));
|
||||
if let hir::ImplItemKind::Fn(ref sig, id) = impl_item.kind {
|
||||
let method_sig = cx.tcx.fn_sig(impl_item.def_id);
|
||||
let method_sig = cx.tcx.fn_sig(impl_item.owner_id);
|
||||
let method_sig = cx.tcx.erase_late_bound_regions(method_sig);
|
||||
let first_arg_ty_opt = method_sig.inputs().iter().next().copied();
|
||||
// if this impl block implements a trait, lint in trait definition instead
|
||||
if !implements_trait && cx.effective_visibilities.is_exported(impl_item.def_id.def_id) {
|
||||
if !implements_trait && cx.effective_visibilities.is_exported(impl_item.owner_id.def_id) {
|
||||
// check missing trait implementations
|
||||
for method_config in &TRAIT_METHODS {
|
||||
if name == method_config.method_name
|
||||
@ -3292,7 +3292,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
|
||||
if sig.decl.implicit_self.has_implicit_self()
|
||||
&& !(self.avoid_breaking_exported_api
|
||||
&& cx.effective_visibilities.is_exported(impl_item.def_id.def_id))
|
||||
&& cx.effective_visibilities.is_exported(impl_item.owner_id.def_id))
|
||||
&& let Some(first_arg) = iter_input_pats(sig.decl, cx.tcx.hir().body(id)).next()
|
||||
&& let Some(first_arg_ty) = first_arg_ty_opt
|
||||
{
|
||||
@ -3370,7 +3370,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
then {
|
||||
let first_arg_span = first_arg_ty.span;
|
||||
let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty);
|
||||
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id())
|
||||
let self_ty = TraitRef::identity(cx.tcx, item.owner_id.to_def_id())
|
||||
.self_ty()
|
||||
.skip_binder();
|
||||
wrong_self_convention::check(
|
||||
@ -3389,7 +3389,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
if item.ident.name == sym::new;
|
||||
if let TraitItemKind::Fn(_, _) = item.kind;
|
||||
let ret_ty = return_ty(cx, item.hir_id());
|
||||
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id())
|
||||
let self_ty = TraitRef::identity(cx.tcx, item.owner_id.to_def_id())
|
||||
.self_ty()
|
||||
.skip_binder();
|
||||
if !ret_ty.contains(self_ty);
|
||||
|
@ -131,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
hir::ItemKind::Fn(..) => {
|
||||
// ignore main()
|
||||
if it.ident.name == sym::main {
|
||||
let at_root = cx.tcx.local_parent(it.def_id.def_id) == CRATE_DEF_ID;
|
||||
let at_root = cx.tcx.local_parent(it.owner_id.def_id) == CRATE_DEF_ID;
|
||||
if at_root {
|
||||
return;
|
||||
}
|
||||
@ -155,7 +155,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
| hir::ItemKind::Use(..) => 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());
|
||||
|
||||
let attrs = cx.tcx.hir().attrs(it.hir_id());
|
||||
if !is_from_proc_macro(cx, it) {
|
||||
@ -164,7 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx 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());
|
||||
|
||||
let attrs = cx.tcx.hir().attrs(trait_item.hir_id());
|
||||
if !is_from_proc_macro(cx, trait_item) {
|
||||
@ -174,7 +174,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
|
||||
// If the method is an impl for a trait, don't doc.
|
||||
if let Some(cid) = cx.tcx.associated_item(impl_item.def_id).impl_container(cx.tcx) {
|
||||
if let Some(cid) = cx.tcx.associated_item(impl_item.owner_id).impl_container(cx.tcx) {
|
||||
if cx.tcx.impl_trait_ref(cid).is_some() {
|
||||
return;
|
||||
}
|
||||
@ -182,7 +182,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
return;
|
||||
}
|
||||
|
||||
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
|
||||
let (article, desc) = cx.tcx.article_and_description(impl_item.owner_id.to_def_id());
|
||||
let attrs = cx.tcx.hir().attrs(impl_item.hir_id());
|
||||
if !is_from_proc_macro(cx, impl_item) {
|
||||
self.check_missing_docs_attrs(cx, attrs, impl_item.span, article, desc);
|
||||
|
@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
return;
|
||||
}
|
||||
|
||||
if !cx.effective_visibilities.is_exported(it.def_id.def_id) {
|
||||
if !cx.effective_visibilities.is_exported(it.owner_id.def_id) {
|
||||
return;
|
||||
}
|
||||
match it.kind {
|
||||
@ -105,7 +105,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
match tit_.kind {
|
||||
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
|
||||
hir::TraitItemKind::Fn(..) => {
|
||||
if cx.tcx.impl_defaultness(tit.id.def_id).has_value() {
|
||||
if cx.tcx.impl_defaultness(tit.id.owner_id).has_value() {
|
||||
// trait method with default body needs inline in case
|
||||
// an impl is not provided
|
||||
let desc = "a default trait method";
|
||||
@ -142,7 +142,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
}
|
||||
|
||||
// If the item being implemented is not exported, then we don't need #[inline]
|
||||
if !cx.effective_visibilities.is_exported(impl_item.def_id.def_id) {
|
||||
if !cx.effective_visibilities.is_exported(impl_item.owner_id.def_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
hir::ImplItemKind::Const(..) | hir::ImplItemKind::Type(_) => return,
|
||||
};
|
||||
|
||||
let assoc_item = cx.tcx.associated_item(impl_item.def_id);
|
||||
let assoc_item = cx.tcx.associated_item(impl_item.owner_id);
|
||||
let container_id = assoc_item.container_id(cx.tcx);
|
||||
let trait_def_id = match assoc_item.container {
|
||||
TraitContainer => Some(container_id),
|
||||
@ -159,7 +159,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
};
|
||||
|
||||
if let Some(trait_def_id) = trait_def_id {
|
||||
if trait_def_id.is_local() && !cx.effective_visibilities.is_exported(impl_item.def_id.def_id) {
|
||||
if trait_def_id.is_local() && !cx.effective_visibilities.is_exported(impl_item.owner_id.def_id) {
|
||||
// If a trait is being implemented for an item, and the
|
||||
// trait is not exported, we don't need #[inline]
|
||||
return;
|
||||
|
@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType {
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'tcx>) {
|
||||
if let hir::ImplItemKind::Fn(ref sig, ..) = item.kind {
|
||||
if trait_ref_of_method(cx, item.def_id.def_id).is_none() {
|
||||
if trait_ref_of_method(cx, item.owner_id.def_id).is_none() {
|
||||
check_sig(cx, item.hir_id(), sig.decl);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
|
||||
// can't be implemented for unsafe new
|
||||
return;
|
||||
}
|
||||
if cx.tcx.is_doc_hidden(impl_item.def_id.def_id) {
|
||||
if cx.tcx.is_doc_hidden(impl_item.owner_id.def_id) {
|
||||
// shouldn't be implemented when it is hidden in docs
|
||||
return;
|
||||
}
|
||||
@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
|
||||
if_chain! {
|
||||
if sig.decl.inputs.is_empty();
|
||||
if name == sym::new;
|
||||
if cx.effective_visibilities.is_reachable(impl_item.def_id.def_id);
|
||||
if cx.effective_visibilities.is_reachable(impl_item.owner_id.def_id);
|
||||
let self_def_id = cx.tcx.hir().get_parent_item(id);
|
||||
let self_ty = cx.tcx.type_of(self_def_id);
|
||||
if self_ty == return_ty(cx, id);
|
||||
|
@ -303,7 +303,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
|
||||
if let Some(of_trait_def_id) = of_trait_ref.trait_def_id();
|
||||
if let Some(of_assoc_item) = cx
|
||||
.tcx
|
||||
.associated_item(impl_item.def_id)
|
||||
.associated_item(impl_item.owner_id)
|
||||
.trait_item_def_id;
|
||||
if cx
|
||||
.tcx
|
||||
|
@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
|
||||
if let Some(trait_id) = trait_ref.trait_def_id();
|
||||
if send_trait == trait_id;
|
||||
if hir_impl.polarity == ImplPolarity::Positive;
|
||||
if let Some(ty_trait_ref) = cx.tcx.impl_trait_ref(item.def_id);
|
||||
if let Some(ty_trait_ref) = cx.tcx.impl_trait_ref(item.owner_id);
|
||||
if let self_ty = ty_trait_ref.self_ty();
|
||||
if let ty::Adt(adt_def, impl_trait_substs) = self_ty.kind();
|
||||
then {
|
||||
|
@ -227,25 +227,25 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
|
||||
// `skip_params` is either `0` or `1` to skip the `self` parameter in trait functions.
|
||||
// It can't be renamed, and it can't be removed without removing it from multiple functions.
|
||||
let (fn_id, fn_kind, skip_params) = match get_parent_node(cx.tcx, body.value.hir_id) {
|
||||
Some(Node::Item(i)) => (i.def_id.to_def_id(), FnKind::Fn, 0),
|
||||
Some(Node::Item(i)) => (i.owner_id.to_def_id(), FnKind::Fn, 0),
|
||||
Some(Node::TraitItem(&TraitItem {
|
||||
kind: TraitItemKind::Fn(ref sig, _),
|
||||
def_id,
|
||||
owner_id,
|
||||
..
|
||||
})) => (
|
||||
def_id.to_def_id(),
|
||||
owner_id.to_def_id(),
|
||||
FnKind::TraitFn,
|
||||
usize::from(sig.decl.implicit_self.has_implicit_self()),
|
||||
),
|
||||
Some(Node::ImplItem(&ImplItem {
|
||||
kind: ImplItemKind::Fn(ref sig, _),
|
||||
def_id,
|
||||
owner_id,
|
||||
..
|
||||
})) => {
|
||||
#[allow(trivial_casts)]
|
||||
if let Some(Node::Item(item)) = get_parent_node(cx.tcx, def_id.into())
|
||||
&& let Some(trait_ref) = cx.tcx.impl_trait_ref(item.def_id)
|
||||
&& let Some(trait_item_id) = cx.tcx.associated_item(def_id).trait_item_def_id
|
||||
if let Some(Node::Item(item)) = get_parent_node(cx.tcx, owner_id.into())
|
||||
&& let Some(trait_ref) = cx.tcx.impl_trait_ref(item.owner_id)
|
||||
&& let Some(trait_item_id) = cx.tcx.associated_item(owner_id).trait_item_def_id
|
||||
{
|
||||
(
|
||||
trait_item_id,
|
||||
@ -253,7 +253,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
|
||||
usize::from(sig.decl.implicit_self.has_implicit_self()),
|
||||
)
|
||||
} else {
|
||||
(def_id.to_def_id(), FnKind::Fn, 0)
|
||||
(owner_id.to_def_id(), FnKind::Fn, 0)
|
||||
}
|
||||
},
|
||||
_ => return,
|
||||
|
@ -204,7 +204,7 @@ fn are_equal<'tcx>(cx: &LateContext<'tcx>, middle_ty: Ty<'_>, hir_ty: &rustc_hir
|
||||
if let ty::Adt(adt_def, _) = middle_ty.kind();
|
||||
if let Some(local_did) = adt_def.did().as_local();
|
||||
let item = cx.tcx.hir().expect_item(local_did);
|
||||
let middle_ty_id = item.def_id.to_def_id();
|
||||
let middle_ty_id = item.owner_id.to_def_id();
|
||||
if let TyKind::Path(QPath::Resolved(_, path)) = hir_ty.kind;
|
||||
if let Res::Def(_, hir_ty_id) = path.res;
|
||||
|
||||
|
@ -36,7 +36,7 @@ impl<'tcx> LateLintPass<'tcx> for PartialEqNeImpl {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
|
||||
if_chain! {
|
||||
if let ItemKind::Impl(Impl { of_trait: Some(ref trait_ref), items: impl_items, .. }) = item.kind;
|
||||
if !cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
|
||||
if !cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
|
||||
if let Some(eq_trait) = cx.tcx.lang_items().eq_trait();
|
||||
if trait_ref.path.res.def_id() == eq_trait;
|
||||
then {
|
||||
|
@ -261,7 +261,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
|
||||
}
|
||||
|
||||
if let hir::TraitItemKind::Fn(method_sig, _) = &item.kind {
|
||||
self.check_poly_fn(cx, item.def_id.def_id, method_sig.decl, None);
|
||||
self.check_poly_fn(cx, item.owner_id.def_id, method_sig.decl, None);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||
check_mut_from_ref(cx, sig, None);
|
||||
for arg in check_fn_args(
|
||||
cx,
|
||||
cx.tcx.fn_sig(item.def_id).skip_binder().inputs(),
|
||||
cx.tcx.fn_sig(item.owner_id).skip_binder().inputs(),
|
||||
sig.decl.inputs,
|
||||
&[],
|
||||
)
|
||||
@ -188,7 +188,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||
let (item_id, sig, is_trait_item) = match parents.next() {
|
||||
Some((_, Node::Item(i))) => {
|
||||
if let ItemKind::Fn(sig, ..) = &i.kind {
|
||||
(i.def_id, sig, false)
|
||||
(i.owner_id, sig, false)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -200,14 +200,14 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||
return;
|
||||
}
|
||||
if let ImplItemKind::Fn(sig, _) = &i.kind {
|
||||
(i.def_id, sig, false)
|
||||
(i.owner_id, sig, false)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
},
|
||||
Some((_, Node::TraitItem(i))) => {
|
||||
if let TraitItemKind::Fn(sig, _) = &i.kind {
|
||||
(i.def_id, sig, true)
|
||||
(i.owner_id, sig, true)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -46,12 +46,12 @@ impl_lint_pass!(RedundantPubCrate => [REDUNDANT_PUB_CRATE]);
|
||||
impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
if_chain! {
|
||||
if cx.tcx.visibility(item.def_id.def_id) == ty::Visibility::Restricted(CRATE_DEF_ID.to_def_id());
|
||||
if !cx.effective_visibilities.is_exported(item.def_id.def_id) && self.is_exported.last() == Some(&false);
|
||||
if cx.tcx.visibility(item.owner_id.def_id) == ty::Visibility::Restricted(CRATE_DEF_ID.to_def_id());
|
||||
if !cx.effective_visibilities.is_exported(item.owner_id.def_id) && self.is_exported.last() == Some(&false);
|
||||
if is_not_macro_export(item);
|
||||
then {
|
||||
let span = item.span.with_hi(item.ident.span.hi());
|
||||
let descr = cx.tcx.def_kind(item.def_id).descr(item.def_id.to_def_id());
|
||||
let descr = cx.tcx.def_kind(item.owner_id).descr(item.owner_id.to_def_id());
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
REDUNDANT_PUB_CRATE,
|
||||
@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
|
||||
}
|
||||
|
||||
if let ItemKind::Mod { .. } = item.kind {
|
||||
self.is_exported.push(cx.effective_visibilities.is_exported(item.def_id.def_id));
|
||||
self.is_exported.push(cx.effective_visibilities.is_exported(item.owner_id.def_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for ReturnSelfNotMustUse {
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'tcx>) {
|
||||
if let TraitItemKind::Fn(ref sig, _) = item.kind {
|
||||
check_method(cx, sig.decl, item.def_id.def_id, item.span, item.hir_id());
|
||||
check_method(cx, sig.decl, item.owner_id.def_id, item.span, item.hir_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
|
||||
let mut map = FxHashMap::<Res, ExistingName>::default();
|
||||
|
||||
for id in cx.tcx.hir().items() {
|
||||
if matches!(cx.tcx.def_kind(id.def_id), DefKind::Impl)
|
||||
if matches!(cx.tcx.def_kind(id.owner_id), DefKind::Impl)
|
||||
&& let item = cx.tcx.hir().item(id)
|
||||
&& let ItemKind::Impl(Impl {
|
||||
items,
|
||||
|
@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors {
|
||||
|
||||
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
|
||||
let item = cx.tcx.hir().expect_item(parent);
|
||||
let self_ty = cx.tcx.type_of(item.def_id);
|
||||
let self_ty = cx.tcx.type_of(item.owner_id);
|
||||
let ret_ty = return_ty(cx, impl_item.hir_id());
|
||||
|
||||
// Do not check trait impls
|
||||
|
@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for TrailingEmptyArray {
|
||||
None,
|
||||
&format!(
|
||||
"consider annotating `{}` with `#[repr(C)]` or another `repr` attribute",
|
||||
cx.tcx.def_path_str(item.def_id.to_def_id())
|
||||
cx.tcx.def_path_str(item.owner_id.to_def_id())
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user