Skip to content

Commit 42cb896

Browse files
eddybalexcrichton
authored andcommitted
---
yaml --- r: 108287 b: refs/heads/dist-snap c: 3af5f38 h: refs/heads/master i: 108285: 377d95a 108283: 0168102 108279: 1a313a1 108271: 6de2438 108255: 1c424db 108223: 6ab30bd 108159: 6d1f1cf 108031: eaec36e v: v3
1 parent 2e9d309 commit 42cb896

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
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: ee2a888860ea496b5a972ed35fb742b4ae008233
9+
refs/heads/dist-snap: 3af5f38f3c3a41376f396fedf7149f1dbe0ef039
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

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