@@ -32,17 +32,27 @@ struct VisitContext {
32
32
33
33
fn compute_modes_for_fn_args ( callee_id : node_id ,
34
34
args : & [ @expr] ,
35
+ last_arg_is_block : bool ,
35
36
& & cx: VisitContext ,
36
37
v : vt < VisitContext > ) {
37
38
let arg_tys = ty:: ty_fn_args ( ty:: node_id_to_type ( cx. tcx , callee_id) ) ;
39
+ let mut i = 0 ;
38
40
for vec:: each2( args, arg_tys) |arg, arg_ty| {
39
- match ty:: resolved_mode ( cx. tcx , arg_ty. mode ) {
40
- by_ref => {
41
- let arg_cx = VisitContext { mode : ReadValue , ..cx } ;
42
- compute_modes_for_expr ( * arg, arg_cx, v) ;
41
+ if last_arg_is_block && i == args. len ( ) - 1 {
42
+ let block_cx = VisitContext { mode : MoveValue , ..cx } ;
43
+ compute_modes_for_expr ( * arg, block_cx, v) ;
44
+ } else {
45
+ match ty:: resolved_mode ( cx. tcx , arg_ty. mode ) {
46
+ by_ref => {
47
+ let arg_cx = VisitContext { mode : ReadValue , ..cx } ;
48
+ compute_modes_for_expr ( * arg, arg_cx, v) ;
49
+ }
50
+ by_val | by_move | by_copy => {
51
+ compute_modes_for_expr ( * arg, cx, v) ;
52
+ }
43
53
}
44
- by_val | by_move | by_copy => compute_modes_for_expr ( * arg, cx, v)
45
54
}
55
+ i += 1 ;
46
56
}
47
57
}
48
58
@@ -80,10 +90,10 @@ fn compute_modes_for_expr(expr: @expr,
80
90
} ;
81
91
82
92
match expr. node {
83
- expr_call( callee, args, _ ) => {
93
+ expr_call( callee, args, is_block ) => {
84
94
let callee_cx = VisitContext { mode : ReadValue , ..cx } ;
85
95
compute_modes_for_expr ( callee, callee_cx, v) ;
86
- compute_modes_for_fn_args ( callee. id , args, cx, v) ;
96
+ compute_modes_for_fn_args ( callee. id , args, is_block , cx, v) ;
87
97
}
88
98
expr_path( * ) => {
89
99
record_mode_for_expr ( expr, cx) ;
@@ -92,7 +102,7 @@ fn compute_modes_for_expr(expr: @expr,
92
102
let callee_cx = VisitContext { mode : CopyValue , ..cx } ;
93
103
compute_modes_for_expr ( expr, callee_cx, v) ;
94
104
}
95
- expr_method_call( callee, _, _, args, _ ) => {
105
+ expr_method_call( callee, _, _, args, is_block ) => {
96
106
// The LHS of the dot may or may not result in a move, depending
97
107
// on the method map entry.
98
108
let callee_mode;
@@ -111,7 +121,7 @@ fn compute_modes_for_expr(expr: @expr,
111
121
let callee_cx = VisitContext { mode : callee_mode, ..cx } ;
112
122
compute_modes_for_expr ( callee, callee_cx, v) ;
113
123
114
- compute_modes_for_fn_args ( expr. callee_id , args, cx, v) ;
124
+ compute_modes_for_fn_args ( expr. callee_id , args, is_block , cx, v) ;
115
125
}
116
126
expr_binary( _, lhs, rhs) | expr_assign_op( _, lhs, rhs) => {
117
127
// The signatures of these take their arguments by-ref, so they
0 commit comments