@@ -2706,7 +2706,8 @@ fn trans_for_each(cx: @block_ctxt, local: @ast::local, seq: @ast::expr,
2706
2706
ty:: mk_iter_body_fn ( lcx. ccx . tcx , decl_ty) , 0 u) ;
2707
2707
let lliterbody: ValueRef =
2708
2708
decl_internal_fastcall_fn ( lcx. ccx . llmod , s, iter_body_llty) ;
2709
- let fcx = new_fn_ctxt_w_id ( lcx, cx. sp , lliterbody, body. node . id ) ;
2709
+ let fcx = new_fn_ctxt_w_id ( lcx, cx. sp , lliterbody, body. node . id ,
2710
+ ast:: return_val) ;
2710
2711
fcx. iterbodyty = cx. fcx . iterbodyty ;
2711
2712
2712
2713
// Generate code to load the environment out of the
@@ -4383,8 +4384,11 @@ fn trans_ret(cx: @block_ctxt, e: option::t<@ast::expr>) -> result {
4383
4384
let t = ty:: expr_ty ( bcx_tcx ( cx) , x) ;
4384
4385
let lv = trans_lval ( cx, x) ;
4385
4386
bcx = lv. res . bcx ;
4386
- let is_local =
4387
- alt x. node {
4387
+ if cx. fcx . ret_style == ast:: return_ref {
4388
+ assert lv. is_mem ;
4389
+ Store ( bcx, cx. fcx . llretptr , lv. res . val ) ;
4390
+ } else {
4391
+ let is_local = alt x. node {
4388
4392
ast:: expr_path ( p) {
4389
4393
alt bcx_tcx ( bcx) . def_map . get ( x. id ) {
4390
4394
ast:: def_local ( _) { true }
@@ -4393,9 +4397,12 @@ fn trans_ret(cx: @block_ctxt, e: option::t<@ast::expr>) -> result {
4393
4397
}
4394
4398
_ { false }
4395
4399
} ;
4396
- if is_local {
4397
- bcx = move_val ( bcx, INIT , cx. fcx . llretptr , lv, t) ;
4398
- } else { bcx = move_val_if_temp ( bcx, INIT , cx. fcx . llretptr , lv, t) ; }
4400
+ if is_local {
4401
+ bcx = move_val ( bcx, INIT , cx. fcx . llretptr , lv, t) ;
4402
+ } else {
4403
+ bcx = move_val_if_temp ( bcx, INIT , cx. fcx . llretptr , lv, t) ;
4404
+ }
4405
+ }
4399
4406
}
4400
4407
_ {
4401
4408
let t = llvm:: LLVMGetElementType ( val_ty ( cx. fcx . llretptr ) ) ;
@@ -4822,7 +4829,8 @@ fn mk_standard_basic_blocks(llfn: ValueRef) ->
4822
4829
// - new_fn_ctxt
4823
4830
// - trans_args
4824
4831
fn new_fn_ctxt_w_id ( cx : @local_ctxt , sp : span , llfndecl : ValueRef ,
4825
- id : ast:: node_id ) -> @fn_ctxt {
4832
+ id : ast:: node_id , rstyle : ast:: ret_style )
4833
+ -> @fn_ctxt {
4826
4834
let llbbs = mk_standard_basic_blocks ( llfndecl) ;
4827
4835
ret @{ llfn : llfndecl,
4828
4836
lltaskptr : llvm:: LLVMGetParam ( llfndecl, 1 u) ,
@@ -4845,12 +4853,13 @@ fn new_fn_ctxt_w_id(cx: @local_ctxt, sp: span, llfndecl: ValueRef,
4845
4853
mutable lltydescs : [ ] ,
4846
4854
derived_tydescs : map:: mk_hashmap ( ty:: hash_ty, ty:: eq_ty) ,
4847
4855
id : id,
4856
+ ret_style : rstyle,
4848
4857
sp : sp,
4849
4858
lcx : cx} ;
4850
4859
}
4851
4860
4852
4861
fn new_fn_ctxt ( cx : @local_ctxt , sp : span , llfndecl : ValueRef ) -> @fn_ctxt {
4853
- be new_fn_ctxt_w_id ( cx, sp, llfndecl, -1 ) ;
4862
+ ret new_fn_ctxt_w_id ( cx, sp, llfndecl, -1 , ast :: return_val ) ;
4854
4863
}
4855
4864
4856
4865
// NB: must keep 4 fns in sync:
@@ -5024,7 +5033,7 @@ fn trans_closure(bcx_maybe: option::t<@block_ctxt>,
5024
5033
set_uwtable ( llfndecl) ;
5025
5034
5026
5035
// Set up arguments to the function.
5027
- let fcx = new_fn_ctxt_w_id ( cx, sp, llfndecl, id) ;
5036
+ let fcx = new_fn_ctxt_w_id ( cx, sp, llfndecl, id, f . decl . cf ) ;
5028
5037
create_llargs_for_fn_args ( fcx, f. proto , ty_self,
5029
5038
ty:: ret_ty_of_fn ( cx. ccx . tcx , id) , f. decl . inputs ,
5030
5039
ty_params) ;
0 commit comments