diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 99ea455941c..01702e749a3 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -343,7 +343,6 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock { _ => {} } - let scratch = scratch_datum(bcx, target_obj_ty, "__auto_borrow_obj", false); diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 06d88f66323..934dfabbb4d 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -434,13 +434,22 @@ pub fn trans_trait_callee(bcx: @mut Block, let _icx = push_ctxt("impl::trans_trait_callee"); let mut bcx = bcx; + // make a local copy for trait if needed let self_ty = expr_ty_adjusted(bcx, self_expr); - let self_scratch = scratch_datum(bcx, self_ty, "__trait_callee", false); - bcx = expr::trans_into(bcx, self_expr, expr::SaveIn(self_scratch.val)); + let self_scratch = match ty::get(self_ty).sty { + ty::ty_trait(_, _, ty::RegionTraitStore(*), _, _) => { + unpack_datum!(bcx, expr::trans_to_datum(bcx, self_expr)) + } + _ => { + let d = scratch_datum(bcx, self_ty, "__trait_callee", false); + bcx = expr::trans_into(bcx, self_expr, expr::SaveIn(d.val)); + // Arrange a temporary cleanup for the object in case something + // should go wrong before the method is actually *invoked*. + d.add_clean(bcx); + d + } + }; - // Arrange a temporary cleanup for the object in case something - // should go wrong before the method is actually *invoked*. - self_scratch.add_clean(bcx); let callee_ty = node_id_type(bcx, callee_id); trans_trait_callee_from_llval(bcx,