@@ -434,13 +434,22 @@ pub fn trans_trait_callee(bcx: @mut Block,
434
434
let _icx = push_ctxt ( "impl::trans_trait_callee" ) ;
435
435
let mut bcx = bcx;
436
436
437
+ // make a local copy for trait if needed
437
438
let self_ty = expr_ty_adjusted ( bcx, self_expr) ;
438
- let self_scratch = scratch_datum ( bcx, self_ty, "__trait_callee" , false ) ;
439
- bcx = expr:: trans_into ( bcx, self_expr, expr:: SaveIn ( self_scratch. val ) ) ;
439
+ let self_scratch = match ty:: get ( self_ty) . sty {
440
+ ty:: ty_trait( _, _, ty:: RegionTraitStore ( * ) , _, _) => {
441
+ unpack_datum ! ( bcx, expr:: trans_to_datum( bcx, self_expr) )
442
+ }
443
+ _ => {
444
+ let d = scratch_datum ( bcx, self_ty, "__trait_callee" , false ) ;
445
+ bcx = expr:: trans_into ( bcx, self_expr, expr:: SaveIn ( d. val ) ) ;
446
+ // Arrange a temporary cleanup for the object in case something
447
+ // should go wrong before the method is actually *invoked*.
448
+ d. add_clean ( bcx) ;
449
+ d
450
+ }
451
+ } ;
440
452
441
- // Arrange a temporary cleanup for the object in case something
442
- // should go wrong before the method is actually *invoked*.
443
- self_scratch. add_clean ( bcx) ;
444
453
445
454
let callee_ty = node_id_type ( bcx, callee_id) ;
446
455
trans_trait_callee_from_llval ( bcx,
0 commit comments