@@ -15,7 +15,6 @@ use rustc::ty::layout::{self, LayoutOf};
15
15
use rustc:: mir;
16
16
use rustc:: middle:: lang_items:: ExchangeMallocFnLangItem ;
17
17
18
- use abi;
19
18
use base;
20
19
use builder:: Builder ;
21
20
use callee;
@@ -49,10 +48,10 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
49
48
bcx
50
49
}
51
50
52
- mir:: Rvalue :: Cast ( mir:: CastKind :: Unsize , ref source, cast_ty ) => {
53
- let cast_ty = self . monomorphize ( & cast_ty ) ;
54
-
55
- if common :: type_is_fat_ptr ( bcx . ccx , cast_ty ) {
51
+ mir:: Rvalue :: Cast ( mir:: CastKind :: Unsize , ref source, _ ) => {
52
+ // The destination necessarily contains a fat pointer, so if
53
+ // it's a scalar pair, it's a fat pointer or newtype thereof.
54
+ if dest . layout . is_llvm_scalar_pair ( ) {
56
55
// into-coerce of a thin pointer to a fat pointer - just
57
56
// use the operand path.
58
57
let ( bcx, temp) = self . trans_rvalue_operand ( bcx, rvalue) ;
@@ -218,6 +217,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
218
217
operand. val
219
218
}
220
219
mir:: CastKind :: Unsize => {
220
+ assert ! ( cast. is_llvm_scalar_pair( ) ) ;
221
221
match operand. val {
222
222
OperandValue :: Pair ( lldata, llextra) => {
223
223
// unsize from a fat pointer - this is a
@@ -243,12 +243,11 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
243
243
}
244
244
}
245
245
}
246
- mir:: CastKind :: Misc if common :: type_is_fat_ptr ( bcx . ccx , operand. layout . ty ) => {
246
+ mir:: CastKind :: Misc if operand. layout . is_llvm_scalar_pair ( ) => {
247
247
if let OperandValue :: Pair ( data_ptr, meta) = operand. val {
248
- if common:: type_is_fat_ptr ( bcx. ccx , cast. ty ) {
249
- let thin_ptr = cast. field ( bcx. ccx , abi:: FAT_PTR_ADDR ) ;
248
+ if cast. is_llvm_scalar_pair ( ) {
250
249
let data_cast = bcx. pointercast ( data_ptr,
251
- thin_ptr . llvm_type ( bcx. ccx ) ) ;
250
+ cast . scalar_pair_element_llvm_type ( bcx. ccx , 0 ) ) ;
252
251
OperandValue :: Pair ( data_cast, meta)
253
252
} else { // cast to thin-ptr
254
253
// Cast of fat-ptr to thin-ptr is an extraction of data-ptr and
@@ -365,22 +364,21 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
365
364
mir:: Rvalue :: BinaryOp ( op, ref lhs, ref rhs) => {
366
365
let lhs = self . trans_operand ( & bcx, lhs) ;
367
366
let rhs = self . trans_operand ( & bcx, rhs) ;
368
- let llresult = if common:: type_is_fat_ptr ( bcx. ccx , lhs. layout . ty ) {
369
- match ( lhs. val , rhs. val ) {
370
- ( OperandValue :: Pair ( lhs_addr, lhs_extra) ,
371
- OperandValue :: Pair ( rhs_addr, rhs_extra) ) => {
372
- self . trans_fat_ptr_binop ( & bcx, op,
373
- lhs_addr, lhs_extra,
374
- rhs_addr, rhs_extra,
375
- lhs. layout . ty )
376
- }
377
- _ => bug ! ( )
367
+ let llresult = match ( lhs. val , rhs. val ) {
368
+ ( OperandValue :: Pair ( lhs_addr, lhs_extra) ,
369
+ OperandValue :: Pair ( rhs_addr, rhs_extra) ) => {
370
+ self . trans_fat_ptr_binop ( & bcx, op,
371
+ lhs_addr, lhs_extra,
372
+ rhs_addr, rhs_extra,
373
+ lhs. layout . ty )
378
374
}
379
375
380
- } else {
381
- self . trans_scalar_binop ( & bcx, op,
382
- lhs. immediate ( ) , rhs. immediate ( ) ,
383
- lhs. layout . ty )
376
+ ( OperandValue :: Immediate ( lhs_val) ,
377
+ OperandValue :: Immediate ( rhs_val) ) => {
378
+ self . trans_scalar_binop ( & bcx, op, lhs_val, rhs_val, lhs. layout . ty )
379
+ }
380
+
381
+ _ => bug ! ( )
384
382
} ;
385
383
let operand = OperandRef {
386
384
val : OperandValue :: Immediate ( llresult) ,
0 commit comments