diff options
| author | Maik Klein <maikklein@googlemail.com> | 2017-12-18 16:14:00 +0100 |
|---|---|---|
| committer | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2017-12-18 19:10:01 +0200 |
| commit | c847cf3f5ef11ad4ea5f347062ece4730751e80a (patch) | |
| tree | 5472ab173fcada0d1e0acb94878d6e081882f50f | |
| parent | f6fcfa3915242b23df17c1cc14c35c6e7d041496 (diff) | |
| download | rust-c847cf3f5ef11ad4ea5f347062ece4730751e80a.tar.gz rust-c847cf3f5ef11ad4ea5f347062ece4730751e80a.zip | |
Fix incorrect rebase in collector::find_vtable_types
| -rw-r--r-- | src/librustc_mir/monomorphize/collector.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index d34e1292d12..44dedde5229 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -789,7 +789,23 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, target_ty: Ty<'tcx>) -> (Ty<'tcx>, Ty<'tcx>) { let ptr_vtable = |inner_source: Ty<'tcx>, inner_target: Ty<'tcx>| { - tcx.struct_lockstep_tails(inner_source, inner_target) + let type_has_metadata = |ty: Ty<'tcx>| -> bool { + use syntax_pos::DUMMY_SP; + if ty.is_sized(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP) { + return false; + } + let tail = tcx.struct_tail(ty); + match tail.sty { + ty::TyForeign(..) => false, + ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true, + _ => bug!("unexpected unsized tail: {:?}", tail.sty), + } + }; + if type_has_metadata(inner_source) { + (inner_source, inner_target) + } else { + tcx.struct_lockstep_tails(inner_source, inner_target) + } }; match (&source_ty.sty, &target_ty.sty) { |
