@@ -14,6 +14,7 @@ use rustc_middle::ty::cast::{CastTy, IntTy};
1414use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf } ;
1515use rustc_middle:: ty:: { self , adjustment:: PointerCast , Instance , Ty , TyCtxt } ;
1616use rustc_span:: source_map:: { Span , DUMMY_SP } ;
17+ use rustc_target:: abi:: Size ;
1718
1819impl < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
1920 #[ instrument( level = "trace" , skip( self , bx) ) ]
@@ -285,6 +286,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
285286 bug ! ( "Only valid to do a DynStar cast into a DynStar type" )
286287 } ;
287288 let vtable = get_vtable ( bx. cx ( ) , source. ty ( self . mir , bx. tcx ( ) ) , trait_ref) ;
289+ let vtable = bx. pointercast ( vtable, bx. cx ( ) . type_ptr_to ( bx. cx ( ) . type_isize ( ) ) ) ;
290+ // FIXME(dyn-star): this is probably not the best way to check if this is
291+ // a pointer, and really we should ensure that the value is a suitable
292+ // pointer earlier in the compilation process.
293+ let data = match operand. layout . pointee_info_at ( bx. cx ( ) , Size :: ZERO ) {
294+ Some ( _) => bx. ptrtoint ( data, bx. cx ( ) . type_isize ( ) ) ,
295+ None => data,
296+ } ;
288297 OperandValue :: Pair ( data, vtable)
289298 }
290299 mir:: CastKind :: Pointer (
0 commit comments