@@ -13,6 +13,9 @@ import driver::session::session;
13
13
import std:: map:: hashmap;
14
14
15
15
fn forbid_upvar ( fcx : fn_ctxt , rhs_id : node_id , sp : span , t : oper_type ) {
16
+ // fcx.ccx.tcx.sess.span_note(sp,
17
+ // #fmt("forbid_upvar: checking. %?", t));
18
+
16
19
alt t {
17
20
oper_move {
18
21
alt local_node_id_to_def( fcx, rhs_id) {
@@ -29,7 +32,7 @@ fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) {
29
32
}
30
33
31
34
fn handle_move_or_copy ( fcx : fn_ctxt , post : poststate , rhs_path: @path,
32
- rhs_id : node_id , instlhs : inst , init_op : init_op ) {
35
+ rhs_id : node_id , destlhs : dest , init_op : init_op ) {
33
36
forbid_upvar ( fcx, rhs_id, rhs_path. span , op_to_oper_ty ( init_op) ) ;
34
37
35
38
let rhs_d_id = local_node_id_to_def_id ( fcx, rhs_id) ;
@@ -38,8 +41,13 @@ fn handle_move_or_copy(fcx: fn_ctxt, post: poststate, rhs_path: @path,
38
41
// RHS is a local var
39
42
let instrhs =
40
43
{ ident: path_to_ident ( rhs_path) , node: rhsid. node } ;
41
- copy_in_poststate ( fcx, post, instlhs, instrhs,
42
- op_to_oper_ty ( init_op) ) ;
44
+ alt destlhs {
45
+ local_dest( instlhs) {
46
+ copy_in_poststate ( fcx, post, instlhs, instrhs,
47
+ op_to_oper_ty ( init_op) ) ;
48
+ }
49
+ _ { }
50
+ }
43
51
}
44
52
_ {
45
53
// not a local -- do nothing
@@ -74,15 +82,20 @@ fn seq_states(fcx: fn_ctxt, pres: prestate, bindings: [binding]) ->
74
82
changed |=
75
83
find_pre_post_state_expr ( fcx, post, an_init. expr ) || changed;
76
84
post = tritv_clone ( expr_poststate ( fcx. ccx , an_init. expr ) ) ;
77
- for b. lhs. each { |i |
85
+ for b. lhs. each { |d |
78
86
alt an_init. expr. node {
79
87
expr_path( p) {
80
- handle_move_or_copy( fcx, post, p, an_init. expr. id, i ,
88
+ handle_move_or_copy( fcx, post, p, an_init. expr. id, d ,
81
89
an_init. op) ;
82
90
}
83
91
_ { }
84
92
}
85
- set_in_poststate_ident ( fcx, i. node , i. ident , post) ;
93
+ alt d {
94
+ local_dest( i) {
95
+ set_in_poststate_ident ( fcx, i. node , i. ident , post) ;
96
+ }
97
+ _ { }
98
+ }
86
99
}
87
100
88
101
// Forget the RHS if we just moved it.
@@ -91,9 +104,14 @@ fn seq_states(fcx: fn_ctxt, pres: prestate, bindings: [binding]) ->
91
104
}
92
105
}
93
106
none {
94
- for b. lhs . each { |i |
107
+ for b. lhs . each { |d |
95
108
// variables w/o an initializer
96
- clear_in_poststate_ident_ ( fcx, i. node , i. ident , post) ;
109
+ alt check d {
110
+ // would be an error to pass something uninit'd to a call
111
+ local_dest( i) {
112
+ clear_in_poststate_ident_ ( fcx, i. node , i. ident , post) ;
113
+ }
114
+ }
97
115
}
98
116
}
99
117
}
@@ -198,7 +216,7 @@ fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr,
198
216
fn find_pre_post_state_exprs ( fcx : fn_ctxt , pres : prestate , id : node_id ,
199
217
ops : [ init_op ] , es : [ @expr] , cf : ret_style ) ->
200
218
bool {
201
- let rs = seq_states ( fcx, pres, anon_bindings ( ops, es) ) ;
219
+ let rs = seq_states ( fcx, pres, arg_bindings ( ops, es) ) ;
202
220
let mut changed = rs. changed | set_prestate_ann ( fcx. ccx , id, pres) ;
203
221
/* if this is a failing call, it sets everything as initialized */
204
222
alt cf {
@@ -371,6 +389,8 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
371
389
return_val) ;
372
390
}
373
391
expr_call ( operator, operands, _) {
392
+ #debug ( "hey it's a call" ) ;
393
+ log_expr ( * e) ;
374
394
ret find_pre_post_state_call ( fcx, pres, operator, e. id ,
375
395
callee_arg_init_ops ( fcx, operator. id ) ,
376
396
operands,
0 commit comments