Skip to content

Commit c847cf3

Browse files
MaikKleinarielb1
authored andcommitted
Fix incorrect rebase in collector::find_vtable_types
1 parent f6fcfa3 commit c847cf3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/librustc_mir/monomorphize/collector.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,23 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
789789
target_ty: Ty<'tcx>)
790790
-> (Ty<'tcx>, Ty<'tcx>) {
791791
let ptr_vtable = |inner_source: Ty<'tcx>, inner_target: Ty<'tcx>| {
792-
tcx.struct_lockstep_tails(inner_source, inner_target)
792+
let type_has_metadata = |ty: Ty<'tcx>| -> bool {
793+
use syntax_pos::DUMMY_SP;
794+
if ty.is_sized(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP) {
795+
return false;
796+
}
797+
let tail = tcx.struct_tail(ty);
798+
match tail.sty {
799+
ty::TyForeign(..) => false,
800+
ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true,
801+
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
802+
}
803+
};
804+
if type_has_metadata(inner_source) {
805+
(inner_source, inner_target)
806+
} else {
807+
tcx.struct_lockstep_tails(inner_source, inner_target)
808+
}
793809
};
794810

795811
match (&source_ty.sty, &target_ty.sty) {

0 commit comments

Comments
 (0)