From 076a838cb097b68ffb8060c72c1e15eba76d0771 Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Wed, 12 Jul 2023 04:05:49 -0400 Subject: [PATCH] Use `LocalDefId` instead of `DefId` --- compiler/rustc_middle/src/ty/mod.rs | 4 ++-- compiler/rustc_resolve/src/build_reduced_graph.rs | 4 ++-- compiler/rustc_resolve/src/lib.rs | 4 ++-- compiler/rustc_restrictions/src/impl_restriction.rs | 7 ++----- compiler/rustc_restrictions/src/mut_restriction.rs | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e83c1540b2331..1bbaf0810091b 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -162,8 +162,8 @@ pub struct ResolverOutputs { #[derive(Debug)] pub struct ResolverGlobalCtxt { pub visibilities: FxHashMap, - pub impl_restrictions: FxHashMap, - pub mut_restrictions: FxHashMap, + pub impl_restrictions: FxHashMap, + pub mut_restrictions: FxHashMap, /// This field is used to decide whether we should make `PRIVATE_IN_PUBLIC` a hard error. pub has_pub_restricted: bool, /// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`. diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index ae8916d1347ff..45fc23828cd5a 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -887,7 +887,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> { ItemKind::Trait(ref trait_def) => { let impl_restriction = self.resolve_restriction(&trait_def.impl_restriction); - self.r.impl_restrictions.insert(def_id, impl_restriction); + self.r.impl_restrictions.insert(local_def_id, impl_restriction); // Add all the items within to a new module. let module = self.r.new_module( @@ -1562,7 +1562,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> { let vis = self.resolve_visibility(&sf.vis); self.r.visibilities.insert(self.r.local_def_id(sf.id), vis); let mut_restriction = self.resolve_restriction(&sf.mut_restriction); - self.r.mut_restrictions.insert(self.r.local_def_id(sf.id).to_def_id(), mut_restriction); + self.r.mut_restrictions.insert(self.r.local_def_id(sf.id), mut_restriction); visit::walk_field_def(self, sf); } } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index d02627fb2fa09..8865ca5e1cd12 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -982,9 +982,9 @@ pub struct Resolver<'a, 'tcx> { visibilities: FxHashMap, has_pub_restricted: bool, /// trait def -> restriction scope - impl_restrictions: FxHashMap, + impl_restrictions: FxHashMap, /// field def -> restriction scope - mut_restrictions: FxHashMap, + mut_restrictions: FxHashMap, used_imports: FxHashSet, maybe_unused_trait_imports: FxIndexSet, diff --git a/compiler/rustc_restrictions/src/impl_restriction.rs b/compiler/rustc_restrictions/src/impl_restriction.rs index a2a5934211e96..7bd4bf3502f6f 100644 --- a/compiler/rustc_restrictions/src/impl_restriction.rs +++ b/compiler/rustc_restrictions/src/impl_restriction.rs @@ -43,11 +43,8 @@ impl<'v> Visitor<'v> for ImplOfRestrictedTraitVisitor<'v> { } } -fn impl_restriction( - tcx: TyCtxt<'_>, - def_id: LocalDefId, -) -> ty::ImplRestriction { - match tcx.resolutions(()).impl_restrictions.get(&def_id.to_def_id()) { +fn impl_restriction(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::ImplRestriction { + match tcx.resolutions(()).impl_restrictions.get(&def_id) { Some(restriction) => *restriction, None => bug!("impl restriction not found for {def_id:?}"), } diff --git a/compiler/rustc_restrictions/src/mut_restriction.rs b/compiler/rustc_restrictions/src/mut_restriction.rs index 14681e1b4b45e..661feef4099f3 100644 --- a/compiler/rustc_restrictions/src/mut_restriction.rs +++ b/compiler/rustc_restrictions/src/mut_restriction.rs @@ -23,7 +23,7 @@ pub(crate) fn provide(providers: &mut Providers) { fn mut_restriction(tcx: TyCtxt<'_>, def_id: LocalDefId) -> MutRestriction { tracing::debug!("mut_restriction({def_id:?})"); - match tcx.resolutions(()).mut_restrictions.get(&def_id.to_def_id()) { + match tcx.resolutions(()).mut_restrictions.get(&def_id) { Some(restriction) => *restriction, None => span_bug!(tcx.def_span(def_id), "mut restriction not found for {def_id:?}"), }