@@ -2563,6 +2563,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr,
2563
2563
}
2564
2564
none { trans_temp_lval( cx, e) }
2565
2565
} ;
2566
+ #debug ( " pre-adaptation value: %s" , val_str ( lv. bcx . ccx ( ) . tn , lv. val ) ) ;
2566
2567
let lv = adapt_borrowed_value ( lv, arg, e) ;
2567
2568
let mut bcx = lv. bcx ;
2568
2569
let mut val = lv. val ;
@@ -2618,7 +2619,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr,
2618
2619
}
2619
2620
2620
2621
if !is_bot && arg. ty != e_ty || ty:: type_has_params ( arg. ty ) {
2621
- #debug ( " casting from %s" , val_str ( bcx. ccx ( ) . tn , val) ) ;
2622
+ #debug ( " casting from %s" , val_str ( bcx. ccx ( ) . tn , val) ) ;
2622
2623
val = PointerCast ( bcx, val, lldestty) ;
2623
2624
}
2624
2625
#debug ( "--- trans_arg_expr passing %s" , val_str ( bcx. ccx ( ) . tn , val) ) ;
@@ -2652,10 +2653,21 @@ fn adapt_borrowed_value(lv: lval_result, _arg: ty::arg,
2652
2653
ty:: ty_estr ( _) |
2653
2654
ty:: ty_evec ( _, _) {
2654
2655
let ccx = bcx. ccx ( ) ;
2656
+ let val = alt lv. kind {
2657
+ temporary { lv. val }
2658
+ owned { load_if_immediate( bcx, lv. val , e_ty) }
2659
+ owned_imm { lv. val }
2660
+ } ;
2661
+
2655
2662
let unit_ty = ty:: sequence_element_type ( ccx. tcx , e_ty) ;
2656
2663
let llunit_ty = type_of ( ccx, unit_ty) ;
2657
- let ( base, len) = tvec:: get_base_and_len ( bcx, lv . val , e_ty) ;
2664
+ let ( base, len) = tvec:: get_base_and_len ( bcx, val, e_ty) ;
2658
2665
let p = alloca ( bcx, T_struct ( [ T_ptr ( llunit_ty) , ccx. int_type ] ) ) ;
2666
+
2667
+ #debug ( "adapt_borrowed_value: adapting %s to %s" ,
2668
+ val_str ( bcx. ccx ( ) . tn , val) ,
2669
+ val_str ( bcx. ccx ( ) . tn , p) ) ;
2670
+
2659
2671
Store ( bcx, base, GEPi ( bcx, p, [ 0 , abi:: slice_elt_base] ) ) ;
2660
2672
Store ( bcx, len, GEPi ( bcx, p, [ 0 , abi:: slice_elt_len] ) ) ;
2661
2673
ret lval_temp( bcx, p) ;
@@ -3064,12 +3076,7 @@ fn trans_expr_save_in(bcx: block, e: @ast::expr, dest: ValueRef)
3064
3076
fn trans_temp_lval ( bcx : block , e : @ast:: expr ) -> lval_result {
3065
3077
let _icx = bcx. insn_ctxt ( "trans_temp_lval" ) ;
3066
3078
let mut bcx = bcx;
3067
- if expr_is_lval ( bcx, e) && !expr_is_borrowed ( bcx, e) {
3068
- // if the expression is borrowed, then are not actually passing the
3069
- // lvalue itself, but rather an adaptation of it. This is a bit of a
3070
- // hack, though, but it only needs to exist so long as we have
3071
- // reference modes and the like---otherwise, all potentially borrowed
3072
- // things will go directly through trans_expr() as they ought to.
3079
+ if expr_is_lval ( bcx, e) {
3073
3080
ret trans_lval ( bcx, e) ;
3074
3081
} else {
3075
3082
let ty = expr_ty ( bcx, e) ;
0 commit comments