Skip to content

Commit e5e921d

Browse files
committed
---
yaml --- r: 5311 b: refs/heads/master c: 75eee8b h: refs/heads/master i: 5309: e9fb01c 5307: d03b244 5303: b46017b 5295: 112b79f 5279: 2dd3691 5247: aa3e89b v: v3
1 parent 2c917a6 commit e5e921d

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 87fa38910eb78c116cd34b2524edd9c1cfe97228
2+
refs/heads/master: 75eee8b194231c2fe808242a9828253125b854c8

trunk/src/comp/middle/alias.rs

+27-34
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> copy_map {
4747
copy_map: std::map::new_int_hash()};
4848
let v = @{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _),
4949
visit_expr: bind visit_expr(cx, _, _, _),
50-
visit_decl: bind visit_decl(cx, _, _, _),
5150
visit_block: bind visit_block(cx, _, _, _)
5251
with *visit::default_visitor::<scope>()};
5352
visit::visit_crate(*crate, {bs: [], ret_style: ast::return_val},
@@ -132,46 +131,38 @@ fn visit_expr(cx: @ctx, ex: @ast::expr, sc: scope, v: vt<scope>) {
132131
if !handled { visit::visit_expr(ex, sc, v); }
133132
}
134133

135-
fn visit_decl(cx: @ctx, d: @ast::decl, sc: scope, v: vt<scope>) {
136-
visit::visit_decl(d, sc, v);
137-
alt d.node {
138-
ast::decl_local(locs) {
139-
for (_, loc) in locs {
140-
alt loc.node.init {
141-
some(init) {
142-
if init.op == ast::init_move {
143-
check_lval(cx, init.expr, sc, v);
144-
}
145-
}
146-
none. { }
147-
}
148-
}
149-
}
150-
_ { }
151-
}
152-
}
153-
154134
fn visit_block(cx: @ctx, b: ast::blk, sc: scope, v: vt<scope>) {
155-
let ref_locs = [];
135+
let bs = sc.bs;
156136
for stmt in b.node.stmts {
157137
alt stmt.node {
158-
ast::stmt_decl(@{node: ast::decl_local(ls), _}, _) {
159-
for (st, loc) in ls {
138+
ast::stmt_decl(@{node: ast::decl_item(it), _}, _) {
139+
v.visit_item(it, sc, v);
140+
}
141+
ast::stmt_decl(@{node: ast::decl_local(locs), _}, _) {
142+
for (st, loc) in locs {
160143
if st == ast::let_ref {
161-
ref_locs += [loc];
144+
add_bindings_for_let(*cx, bs, loc);
145+
sc = {bs: bs with sc};
146+
}
147+
alt loc.node.init {
148+
some(init) {
149+
if init.op == ast::init_move {
150+
check_lval(cx, init.expr, sc, v);
151+
}
152+
}
153+
none. { }
162154
}
163155
}
164156
}
165-
_ {}
157+
ast::stmt_expr(ex, _) {
158+
v.visit_expr(ex, sc, v);
159+
}
160+
ast::stmt_crate_directive(cd) {
161+
visit::visit_crate_directive(cd, sc, v);
162+
}
166163
}
167164
}
168-
if vec::len(ref_locs) > 0u {
169-
let bindings = sc.bs;
170-
for loc in ref_locs { add_bindings_for_let(*cx, bindings, loc); }
171-
visit::visit_block(b, {bs: bindings with sc}, v);
172-
} else {
173-
visit::visit_block(b, sc, v);
174-
}
165+
visit::visit_expr_opt(b.node.expr, sc, v);
175166
}
176167

177168
fn add_bindings_for_let(cx: ctx, &bs: [binding], loc: @ast::local) {
@@ -192,12 +183,14 @@ fn add_bindings_for_let(cx: ctx, &bs: [binding], loc: @ast::local) {
192183
let ret_style = ty::ty_fn_ret_style(cx.tcx, fty);
193184
if ast_util::ret_by_ref(ret_style) {
194185
// FIXME pick right arg
195-
let arg_root = expr_root(cx.tcx, args[0], false);
186+
let arg = args[0];
187+
let arg_root = expr_root(cx.tcx, arg, false);
196188
root_var = path_def_id(cx, arg_root.ex);
197189
if !is_none(root_var) {
198190
is_temp = false;
199191
if ret_style == ast::return_ref(true) {
200-
outer_ds = [@{mut: true with *arg_root.ds[0]}];
192+
outer_ds = [@{mut: true, kind: unbox,
193+
outer_t: ty::expr_ty(cx.tcx, arg)}];
201194
}
202195
outer_ds = *arg_root.ds + outer_ds;
203196
}

0 commit comments

Comments
 (0)