@@ -40,7 +40,12 @@ type region_map = {
40
40
/* Mapping from an AST type node to the region that `&` resolves to. */
41
41
ast_type_to_inferred_region : hashmap < ast:: node_id , ty:: region > ,
42
42
/* 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 >
44
49
} ;
45
50
46
51
type ctxt = {
@@ -249,6 +254,17 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
249
254
}
250
255
visit:: visit_expr ( expr, cx, visitor) ;
251
256
}
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
+ }
252
268
_ { visit : : visit_expr ( expr, cx, visitor) ; }
253
269
}
254
270
}
@@ -276,7 +292,8 @@ fn resolve_crate(sess: session, def_map: resolve::def_map, crate: @ast::crate)
276
292
region_name_to_fn : new_def_hash ( ) ,
277
293
ast_type_to_inferred_region :
278
294
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 ( ) } ,
280
297
mut bindings: @list:: nil,
281
298
mut queued_locals: [ ] ,
282
299
parent: pa_crate,
0 commit comments