@@ -4444,7 +4444,7 @@ fn trans_be(cx: @block_ctxt, e: @ast::expr) : ast_util::is_call_expr(e) ->
4444
4444
ret trans_ret ( cx, some ( e) ) ;
4445
4445
}
4446
4446
4447
- fn init_local ( bcx : @block_ctxt , local : @ast:: local ) -> result {
4447
+ fn init_local ( bcx : @block_ctxt , local : @ast:: local ) -> @ block_ctxt {
4448
4448
let ty = node_id_type ( bcx_ccx ( bcx) , local. node . id ) ;
4449
4449
let llptr = bcx. fcx . lllocals . get ( local. node . id ) ;
4450
4450
// Make a note to drop this slot on the way out.
@@ -4476,7 +4476,7 @@ fn init_local(bcx: @block_ctxt, local: @ast::local) -> result {
4476
4476
bcx =
4477
4477
trans_alt:: bind_irrefutable_pat ( bcx, local. node . pat , llptr,
4478
4478
bcx. fcx . lllocals , false ) ;
4479
- ret rslt ( bcx, llptr ) ;
4479
+ ret bcx;
4480
4480
4481
4481
fn must_zero ( ccx : @crate_ctxt , local : @ast:: local ) -> bool {
4482
4482
alt local. node . init {
@@ -4513,6 +4513,14 @@ fn init_local(bcx: @block_ctxt, local: @ast::local) -> result {
4513
4513
}
4514
4514
}
4515
4515
4516
+ fn init_ref_local ( bcx : @block_ctxt , local : @ast:: local ) -> @block_ctxt {
4517
+ let init_expr = option:: get ( local. node . init ) . expr ;
4518
+ let val = trans_lval ( bcx, init_expr) ;
4519
+ assert val. is_mem ;
4520
+ ret trans_alt:: bind_irrefutable_pat ( bcx, local. node . pat , val. res . val ,
4521
+ bcx. fcx . lllocals , false ) ;
4522
+ }
4523
+
4516
4524
fn zero_alloca ( cx : @block_ctxt , llptr : ValueRef , t : ty:: t ) -> result {
4517
4525
let bcx = cx;
4518
4526
let ccx = bcx_ccx ( cx) ;
@@ -4538,8 +4546,12 @@ fn trans_stmt(cx: @block_ctxt, s: ast::stmt) -> result {
4538
4546
ast:: stmt_decl ( d, _) {
4539
4547
alt d. node {
4540
4548
ast:: decl_local ( locals) {
4541
- for ( _, local) in locals {
4542
- bcx = init_local ( bcx, local) . bcx ;
4549
+ for ( style, local) in locals {
4550
+ if style == ast:: let_copy {
4551
+ bcx = init_local ( bcx, local) ;
4552
+ } else {
4553
+ bcx = init_ref_local ( bcx, local) ;
4554
+ }
4543
4555
}
4544
4556
}
4545
4557
ast:: decl_item ( i) { trans_item ( cx. fcx . lcx , * i) ; }
@@ -4646,15 +4658,14 @@ fn trans_fn_cleanups(fcx: @fn_ctxt, cx: @block_ctxt) {
4646
4658
}
4647
4659
4648
4660
iter block_locals ( b: ast:: blk) -> @ast:: local {
4649
-
4650
- // FIXME: putting from inside an iter block doesn't work, so we can't
4651
- // use the index here.
4652
4661
for s: @ast:: stmt in b. node . stmts {
4653
4662
alt s. node {
4654
4663
ast:: stmt_decl ( d, _) {
4655
4664
alt d. node {
4656
4665
ast:: decl_local ( locals) {
4657
- for ( _, local) in locals { put local; }
4666
+ for ( style, local) in locals {
4667
+ if style == ast:: let_copy { put local; }
4668
+ }
4658
4669
}
4659
4670
_ { /* fall through */ }
4660
4671
}
0 commit comments