Skip to content

Commit e439761

Browse files
committed
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`.
1 parent 8723fe0 commit e439761

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types::Typ
6767
pointer_ty(tcx)
6868
}
6969
}
70-
ty::Adt(adt_def, _) if adt_def.repr.simd() => {
70+
ty::Adt(adt_def, _) if adt_def.repr().simd() => {
7171
let (element, count) = match &tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().abi
7272
{
7373
Abi::Vector { element, count } => (element.clone(), *count),

src/unsize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub(crate) fn coerce_unsized_into<'tcx>(
127127
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
128128
assert_eq!(def_a, def_b);
129129

130-
for i in 0..def_a.variants[VariantIdx::new(0)].fields.len() {
130+
for i in 0..def_a.variant(VariantIdx::new(0)).fields.len() {
131131
let src_f = src.value_field(fx, mir::Field::new(i));
132132
let dst_f = dst.place_field(fx, mir::Field::new(i));
133133

@@ -200,7 +200,7 @@ pub(crate) fn size_and_align_of_dst<'tcx>(
200200

201201
// Packed types ignore the alignment of their fields.
202202
if let ty::Adt(def, _) = layout.ty.kind() {
203-
if def.repr.packed() {
203+
if def.repr().packed() {
204204
unsized_align = sized_align;
205205
}
206206
}

src/value_and_place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn codegen_field<'tcx>(
2424
}
2525
match field_layout.ty.kind() {
2626
ty::Slice(..) | ty::Str | ty::Foreign(..) => simple(fx),
27-
ty::Adt(def, _) if def.repr.packed() => {
27+
ty::Adt(def, _) if def.repr().packed() => {
2828
assert_eq!(layout.align.abi.bytes(), 1);
2929
simple(fx)
3030
}
@@ -816,7 +816,7 @@ pub(crate) fn assert_assignable<'tcx>(
816816
// dyn for<'r> Trait<'r> -> dyn Trait<'_> is allowed
817817
}
818818
(&ty::Adt(adt_def_a, substs_a), &ty::Adt(adt_def_b, substs_b))
819-
if adt_def_a.did == adt_def_b.did =>
819+
if adt_def_a.did() == adt_def_b.did() =>
820820
{
821821
let mut types_a = substs_a.types();
822822
let mut types_b = substs_b.types();

0 commit comments

Comments
 (0)