Skip to content

Commit be6939e

Browse files
committed
---
yaml --- r: 14830 b: refs/heads/try c: c3516f0 h: refs/heads/master v: v3
1 parent d589582 commit be6939e

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-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: ffc1d0a55d66a83bfde3f45e85c6fc90e5b8240a
5+
refs/heads/try: c3516f091bbf051f8f9d40ea0dda9ab8c4584e74
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/region.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ type region_map = {
4040
/* Mapping from an AST type node to the region that `&` resolves to. */
4141
ast_type_to_inferred_region: hashmap<ast::node_id,ty::region>,
4242
/* Mapping from a call site (or `bind` site) to its containing block. */
43-
call_site_to_block: hashmap<ast::node_id,ast::node_id>
43+
call_site_to_block: hashmap<ast::node_id,ast::node_id>,
44+
/*
45+
* Mapping from an address-of operator or alt expression to its containing
46+
* block. This is used as the region if the operand is an rvalue.
47+
*/
48+
rvalue_to_block: hashmap<ast::node_id,ast::node_id>
4449
};
4550

4651
type ctxt = {
@@ -249,6 +254,17 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
249254
}
250255
visit::visit_expr(expr, cx, visitor);
251256
}
257+
ast::expr_addr_of(_, _) | ast::expr_alt(_, _, _) {
258+
// Record the block that this expression appears in, in case the
259+
// operand is an rvalue.
260+
alt cx.parent {
261+
pa_block(blk_id) {
262+
cx.region_map.rvalue_to_block.insert(expr.id, blk_id);
263+
}
264+
_ { cx.sess.span_bug(expr.span, "expr outside of block?!"); }
265+
}
266+
visit::visit_expr(expr, cx, visitor);
267+
}
252268
_ { visit::visit_expr(expr, cx, visitor); }
253269
}
254270
}
@@ -276,7 +292,8 @@ fn resolve_crate(sess: session, def_map: resolve::def_map, crate: @ast::crate)
276292
region_name_to_fn: new_def_hash(),
277293
ast_type_to_inferred_region:
278294
map::new_int_hash(),
279-
call_site_to_block: map::new_int_hash()},
295+
call_site_to_block: map::new_int_hash(),
296+
rvalue_to_block: map::new_int_hash()},
280297
mut bindings: @list::nil,
281298
mut queued_locals: [],
282299
parent: pa_crate,

branches/try/src/rustc/middle/typeck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,8 +1931,8 @@ fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region {
19311931
"index, or deref operations");
19321932
}
19331933
_ {
1934-
fcx.ccx.tcx.sess.span_err(expr.span, "not an lvalue");
1935-
ret ty::re_block(0);
1934+
let blk_id = fcx.ccx.tcx.region_map.rvalue_to_block.get(expr.id);
1935+
ret ty::re_block(blk_id);
19361936
}
19371937
}
19381938
}

0 commit comments

Comments
 (0)