if data_a.principal_def_id() == data_b.principal_def_id() {
return old_info;
}
- // trait upcasting coercion
-
- // if both of the two `principal`s are `None`, this function would have returned early above.
- // and if one of the two `principal`s is `None`, typechecking would have rejected this case.
- let principal_a = data_a
- .principal()
- .expect("unsized_info: missing principal trait for trait upcasting coercion");
- let principal_b = data_b
- .principal()
- .expect("unsized_info: missing principal trait for trait upcasting coercion");
- let vptr_entry_idx = fx.tcx.vtable_trait_upcasting_coercion_new_vptr_slot((
- principal_a.with_self_ty(fx.tcx, source),
- principal_b.with_self_ty(fx.tcx, source),
- ));
+ // trait upcasting coercion
+ let vptr_entry_idx =
+ fx.tcx.vtable_trait_upcasting_coercion_new_vptr_slot((source, target));
if let Some(entry_idx) = vptr_entry_idx {
let entry_idx = u32::try_from(entry_idx).unwrap();
(&ty::Ref(_, a, _), &ty::Ref(_, b, _))
| (&ty::Ref(_, a, _), &ty::RawPtr(ty::TypeAndMut { ty: b, .. }))
| (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
- assert!(!fx.layout_of(a).is_unsized());
- (src, unsized_info(fx, a, b, old_info))
+ (src, unsized_info(fx, *a, *b, old_info))
}
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
let (a, b) = (src_layout.ty.boxed_ty(), dst_layout.ty.boxed_ty());
- assert!(!fx.layout_of(a).is_unsized());
(src, unsized_info(fx, a, b, old_info))
}
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
(&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.value_field(fx, mir::Field::new(i));
let dst_f = dst.place_field(fx, mir::Field::new(i));
// Packed types ignore the alignment of their fields.
if let ty::Adt(def, _) = layout.ty.kind() {
- if def.repr.packed() {
+ if def.repr().packed() {
unsized_align = sized_align;
}
}