Skip to content

Commit e47ba26

Browse files
eddybalexcrichton
authored andcommitted
---
yaml --- r: 100796 b: refs/heads/snap-stage3 c: 3af5f38 h: refs/heads/master v: v3
1 parent 8c85334 commit e47ba26

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,7 +1,7 @@
11
---
22
refs/heads/master: e3b1f3c443c048913e2d573fcc5a9c2be3484a78
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ee2a888860ea496b5a972ed35fb742b4ae008233
4+
refs/heads/snap-stage3: 3af5f38f3c3a41376f396fedf7149f1dbe0ef039
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)