@@ -14,6 +14,7 @@ use rustc_middle::ty::cast::{CastTy, IntTy};
14
14
use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf } ;
15
15
use rustc_middle:: ty:: { self , adjustment:: PointerCast , Instance , Ty , TyCtxt } ;
16
16
use rustc_span:: source_map:: { Span , DUMMY_SP } ;
17
+ use rustc_target:: abi:: Size ;
17
18
18
19
impl < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
19
20
#[ instrument( level = "trace" , skip( self , bx) ) ]
@@ -285,6 +286,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
285
286
bug ! ( "Only valid to do a DynStar cast into a DynStar type" )
286
287
} ;
287
288
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
+ } ;
288
297
OperandValue :: Pair ( data, vtable)
289
298
}
290
299
mir:: CastKind :: Pointer (
0 commit comments