From 3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:43 +0200 Subject: Merging upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_middle/src/hir/mod.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'compiler/rustc_middle/src/hir/mod.rs') diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index dedc65f4c..c9da711e5 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -64,13 +64,17 @@ impl ModuleItems { self.foreign_items.iter().copied() } - pub fn definitions(&self) -> impl Iterator + '_ { + pub fn owners(&self) -> impl Iterator + '_ { self.items .iter() - .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)) + .map(|id| id.owner_id) + .chain(self.trait_items.iter().map(|id| id.owner_id)) + .chain(self.impl_items.iter().map(|id| id.owner_id)) + .chain(self.foreign_items.iter().map(|id| id.owner_id)) + } + + pub fn definitions(&self) -> impl Iterator + '_ { + self.owners().map(|id| id.def_id) } pub fn par_items(&self, f: impl Fn(ItemId) + Send + Sync) { @@ -104,7 +108,7 @@ impl<'tcx> TyCtxt<'tcx> { self.impl_trait_ref(def_id) .map(|t| t.subst_identity()) .map(ImplSubject::Trait) - .unwrap_or_else(|| ImplSubject::Inherent(self.type_of(def_id))) + .unwrap_or_else(|| ImplSubject::Inherent(self.type_of(def_id).subst_identity())) } } @@ -121,13 +125,13 @@ pub fn provide(providers: &mut Providers) { let node = owner.node(); Some(Owner { node, hash_without_bodies: owner.nodes.hash_without_bodies }) }; - providers.local_def_id_to_hir_id = |tcx, id| { + providers.opt_local_def_id_to_hir_id = |tcx, id| { let owner = tcx.hir_crate(()).owners[id].map(|_| ()); - match owner { + Some(match owner { MaybeOwner::Owner(_) => HirId::make_owner(id), MaybeOwner::Phantom => bug!("No HirId for {:?}", id), MaybeOwner::NonOwner(hir_id) => hir_id, - } + }) }; providers.hir_owner_nodes = |tcx, id| tcx.hir_crate(()).owners[id.def_id].map(|i| &i.nodes); providers.hir_owner_parent = |tcx, id| { @@ -173,6 +177,7 @@ pub fn provide(providers: &mut Providers) { } }; providers.opt_def_kind = |tcx, def_id| tcx.hir().opt_def_kind(def_id.expect_local()); + providers.opt_rpitit_info = |_, _| None; providers.all_local_trait_impls = |tcx, ()| &tcx.resolutions(()).trait_impls; providers.expn_that_defined = |tcx, id| { let id = id.expect_local(); -- cgit v1.2.3