will not copy trait_callee on stack if it's source expr is a plain borrowed ref
This commit is contained in:
parent
dfa3f5fa8d
commit
0c3b6ad6b8
|
@ -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);
|
||||
|
||||
|
|
|
@ -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*.
|
||||
self_scratch.add_clean(bcx);
|
||||
d.add_clean(bcx);
|
||||
d
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
let callee_ty = node_id_type(bcx, callee_id);
|
||||
trans_trait_callee_from_llval(bcx,
|
||||
|
|
Loading…
Reference in New Issue