@@ -258,14 +258,6 @@ impl<'tcx> CValue<'tcx> {
258
258
}
259
259
}
260
260
261
- pub ( crate ) fn unsize_value ( self , fx : & mut FunctionCx < ' _ , ' _ , ' tcx > , dest : CPlace < ' tcx > ) {
262
- crate :: unsize:: coerce_unsized_into ( fx, self , dest) ;
263
- }
264
-
265
- pub ( crate ) fn coerce_dyn_star ( self , fx : & mut FunctionCx < ' _ , ' _ , ' tcx > , dest : CPlace < ' tcx > ) {
266
- crate :: unsize:: coerce_dyn_star ( fx, self , dest) ;
267
- }
268
-
269
261
/// If `ty` is signed, `const_val` must already be sign extended.
270
262
pub ( crate ) fn const_val (
271
263
fx : & mut FunctionCx < ' _ , ' _ , ' tcx > ,
@@ -454,18 +446,21 @@ impl<'tcx> CPlace<'tcx> {
454
446
455
447
#[ track_caller]
456
448
pub ( crate ) fn to_ptr ( self ) -> Pointer {
457
- match self . to_ptr_maybe_unsized ( ) {
458
- ( ptr, None ) => ptr,
459
- ( _, Some ( _) ) => bug ! ( "Expected sized cplace, found {:?}" , self ) ,
449
+ match self . inner {
450
+ CPlaceInner :: Addr ( ptr, None ) => ptr,
451
+ CPlaceInner :: Addr ( _, Some ( _) ) => bug ! ( "Expected sized cplace, found {:?}" , self ) ,
452
+ CPlaceInner :: Var ( _, _) | CPlaceInner :: VarPair ( _, _, _) => {
453
+ bug ! ( "Expected CPlace::Addr, found {:?}" , self )
454
+ }
460
455
}
461
456
}
462
457
463
458
#[ track_caller]
464
- pub ( crate ) fn to_ptr_maybe_unsized ( self ) -> ( Pointer , Option < Value > ) {
459
+ pub ( crate ) fn to_ptr_unsized ( self ) -> ( Pointer , Value ) {
465
460
match self . inner {
466
- CPlaceInner :: Addr ( ptr, extra) => ( ptr, extra) ,
467
- CPlaceInner :: Var ( _, _) | CPlaceInner :: VarPair ( _, _, _) => {
468
- bug ! ( "Expected CPlace::Addr , found {:?}" , self )
461
+ CPlaceInner :: Addr ( ptr, Some ( extra) ) => ( ptr, extra) ,
462
+ CPlaceInner :: Addr ( _ , None ) | CPlaceInner :: Var ( _, _) | CPlaceInner :: VarPair ( _, _, _) => {
463
+ bug ! ( "Expected unsized cplace , found {:?}" , self )
469
464
}
470
465
}
471
466
}
@@ -498,7 +493,7 @@ impl<'tcx> CPlace<'tcx> {
498
493
from : CValue < ' tcx > ,
499
494
method : & ' static str ,
500
495
) {
501
- fn transmute_value < ' tcx > (
496
+ fn transmute_scalar < ' tcx > (
502
497
fx : & mut FunctionCx < ' _ , ' _ , ' tcx > ,
503
498
var : Variable ,
504
499
data : Value ,
@@ -569,7 +564,7 @@ impl<'tcx> CPlace<'tcx> {
569
564
CPlaceInner :: Var ( _local, var) => {
570
565
let data = CValue ( from. 0 , dst_layout) . load_scalar ( fx) ;
571
566
let dst_ty = fx. clif_type ( self . layout ( ) . ty ) . unwrap ( ) ;
572
- transmute_value ( fx, var, data, dst_ty) ;
567
+ transmute_scalar ( fx, var, data, dst_ty) ;
573
568
}
574
569
CPlaceInner :: VarPair ( _local, var1, var2) => {
575
570
let ( data1, data2) = if from. layout ( ) . ty == dst_layout. ty {
@@ -580,8 +575,8 @@ impl<'tcx> CPlace<'tcx> {
580
575
CValue ( CValueInner :: ByRef ( ptr, None ) , dst_layout) . load_scalar_pair ( fx)
581
576
} ;
582
577
let ( dst_ty1, dst_ty2) = fx. clif_pair_type ( self . layout ( ) . ty ) . unwrap ( ) ;
583
- transmute_value ( fx, var1, data1, dst_ty1) ;
584
- transmute_value ( fx, var2, data2, dst_ty2) ;
578
+ transmute_scalar ( fx, var1, data1, dst_ty1) ;
579
+ transmute_scalar ( fx, var2, data2, dst_ty2) ;
585
580
}
586
581
CPlaceInner :: Addr ( _, Some ( _) ) => bug ! ( "Can't write value to unsized place {:?}" , self ) ,
587
582
CPlaceInner :: Addr ( to_ptr, None ) => {
@@ -666,7 +661,12 @@ impl<'tcx> CPlace<'tcx> {
666
661
_ => { }
667
662
}
668
663
669
- let ( base, extra) = self . to_ptr_maybe_unsized ( ) ;
664
+ let ( base, extra) = match self . inner {
665
+ CPlaceInner :: Addr ( ptr, extra) => ( ptr, extra) ,
666
+ CPlaceInner :: Var ( _, _) | CPlaceInner :: VarPair ( _, _, _) => {
667
+ bug ! ( "Expected CPlace::Addr, found {:?}" , self )
668
+ }
669
+ } ;
670
670
671
671
let ( field_ptr, field_layout) = codegen_field ( fx, base, extra, layout, field) ;
672
672
if field_layout. is_unsized ( ) {
@@ -721,7 +721,7 @@ impl<'tcx> CPlace<'tcx> {
721
721
| CPlaceInner :: VarPair ( _, _, _) => bug ! ( "Can't index into {self:?}" ) ,
722
722
}
723
723
}
724
- ty:: Slice ( elem_ty) => ( fx. layout_of ( * elem_ty) , self . to_ptr_maybe_unsized ( ) . 0 ) ,
724
+ ty:: Slice ( elem_ty) => ( fx. layout_of ( * elem_ty) , self . to_ptr_unsized ( ) . 0 ) ,
725
725
_ => bug ! ( "place_index({:?})" , self . layout( ) . ty) ,
726
726
} ;
727
727
@@ -746,12 +746,8 @@ impl<'tcx> CPlace<'tcx> {
746
746
layout : TyAndLayout < ' tcx > ,
747
747
) -> CValue < ' tcx > {
748
748
if has_ptr_meta ( fx. tcx , self . layout ( ) . ty ) {
749
- let ( ptr, extra) = self . to_ptr_maybe_unsized ( ) ;
750
- CValue :: by_val_pair (
751
- ptr. get_addr ( fx) ,
752
- extra. expect ( "unsized type without metadata" ) ,
753
- layout,
754
- )
749
+ let ( ptr, extra) = self . to_ptr_unsized ( ) ;
750
+ CValue :: by_val_pair ( ptr. get_addr ( fx) , extra, layout)
755
751
} else {
756
752
CValue :: by_val ( self . to_ptr ( ) . get_addr ( fx) , layout)
757
753
}
0 commit comments