@@ -4,12 +4,11 @@ use middle::typeck::{method_map, method_map_entry};
4
4
5
5
use core:: vec;
6
6
use std:: map:: HashMap ;
7
- use syntax:: ast:: { by_copy, by_move, by_ref, by_val, crate , expr, expr_assign} ;
8
- use syntax:: ast:: { expr_addr_of, expr_assign_op, expr_binary, expr_call} ;
9
- use syntax:: ast:: { expr_copy, expr_field, expr_index, expr_method_call} ;
10
- use syntax:: ast:: { expr_path, expr_swap, expr_unary, node_id, sty_uniq} ;
11
- use syntax:: ast:: { sty_value} ;
12
- use syntax:: ast:: { box, uniq, deref, not, neg, expr_match, expr_paren} ;
7
+ use syntax:: ast:: { box, by_copy, by_move, by_ref, by_val, crate , deref, expr} ;
8
+ use syntax:: ast:: { expr_addr_of, expr_assign, expr_assign_op, expr_binary} ;
9
+ use syntax:: ast:: { expr_call, expr_copy, expr_field, expr_index, expr_match} ;
10
+ use syntax:: ast:: { expr_method_call, expr_paren, expr_path, expr_swap} ;
11
+ use syntax:: ast:: { expr_unary, neg, node_id, not, sty_uniq, sty_value, uniq} ;
13
12
use syntax:: visit;
14
13
use syntax:: visit:: vt;
15
14
@@ -115,17 +114,25 @@ fn compute_modes_for_expr(expr: @expr,
115
114
compute_modes_for_expr ( arg, arg_cx, v) ;
116
115
}
117
116
expr_unary( unop, arg) => {
118
- // Ditto.
119
- let arg_cx = VisitContext { mode : ReadValue , ..cx } ;
120
- compute_modes_for_expr ( arg, arg_cx, v) ;
121
-
122
117
match unop {
123
118
deref => {
119
+ // Derefs function as reads.
120
+ let arg_cx = VisitContext { mode : ReadValue , ..cx } ;
121
+ compute_modes_for_expr ( arg, arg_cx, v) ;
122
+
124
123
// This is an lvalue, so it needs a value mode recorded
125
124
// for it.
126
125
record_mode_for_expr ( expr, cx) ;
127
126
}
128
- box( _) | uniq( _) | not | neg => { }
127
+ box( _) | uniq( _) => {
128
+ let arg_cx = VisitContext { mode : MoveValue , ..cx } ;
129
+ compute_modes_for_expr ( arg, arg_cx, v) ;
130
+ }
131
+ not | neg => {
132
+ // Takes its argument by ref.
133
+ let arg_cx = VisitContext { mode : ReadValue , ..cx } ;
134
+ compute_modes_for_expr ( arg, arg_cx, v) ;
135
+ }
129
136
}
130
137
}
131
138
expr_field( arg, _, _) => {
0 commit comments