Skip to content

Commit 089c28a

Browse files
committed
---
yaml --- r: 14553 b: refs/heads/try c: c3ae72d h: refs/heads/master i: 14551: 3ec6daf v: v3
1 parent 124a55d commit 089c28a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 0da1aca498114a1caa608592dd63bebee615755e
5+
refs/heads/try: c3ae72d60b170e193cb006b7e880404b34984a82
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/comp/middle/kind.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id,
7070
// Check that the free variables used in a shared/sendable closure conform
7171
// to the copy/move kind bounds. Then recursively check the function body.
7272
fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
73-
id: node_id, cx: ctx, v: visit::vt<ctx>) {
73+
fn_id: node_id, cx: ctx, v: visit::vt<ctx>) {
7474

7575
// n.b.: This could be the body of either a fn decl or a fn expr. In the
7676
// former case, the prototype will be proto_bare and no check occurs. In
@@ -82,15 +82,22 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
8282
// "future-proof" to do it this way, as check_fn_body() is supposed to be
8383
// the common flow point for all functions that appear in the AST.
8484

85-
with_appropriate_checker(cx, id) { |checker|
86-
for @{def, span} in *freevars::get_freevars(cx.tcx, id) {
85+
with_appropriate_checker(cx, fn_id) { |checker|
86+
for @{def, span} in *freevars::get_freevars(cx.tcx, fn_id) {
8787
let id = ast_util::def_id_of_def(def).node;
88+
if checker == check_copy {
89+
let last_uses = alt check cx.last_uses.find(fn_id) {
90+
some(last_use::closes_over(vars)) { vars }
91+
none { [] }
92+
};
93+
if option::is_some(vec::position_elt(last_uses, id)) { cont; }
94+
}
8895
let ty = ty::node_id_to_type(cx.tcx, id);
8996
checker(cx, ty, span);
9097
}
9198
}
9299

93-
visit::visit_fn(fk, decl, body, sp, id, cx, v);
100+
visit::visit_fn(fk, decl, body, sp, fn_id, cx, v);
94101
}
95102

96103
fn check_fn_cap_clause(cx: ctx,

0 commit comments

Comments
 (0)