@@ -89,8 +89,11 @@ use middle::typeck::astconv::{AstConv, ast_path_to_ty};
8989use middle:: typeck:: astconv:: { ast_region_to_region, ast_ty_to_ty} ;
9090use middle:: typeck:: astconv;
9191use middle:: typeck:: check:: _match:: pat_ctxt;
92+ use middle:: typeck:: check:: method:: { AutoderefReceiver } ;
93+ use middle:: typeck:: check:: method:: { AutoderefReceiverFlag } ;
9294use middle:: typeck:: check:: method:: { CheckTraitsAndInherentMethods } ;
93- use middle:: typeck:: check:: method:: { CheckTraitsOnly , TransformTypeNormally } ;
95+ use middle:: typeck:: check:: method:: { CheckTraitsOnly , DontAutoderefReceiver } ;
96+ use middle:: typeck:: check:: method:: { TransformTypeNormally } ;
9497use middle:: typeck:: check:: regionmanip:: replace_bound_regions_in_fn_sig;
9598use middle:: typeck:: check:: vtable:: { LocationInfo , VtableContext } ;
9699use middle:: typeck:: CrateCtxt ;
@@ -1373,7 +1376,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
13731376 expr_t,
13741377 tps,
13751378 DontDerefArgs ,
1376- CheckTraitsAndInherentMethods ) {
1379+ CheckTraitsAndInherentMethods ,
1380+ AutoderefReceiver ) {
13771381 Some ( ref entry) => {
13781382 let method_map = fcx. ccx . method_map ;
13791383 method_map. insert ( expr. id , ( * entry) ) ;
@@ -1453,7 +1457,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
14531457 self_t : ty:: t ,
14541458 opname : ast:: ident ,
14551459 +args : ~[ @ast:: expr ] ,
1456- +deref_args : DerefArgs )
1460+ +deref_args : DerefArgs ,
1461+ +autoderef_receiver : AutoderefReceiverFlag )
14571462 -> Option < ( ty:: t , bool ) > {
14581463 match method:: lookup ( fcx,
14591464 op_ex,
@@ -1463,7 +1468,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
14631468 self_t,
14641469 ~[ ] ,
14651470 deref_args,
1466- CheckTraitsOnly ) {
1471+ CheckTraitsOnly ,
1472+ autoderef_receiver) {
14671473 Some ( ref origin) => {
14681474 let method_ty = fcx. node_ty ( op_ex. callee_id ) ;
14691475 let method_map = fcx. ccx . method_map ;
@@ -1548,9 +1554,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
15481554 let tcx = fcx. ccx . tcx ;
15491555 match ast_util:: binop_to_method_name ( op) {
15501556 Some ( ref name) => {
1551- match lookup_op_method ( fcx, ex, lhs_expr, lhs_resolved_t,
1557+ match lookup_op_method ( fcx,
1558+ ex,
1559+ lhs_expr,
1560+ lhs_resolved_t,
15521561 fcx. tcx ( ) . sess . ident_of ( copy * name) ,
1553- ~[ rhs] , DoDerefArgs ) {
1562+ ~[ rhs] ,
1563+ DoDerefArgs ,
1564+ DontAutoderefReceiver ) {
15541565 Some ( pair) => return pair,
15551566 _ => ( )
15561567 }
@@ -1588,11 +1599,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
15881599 rhs_expr: @ast:: expr,
15891600 rhs_t: ty:: t)
15901601 -> ty:: t {
1591- match lookup_op_method(
1592- fcx, ex, rhs_expr, rhs_t,
1593- fcx. tcx( ) . sess. ident_of( /*bad*/ copy mname) , ~[ ] ,
1594- DontDerefArgs )
1595- {
1602+ match lookup_op_method( fcx,
1603+ ex,
1604+ rhs_expr,
1605+ rhs_t,
1606+ fcx. tcx( ) . sess. ident_of( /*bad*/ copy mname) ,
1607+ ~[ ] ,
1608+ DontDerefArgs ,
1609+ DontAutoderefReceiver ) {
15961610 Some ( ( ret_ty, _) ) => ret_ty,
15971611 _ => {
15981612 fcx. type_error_message( ex. span, |actual| {
@@ -1740,7 +1754,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
17401754 expr_t,
17411755 tps,
17421756 DontDerefArgs ,
1743- CheckTraitsAndInherentMethods ) {
1757+ CheckTraitsAndInherentMethods ,
1758+ AutoderefReceiver ) {
17441759 Some ( ref entry) => {
17451760 let method_map = fcx. ccx. method_map;
17461761 method_map. insert( expr. id, ( * entry) ) ;
@@ -2569,9 +2584,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
25692584 None => {
25702585 let resolved = structurally_resolved_type( fcx, expr. span,
25712586 raw_base_t) ;
2572- match lookup_op_method( fcx, expr, base, resolved,
2587+ match lookup_op_method( fcx,
2588+ expr,
2589+ base,
2590+ resolved,
25732591 tcx. sess. ident_of( ~"index") ,
2574- ~[ idx] , DontDerefArgs ) {
2592+ ~[ idx] ,
2593+ DontDerefArgs ,
2594+ AutoderefReceiver ) {
25752595 Some ( ( ret_ty, _) ) => fcx. write_ty( id, ret_ty) ,
25762596 _ => {
25772597 fcx. type_error_message( expr. span, |actual|
0 commit comments