Skip to content

Commit

Permalink
Use LocalDefId instead of DefId
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Jul 15, 2023
1 parent c4c73cd commit 076a838
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ pub struct ResolverOutputs {
#[derive(Debug)]
pub struct ResolverGlobalCtxt {
pub visibilities: FxHashMap<LocalDefId, Visibility>,
pub impl_restrictions: FxHashMap<DefId, ImplRestriction>,
pub mut_restrictions: FxHashMap<DefId, MutRestriction>,
pub impl_restrictions: FxHashMap<LocalDefId, ImplRestriction>,
pub mut_restrictions: FxHashMap<LocalDefId, MutRestriction>,
/// 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`.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,9 +982,9 @@ pub struct Resolver<'a, 'tcx> {
visibilities: FxHashMap<LocalDefId, ty::Visibility>,
has_pub_restricted: bool,
/// trait def -> restriction scope
impl_restrictions: FxHashMap<DefId, ty::ImplRestriction>,
impl_restrictions: FxHashMap<LocalDefId, ty::ImplRestriction>,
/// field def -> restriction scope
mut_restrictions: FxHashMap<DefId, ty::MutRestriction>,
mut_restrictions: FxHashMap<LocalDefId, ty::MutRestriction>,
used_imports: FxHashSet<NodeId>,
maybe_unused_trait_imports: FxIndexSet<LocalDefId>,

Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_restrictions/src/impl_restriction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}"),
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_restrictions/src/mut_restriction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}"),
}
Expand Down

0 comments on commit 076a838

Please sign in to comment.