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:
parent
5f4e067719
commit
ca5525d564
169 changed files with 702 additions and 687 deletions
|
@ -255,7 +255,7 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
|
||||
assert_eq!(def_a, def_b);
|
||||
|
||||
for i in 0..def_a.variants[VariantIdx::new(0)].fields.len() {
|
||||
for i in 0..def_a.variant(VariantIdx::new(0)).fields.len() {
|
||||
let src_f = src.project_field(bx, i);
|
||||
let dst_f = dst.project_field(bx, i);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
if def.is_enum() && cpp_like_debuginfo {
|
||||
msvc_enum_fallback(tcx, t, def, substs, output, visited);
|
||||
} else {
|
||||
push_item_name(tcx, def.did, qualified, output);
|
||||
push_item_name(tcx, def.did(), qualified, output);
|
||||
push_generic_params_internal(tcx, substs, output, visited);
|
||||
}
|
||||
}
|
||||
|
@ -405,15 +405,15 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
fn msvc_enum_fallback<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
def: &AdtDef,
|
||||
def: AdtDef<'tcx>,
|
||||
substs: SubstsRef<'tcx>,
|
||||
output: &mut String,
|
||||
visited: &mut FxHashSet<Ty<'tcx>>,
|
||||
) {
|
||||
let layout = tcx.layout_of(tcx.param_env(def.did).and(ty)).expect("layout error");
|
||||
let layout = tcx.layout_of(tcx.param_env(def.did()).and(ty)).expect("layout error");
|
||||
|
||||
output.push_str("enum$<");
|
||||
push_item_name(tcx, def.did, true, output);
|
||||
push_item_name(tcx, def.did(), true, output);
|
||||
push_generic_params_internal(tcx, substs, output, visited);
|
||||
|
||||
if let Variants::Multiple {
|
||||
|
@ -435,14 +435,14 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
let max = dataful_discriminant_range.end;
|
||||
let max = tag.value.size(&tcx).truncate(max);
|
||||
|
||||
let dataful_variant_name = def.variants[*dataful_variant].name.as_str();
|
||||
let dataful_variant_name = def.variant(*dataful_variant).name.as_str();
|
||||
|
||||
output.push_str(&format!(", {}, {}, {}", min, max, dataful_variant_name));
|
||||
} else if let Variants::Single { index: variant_idx } = &layout.variants {
|
||||
// Uninhabited enums can't be constructed and should never need to be visualized so
|
||||
// skip this step for them.
|
||||
if def.variants.len() != 0 {
|
||||
let variant = def.variants[*variant_idx].name.as_str();
|
||||
if def.variants().len() != 0 {
|
||||
let variant = def.variant(*variant_idx).name.as_str();
|
||||
|
||||
output.push_str(&format!(", {}", variant));
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
|
||||
// Packed types ignore the alignment of their fields.
|
||||
if let ty::Adt(def, _) = t.kind() {
|
||||
if def.repr.packed() {
|
||||
if def.repr().packed() {
|
||||
unsized_align = sized_align;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
_ if !field.is_unsized() => return simple(),
|
||||
ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(),
|
||||
ty::Adt(def, _) => {
|
||||
if def.repr.packed() {
|
||||
if def.repr().packed() {
|
||||
// FIXME(eddyb) generalize the adjustment when we
|
||||
// start supporting packing to larger alignments.
|
||||
assert_eq!(self.layout.align.abi.bytes(), 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue