Improve AdtDef interning.

This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.
This commit is contained in:
Nicholas Nethercote
2022-03-05 07:28:41 +11:00
parent 5f4e067719
commit ca5525d564
169 changed files with 702 additions and 687 deletions

View File

@@ -1,5 +1,6 @@
use rustc_data_structures::base_n;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::intern::Interned;
use rustc_hir as hir;
use rustc_hir::def::CtorKind;
use rustc_hir::def_id::{CrateNum, DefId};
@@ -453,7 +454,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
}
// Mangle all nominal types as paths.
ty::Adt(&ty::AdtDef { did: def_id, .. }, substs)
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
| ty::FnDef(def_id, substs)
| ty::Opaque(def_id, substs)
| ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs })
@@ -684,7 +685,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
ty::Adt(def, substs) => {
let variant_idx =
contents.variant.expect("destructed const of adt without variant idx");
let variant_def = &def.variants[variant_idx];
let variant_def = &def.variant(variant_idx);
self.push("V");
self = self.print_def_path(variant_def.def_id, substs)?;