@@ -110,7 +110,7 @@ fn visit_expr(cx: @ctx, ex: @ast::expr, sc: scope, v: vt<scope>) {
110
110
let handled = true ;
111
111
alt ex. node {
112
112
ast:: expr_call ( f, args, _) {
113
- check_call ( * cx, f, args) ;
113
+ check_call ( * cx, sc , f, args) ;
114
114
handled = false ;
115
115
}
116
116
ast:: expr_alt ( input, arms) { check_alt ( * cx, input, arms, sc, v) ; }
@@ -234,7 +234,8 @@ fn cant_copy(cx: ctx, b: binding) -> bool {
234
234
} else { ret true ; }
235
235
}
236
236
237
- fn check_call ( cx : ctx , f : @ast:: expr , args : [ @ast:: expr ] ) -> [ binding ] {
237
+ fn check_call ( cx : ctx , sc : scope , f : @ast:: expr , args : [ @ast:: expr ] )
238
+ -> [ binding ] {
238
239
let fty = ty:: expr_ty ( cx. tcx , f) ;
239
240
let by_ref = alt ty:: ty_fn_ret_style ( cx. tcx , fty) {
240
241
ast:: return_ref ( _, arg_n) { arg_n } _ { 0 u }
@@ -276,7 +277,18 @@ fn check_call(cx: ctx, f: @ast::expr, args: [@ast::expr]) -> [binding] {
276
277
if f_may_close {
277
278
let i = 0 u;
278
279
for b in bindings {
279
- if vec:: len ( b. unsafe_tys ) > 0 u && cant_copy ( cx, b) {
280
+ let unsfe = vec:: len ( b. unsafe_tys ) > 0 u;
281
+ alt b. root_var {
282
+ some ( rid) {
283
+ for o in sc. bs {
284
+ if o. node_id == rid && vec:: len ( o. unsafe_tys ) > 0 u {
285
+ unsfe = true ; break ;
286
+ }
287
+ }
288
+ }
289
+ _ { }
290
+ }
291
+ if unsfe && cant_copy ( cx, b) {
280
292
err ( cx, f. span , #fmt[ "function may alias with argument \
281
293
%u, which is not immutably rooted", i] ) ;
282
294
}
0 commit comments