// Potentially-fat pointers.
ty::TyRef(_, pointee, _) |
ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
- assert!(i < 2);
+ assert!(i < this.fields.count());
// Reuse the fat *T type as its own thin pointer data field.
// This provides information about e.g. DST struct pointees
match tcx.struct_tail(pointee).sty {
ty::TySlice(_) |
ty::TyStr => tcx.types.usize,
- ty::TyDynamic(..) => {
- // FIXME(eddyb) use an usize/fn() array with
- // the correct number of vtables slots.
- tcx.mk_imm_ref(tcx.types.re_static, tcx.mk_nil())
+ ty::TyDynamic(data, _) => {
+ let trait_def_id = data.principal().unwrap().def_id();
+ let num_fns: u64 = crate::traits::supertrait_def_ids(tcx, trait_def_id)
+ .map(|trait_def_id| {
+ tcx.associated_items(trait_def_id)
+ .filter(|item| item.kind == ty::AssociatedKind::Method)
+ .count() as u64
+ })
+ .sum();
+ tcx.mk_imm_ref(
+ tcx.types.re_static,
+ tcx.mk_array(tcx.types.usize, 3 + num_fns),
+ )
+ /* FIXME use actual fn pointers
+ tcx.mk_tup(&[
+ tcx.mk_array(tcx.types.usize, 3),
+ tcx.mk_array(Option<fn()>),
+ ])
+ */
}
_ => bug!("TyLayout::field_type({:?}): not applicable", this)
}