Skip to content

Commit 5a81a2c

Browse files
committed
---
yaml --- r: 6415 b: refs/heads/master c: 02574a5 h: refs/heads/master i: 6413: 3c905eb 6411: feb8fef 6407: 766be96 6399: eaaa939 v: v3
1 parent badbe6c commit 5a81a2c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b4217b383bbbebafbdc621f31716d5bee3cd0c72
2+
refs/heads/master: 02574a5bdb7900fd6b40bf4f3c93080eafa35d4e

trunk/src/comp/middle/alias.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn visit_expr(cx: @ctx, ex: @ast::expr, sc: scope, v: vt<scope>) {
110110
let handled = true;
111111
alt ex.node {
112112
ast::expr_call(f, args, _) {
113-
check_call(*cx, f, args);
113+
check_call(*cx, sc, f, args);
114114
handled = false;
115115
}
116116
ast::expr_alt(input, arms) { check_alt(*cx, input, arms, sc, v); }
@@ -234,7 +234,8 @@ fn cant_copy(cx: ctx, b: binding) -> bool {
234234
} else { ret true; }
235235
}
236236

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] {
238239
let fty = ty::expr_ty(cx.tcx, f);
239240
let by_ref = alt ty::ty_fn_ret_style(cx.tcx, fty) {
240241
ast::return_ref(_, arg_n) { arg_n } _ { 0u }
@@ -276,7 +277,18 @@ fn check_call(cx: ctx, f: @ast::expr, args: [@ast::expr]) -> [binding] {
276277
if f_may_close {
277278
let i = 0u;
278279
for b in bindings {
279-
if vec::len(b.unsafe_tys) > 0u && cant_copy(cx, b) {
280+
let unsfe = vec::len(b.unsafe_tys) > 0u;
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) > 0u {
285+
unsfe = true; break;
286+
}
287+
}
288+
}
289+
_ {}
290+
}
291+
if unsfe && cant_copy(cx, b) {
280292
err(cx, f.span, #fmt["function may alias with argument \
281293
%u, which is not immutably rooted", i]);
282294
}

0 commit comments

Comments
 (0)