@@ -63,6 +63,13 @@ fn find_last_uses(c: @crate, def_map: resolve::def_map,
63
63
ret mini_table;
64
64
}
65
65
66
+ fn is_block ( cx : ctx , id : node_id ) -> bool {
67
+ alt ty:: struct ( cx. tcx , ty:: node_id_to_monotype ( cx. tcx , id) ) {
68
+ ty:: ty_fn ( { proto: proto_block. , _} ) { true }
69
+ _ { false }
70
+ }
71
+ }
72
+
66
73
fn visit_expr ( ex : @expr, cx : ctx , v : visit:: vt < ctx > ) {
67
74
alt ex. node {
68
75
expr_ret ( oexpr) {
@@ -135,9 +142,8 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
135
142
let arg_ts = ty:: ty_fn_args ( cx. tcx , ty:: expr_ty ( cx. tcx , f) ) ;
136
143
for arg in args {
137
144
alt arg. node {
138
- //NDM--register captured as uses
139
- expr_fn ( _, _, _, captured) { fns += [ arg] ; }
140
- expr_fn_block ( _, _) { fns += [ arg] ; }
145
+ expr_fn ( proto_block. , _, _, _) { fns += [ arg] ; }
146
+ expr_fn_block ( _, _) when is_block( cx, arg. id ) { fns += [ arg] ; }
141
147
_ {
142
148
alt arg_ts[ i] . mode {
143
149
by_mut_ref. { clear_if_path ( cx, arg, v, false ) ; }
@@ -163,6 +169,15 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
163
169
visit:: visit_fn ( fk, decl, body, sp, id, cx, v) ;
164
170
} ) ;
165
171
} else {
172
+ alt cx. tcx . freevars . find ( id) {
173
+ some ( vars) {
174
+ for v in * vars {
175
+ clear_in_current ( cx, ast_util:: def_id_of_def ( v. def ) . node ,
176
+ false ) ;
177
+ }
178
+ }
179
+ _ { }
180
+ }
166
181
let old = nil;
167
182
cx. blocks <-> old;
168
183
visit:: visit_fn ( fk, decl, body, sp, id, cx, v) ;
0 commit comments