Skip to content

Commit 26db611

Browse files
eddybalexcrichton
authored andcommitted
---
yaml --- r: 101820 b: refs/heads/master c: 3af5f38 h: refs/heads/master v: v3
1 parent d4be4ff commit 26db611

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ee2a888860ea496b5a972ed35fb742b4ae008233
2+
refs/heads/master: 3af5f38f3c3a41376f396fedf7149f1dbe0ef039
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff

trunk/src/librustc/middle/trans/meth.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,24 @@ fn trans_trait_callee<'a>(bcx: &'a Block<'a>,
353353
// converting to an rvalue.
354354
let self_datum = unpack_datum!(
355355
bcx, expr::trans(bcx, self_expr));
356-
let self_datum = unpack_datum!(
357-
bcx, self_datum.to_rvalue_datum(bcx, "trait_callee"));
358356

359-
// Convert to by-ref since `trans_trait_callee_from_llval` wants it
360-
// that way.
361-
let self_datum = unpack_datum!(
362-
bcx, self_datum.to_ref_datum(bcx));
357+
let llval = if ty::type_needs_drop(bcx.tcx(), self_datum.ty) {
358+
let self_datum = unpack_datum!(
359+
bcx, self_datum.to_rvalue_datum(bcx, "trait_callee"));
360+
361+
// Convert to by-ref since `trans_trait_callee_from_llval` wants it
362+
// that way.
363+
let self_datum = unpack_datum!(
364+
bcx, self_datum.to_ref_datum(bcx));
363365

364-
// Arrange cleanup in case something should go wrong before the
365-
// actual call occurs.
366-
let llval = self_datum.add_clean(bcx.fcx, arg_cleanup_scope);
366+
// Arrange cleanup in case something should go wrong before the
367+
// actual call occurs.
368+
self_datum.add_clean(bcx.fcx, arg_cleanup_scope)
369+
} else {
370+
// We don't have to do anything about cleanups for &Trait and &mut Trait.
371+
assert!(self_datum.kind.is_by_ref());
372+
self_datum.val
373+
};
367374

368375
let callee_ty = node_id_type(bcx, callee_id);
369376
trans_trait_callee_from_llval(bcx, callee_ty, n_method, llval)

0 commit comments

Comments
 (0)