File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -485,7 +485,7 @@ fn trans_stmt<'tcx>(
485
485
| Rvalue :: Cast ( CastKind :: Pointer ( PointerCast :: ArrayToPointer ) , operand, to_ty) => {
486
486
let to_layout = fx. layout_of ( fx. monomorphize ( to_ty) ) ;
487
487
let operand = trans_operand ( fx, operand) ;
488
- lval. write_cvalue ( fx, operand. unchecked_cast_to ( to_layout) ) ;
488
+ lval. write_cvalue ( fx, operand. cast_pointer_to ( to_layout) ) ;
489
489
}
490
490
Rvalue :: Cast ( CastKind :: Misc , operand, to_ty) => {
491
491
let operand = trans_operand ( fx, operand) ;
@@ -509,7 +509,7 @@ fn trans_stmt<'tcx>(
509
509
if is_fat_ptr ( fx, from_ty) {
510
510
if is_fat_ptr ( fx, to_ty) {
511
511
// fat-ptr -> fat-ptr
512
- lval. write_cvalue ( fx, operand. unchecked_cast_to ( dest_layout) ) ;
512
+ lval. write_cvalue ( fx, operand. cast_pointer_to ( dest_layout) ) ;
513
513
} else {
514
514
// fat-ptr -> thin-ptr
515
515
let ( ptr, _extra) = operand. load_scalar_pair ( fx) ;
Original file line number Diff line number Diff line change @@ -243,7 +243,10 @@ impl<'tcx> CValue<'tcx> {
243
243
CValue :: by_val ( val, layout)
244
244
}
245
245
246
- pub ( crate ) fn unchecked_cast_to ( self , layout : TyAndLayout < ' tcx > ) -> Self {
246
+ pub ( crate ) fn cast_pointer_to ( self , layout : TyAndLayout < ' tcx > ) -> Self {
247
+ assert ! ( matches!( self . layout( ) . ty. kind, ty:: Ref ( ..) | ty:: RawPtr ( ..) | ty:: FnPtr ( ..) ) ) ;
248
+ assert ! ( matches!( layout. ty. kind, ty:: Ref ( ..) | ty:: RawPtr ( ..) | ty:: FnPtr ( ..) ) ) ;
249
+ assert_eq ! ( self . layout( ) . abi, layout. abi) ;
247
250
CValue ( self . 0 , layout)
248
251
}
249
252
}
@@ -560,20 +563,16 @@ impl<'tcx> CPlace<'tcx> {
560
563
}
561
564
}
562
565
563
- pub ( crate ) fn unchecked_cast_to ( self , layout : TyAndLayout < ' tcx > ) -> Self {
564
- assert ! ( !self . layout( ) . is_unsized( ) ) ;
565
- CPlace {
566
- inner : self . inner ,
567
- layout,
568
- }
569
- }
570
-
571
566
pub ( crate ) fn downcast_variant (
572
567
self ,
573
568
fx : & FunctionCx < ' _ , ' tcx , impl Backend > ,
574
569
variant : VariantIdx ,
575
570
) -> Self {
571
+ assert ! ( !self . layout( ) . is_unsized( ) ) ;
576
572
let layout = self . layout ( ) . for_variant ( fx, variant) ;
577
- self . unchecked_cast_to ( layout)
573
+ CPlace {
574
+ inner : self . inner ,
575
+ layout,
576
+ }
578
577
}
579
578
}
You can’t perform that action at this time.
0 commit comments