@@ -2904,6 +2904,7 @@ pub fn lookup_tup_field_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
2904
2904
2905
2905
// Controls whether the arguments are automatically referenced. This is useful
2906
2906
// for overloaded binary and unary operators.
2907
+ #[ deriving( PartialEq ) ]
2907
2908
pub enum DerefArgs {
2908
2909
DontDerefArgs ,
2909
2910
DoDerefArgs
@@ -3130,7 +3131,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3130
3131
trait_did : Option < ast:: DefId > ,
3131
3132
lhs : & ' a ast:: Expr ,
3132
3133
rhs : Option < & P < ast:: Expr > > ,
3133
- unbound_method : F ) -> Ty < ' tcx > where
3134
+ unbound_method : F ,
3135
+ deref_args : DerefArgs ) -> Ty < ' tcx > where
3134
3136
F : FnOnce ( ) ,
3135
3137
{
3136
3138
let method = match trait_did {
@@ -3146,7 +3148,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3146
3148
// traits that don't force left and right to have same
3147
3149
// type.
3148
3150
let ( adj_ty, adjustment) = match lhs_ty. sty {
3149
- ty:: ty_rptr( r_in, mt) => {
3151
+ ty:: ty_rptr( r_in, mt) if deref_args == DoDerefArgs => {
3150
3152
let r_adj = fcx. infcx ( ) . next_region_var ( infer:: Autoref ( lhs. span ) ) ;
3151
3153
fcx. mk_subr ( infer:: Reborrow ( lhs. span ) , r_adj, r_in) ;
3152
3154
let adjusted_ty = ty:: mk_rptr ( fcx. tcx ( ) , r_adj, mt) ;
@@ -3183,7 +3185,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3183
3185
method_ty,
3184
3186
op_ex,
3185
3187
args. as_slice ( ) ,
3186
- DoDerefArgs ,
3188
+ deref_args ,
3187
3189
DontTupleArguments ) {
3188
3190
ty:: FnConverging ( result_type) => result_type,
3189
3191
ty:: FnDiverging => ty:: mk_err ( )
@@ -3199,7 +3201,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3199
3201
expected_ty,
3200
3202
op_ex,
3201
3203
args. as_slice ( ) ,
3202
- DoDerefArgs ,
3204
+ deref_args ,
3203
3205
DontTupleArguments ) ;
3204
3206
ty:: mk_err ( )
3205
3207
}
@@ -3318,23 +3320,23 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3318
3320
rhs : & P < ast:: Expr > ) -> Ty < ' tcx > {
3319
3321
let tcx = fcx. ccx . tcx ;
3320
3322
let lang = & tcx. lang_items ;
3321
- let ( name, trait_did) = match op {
3322
- ast:: BiAdd => ( "add" , lang. add_trait ( ) ) ,
3323
- ast:: BiSub => ( "sub" , lang. sub_trait ( ) ) ,
3324
- ast:: BiMul => ( "mul" , lang. mul_trait ( ) ) ,
3325
- ast:: BiDiv => ( "div" , lang. div_trait ( ) ) ,
3326
- ast:: BiRem => ( "rem" , lang. rem_trait ( ) ) ,
3327
- ast:: BiBitXor => ( "bitxor" , lang. bitxor_trait ( ) ) ,
3328
- ast:: BiBitAnd => ( "bitand" , lang. bitand_trait ( ) ) ,
3329
- ast:: BiBitOr => ( "bitor" , lang. bitor_trait ( ) ) ,
3330
- ast:: BiShl => ( "shl" , lang. shl_trait ( ) ) ,
3331
- ast:: BiShr => ( "shr" , lang. shr_trait ( ) ) ,
3332
- ast:: BiLt => ( "lt" , lang. ord_trait ( ) ) ,
3333
- ast:: BiLe => ( "le" , lang. ord_trait ( ) ) ,
3334
- ast:: BiGe => ( "ge" , lang. ord_trait ( ) ) ,
3335
- ast:: BiGt => ( "gt" , lang. ord_trait ( ) ) ,
3336
- ast:: BiEq => ( "eq" , lang. eq_trait ( ) ) ,
3337
- ast:: BiNe => ( "ne" , lang. eq_trait ( ) ) ,
3323
+ let ( name, trait_did, deref_args ) = match op {
3324
+ ast:: BiAdd => ( "add" , lang. add_trait ( ) , DontDerefArgs ) ,
3325
+ ast:: BiSub => ( "sub" , lang. sub_trait ( ) , DontDerefArgs ) ,
3326
+ ast:: BiMul => ( "mul" , lang. mul_trait ( ) , DontDerefArgs ) ,
3327
+ ast:: BiDiv => ( "div" , lang. div_trait ( ) , DontDerefArgs ) ,
3328
+ ast:: BiRem => ( "rem" , lang. rem_trait ( ) , DontDerefArgs ) ,
3329
+ ast:: BiBitXor => ( "bitxor" , lang. bitxor_trait ( ) , DontDerefArgs ) ,
3330
+ ast:: BiBitAnd => ( "bitand" , lang. bitand_trait ( ) , DontDerefArgs ) ,
3331
+ ast:: BiBitOr => ( "bitor" , lang. bitor_trait ( ) , DontDerefArgs ) ,
3332
+ ast:: BiShl => ( "shl" , lang. shl_trait ( ) , DontDerefArgs ) ,
3333
+ ast:: BiShr => ( "shr" , lang. shr_trait ( ) , DontDerefArgs ) ,
3334
+ ast:: BiLt => ( "lt" , lang. ord_trait ( ) , DoDerefArgs ) ,
3335
+ ast:: BiLe => ( "le" , lang. ord_trait ( ) , DoDerefArgs ) ,
3336
+ ast:: BiGe => ( "ge" , lang. ord_trait ( ) , DoDerefArgs ) ,
3337
+ ast:: BiGt => ( "gt" , lang. ord_trait ( ) , DoDerefArgs ) ,
3338
+ ast:: BiEq => ( "eq" , lang. eq_trait ( ) , DoDerefArgs ) ,
3339
+ ast:: BiNe => ( "ne" , lang. eq_trait ( ) , DoDerefArgs ) ,
3338
3340
ast:: BiAnd | ast:: BiOr => {
3339
3341
check_expr ( fcx, & * * rhs) ;
3340
3342
return ty:: mk_err ( ) ;
@@ -3347,7 +3349,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3347
3349
ast_util:: binop_to_string( op) ,
3348
3350
actual)
3349
3351
} , lhs_resolved_t, None )
3350
- } )
3352
+ } , deref_args )
3351
3353
}
3352
3354
3353
3355
fn check_user_unop < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
@@ -3363,7 +3365,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3363
3365
format ! ( "cannot apply unary operator `{}` to type `{}`" ,
3364
3366
op_str, actual)
3365
3367
} , rhs_t, None ) ;
3366
- } )
3368
+ } , DontDerefArgs )
3367
3369
}
3368
3370
3369
3371
// Check field access expressions
0 commit comments