1
1
use rustc:: mir;
2
- use rustc:: ty:: { self , Ty } ;
2
+ use rustc:: ty:: { self , Ty , layout } ;
3
3
use syntax:: ast:: FloatTy ;
4
4
use rustc:: ty:: layout:: LayoutOf ;
5
5
use rustc_apfloat:: ieee:: { Double , Single } ;
@@ -68,8 +68,17 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
68
68
) -> EvalResult < ' tcx , ( Scalar , bool ) > {
69
69
use rustc:: mir:: BinOp :: * ;
70
70
71
- let left_kind = self . ty_to_primitive ( left_ty) ?;
72
- let right_kind = self . ty_to_primitive ( right_ty) ?;
71
+ let left_layout = self . layout_of ( left_ty) ?;
72
+ let right_layout = self . layout_of ( right_ty) ?;
73
+
74
+ let left_kind = match left_layout. abi {
75
+ layout:: Abi :: Scalar ( ref scalar) => scalar. value ,
76
+ _ => return err ! ( TypeNotPrimitive ( left_ty) ) ,
77
+ } ;
78
+ let right_kind = match right_layout. abi {
79
+ layout:: Abi :: Scalar ( ref scalar) => scalar. value ,
80
+ _ => return err ! ( TypeNotPrimitive ( right_ty) ) ,
81
+ } ;
73
82
trace ! ( "Running binary op {:?}: {:?} ({:?}), {:?} ({:?})" , bin_op, left, left_kind, right, right_kind) ;
74
83
75
84
// I: Handle operations that support pointers
@@ -79,9 +88,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
79
88
}
80
89
}
81
90
82
- let left_layout = self . layout_of ( left_ty) ?;
83
- let right_layout = self . layout_of ( right_ty) ?;
84
-
85
91
// II: From now on, everything must be bytes, no pointers
86
92
let l = left. to_bits ( left_layout. size ) ?;
87
93
let r = right. to_bits ( right_layout. size ) ?;
0 commit comments