@@ -21,7 +21,7 @@ use super::{
21
21
structurally_resolved_type,
22
22
} ;
23
23
use middle:: traits;
24
- use middle:: ty:: { self , Ty , HasTypeFlags } ;
24
+ use middle:: ty:: { Ty , HasTypeFlags } ;
25
25
use syntax:: ast;
26
26
use syntax:: ast_util;
27
27
use syntax:: parse:: token;
@@ -41,7 +41,7 @@ pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
41
41
let lhs_ty = structurally_resolved_type ( fcx, lhs_expr. span , fcx. expr_ty ( lhs_expr) ) ;
42
42
let rhs_ty = structurally_resolved_type ( fcx, rhs_expr. span , fcx. expr_ty ( rhs_expr) ) ;
43
43
44
- if is_builtin_binop ( fcx . tcx ( ) , lhs_ty, rhs_ty, op) {
44
+ if is_builtin_binop ( lhs_ty, rhs_ty, op) {
45
45
enforce_builtin_binop_types ( fcx, lhs_expr, lhs_ty, rhs_expr, rhs_ty, op) ;
46
46
fcx. write_nil ( expr. id ) ;
47
47
} else {
@@ -86,7 +86,7 @@ pub fn check_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
86
86
// traits, because their return type is not bool. Perhaps this
87
87
// should change, but for now if LHS is SIMD we go down a
88
88
// different path that bypassess all traits.
89
- if lhs_ty. is_simd ( fcx . tcx ( ) ) {
89
+ if lhs_ty. is_simd ( ) {
90
90
check_expr_coercable_to_type ( fcx, rhs_expr, lhs_ty) ;
91
91
let rhs_ty = fcx. resolve_type_vars_if_possible ( fcx. expr_ty ( lhs_expr) ) ;
92
92
let return_ty = enforce_builtin_binop_types ( fcx, lhs_expr, lhs_ty, rhs_expr, rhs_ty, op) ;
@@ -123,7 +123,7 @@ pub fn check_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
123
123
let rhs_ty = fcx. resolve_type_vars_if_possible ( rhs_ty) ;
124
124
if
125
125
!lhs_ty. is_ty_var ( ) && !rhs_ty. is_ty_var ( ) &&
126
- is_builtin_binop ( fcx . tcx ( ) , lhs_ty, rhs_ty, op)
126
+ is_builtin_binop ( lhs_ty, rhs_ty, op)
127
127
{
128
128
let builtin_return_ty =
129
129
enforce_builtin_binop_types ( fcx, lhs_expr, lhs_ty, rhs_expr, rhs_ty, op) ;
@@ -143,7 +143,7 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
143
143
op : ast:: BinOp )
144
144
-> Ty < ' tcx >
145
145
{
146
- debug_assert ! ( is_builtin_binop( fcx . tcx ( ) , lhs_ty, rhs_ty, op) ) ;
146
+ debug_assert ! ( is_builtin_binop( lhs_ty, rhs_ty, op) ) ;
147
147
148
148
let tcx = fcx. tcx ( ) ;
149
149
match BinOpCategory :: from ( op) {
@@ -156,7 +156,7 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
156
156
BinOpCategory :: Shift => {
157
157
// For integers, the shift amount can be of any integral
158
158
// type. For simd, the type must match exactly.
159
- if lhs_ty. is_simd ( tcx ) {
159
+ if lhs_ty. is_simd ( ) {
160
160
demand:: suptype ( fcx, rhs_expr. span , lhs_ty, rhs_ty) ;
161
161
}
162
162
@@ -176,7 +176,7 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
176
176
demand:: suptype ( fcx, rhs_expr. span , lhs_ty, rhs_ty) ;
177
177
178
178
// if this is simd, result is same as lhs, else bool
179
- if lhs_ty. is_simd ( tcx ) {
179
+ if lhs_ty. is_simd ( ) {
180
180
let unit_ty = lhs_ty. simd_type ( tcx) ;
181
181
debug ! ( "enforce_builtin_binop_types: lhs_ty={:?} unit_ty={:?}" ,
182
182
lhs_ty,
@@ -415,8 +415,7 @@ impl BinOpCategory {
415
415
/// Reason #2 is the killer. I tried for a while to always use
416
416
/// overloaded logic and just check the types in constants/trans after
417
417
/// the fact, and it worked fine, except for SIMD types. -nmatsakis
418
- fn is_builtin_binop < ' tcx > ( cx : & ty:: ctxt < ' tcx > ,
419
- lhs : Ty < ' tcx > ,
418
+ fn is_builtin_binop < ' tcx > ( lhs : Ty < ' tcx > ,
420
419
rhs : Ty < ' tcx > ,
421
420
op : ast:: BinOp )
422
421
-> bool
@@ -429,28 +428,28 @@ fn is_builtin_binop<'tcx>(cx: &ty::ctxt<'tcx>,
429
428
BinOpCategory :: Shift => {
430
429
lhs. references_error ( ) || rhs. references_error ( ) ||
431
430
lhs. is_integral ( ) && rhs. is_integral ( ) ||
432
- lhs. is_simd ( cx ) && rhs. is_simd ( cx )
431
+ lhs. is_simd ( ) && rhs. is_simd ( )
433
432
}
434
433
435
434
BinOpCategory :: Math => {
436
435
lhs. references_error ( ) || rhs. references_error ( ) ||
437
436
lhs. is_integral ( ) && rhs. is_integral ( ) ||
438
437
lhs. is_floating_point ( ) && rhs. is_floating_point ( ) ||
439
- lhs. is_simd ( cx ) && rhs. is_simd ( cx )
438
+ lhs. is_simd ( ) && rhs. is_simd ( )
440
439
}
441
440
442
441
BinOpCategory :: Bitwise => {
443
442
lhs. references_error ( ) || rhs. references_error ( ) ||
444
443
lhs. is_integral ( ) && rhs. is_integral ( ) ||
445
444
lhs. is_floating_point ( ) && rhs. is_floating_point ( ) ||
446
- lhs. is_simd ( cx ) && rhs. is_simd ( cx ) ||
445
+ lhs. is_simd ( ) && rhs. is_simd ( ) ||
447
446
lhs. is_bool ( ) && rhs. is_bool ( )
448
447
}
449
448
450
449
BinOpCategory :: Comparison => {
451
450
lhs. references_error ( ) || rhs. references_error ( ) ||
452
451
lhs. is_scalar ( ) && rhs. is_scalar ( ) ||
453
- lhs. is_simd ( cx ) && rhs. is_simd ( cx )
452
+ lhs. is_simd ( ) && rhs. is_simd ( )
454
453
}
455
454
}
456
455
}
0 commit comments