Skip to content

Commit fed3616

Browse files
committed
---
yaml --- r: 107424 b: refs/heads/dist-snap c: 84f33fb h: refs/heads/master v: v3
1 parent 4c91514 commit fed3616

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
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: 6badef49fe502ca22aaabd4309bd899eea4144d4
9+
refs/heads/dist-snap: 84f33fb13415b74fc5b29ee4162efb86f8b06e9c
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: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -440,39 +440,31 @@ pub fn trans_trait_callee<'a>(
440440
let _icx = push_ctxt("impl::trans_trait_callee");
441441
let mut bcx = bcx;
442442

443-
// make a local copy for trait if needed
444-
let self_ty = expr_ty_adjusted(bcx, self_expr);
445-
let self_scratch = match ty::get(self_ty).sty {
446-
ty::ty_trait(_, _, ty::RegionTraitStore(..), _, _) => {
447-
unpack_datum!(bcx, expr::trans(bcx, self_expr))
448-
}
449-
_ => {
450-
// Arrange a temporary cleanup for the object in case something
451-
// should go wrong before the method is actually *invoked*.
452-
let datum = unpack_datum!(
453-
bcx,
454-
lvalue_scratch_datum(
455-
bcx, self_ty, "__trait_callee", false, arg_cleanup_scope, (),
456-
|(), bcx, llval| expr::trans_into(bcx, self_expr,
457-
expr::SaveIn(llval))));
458-
datum.to_expr_datum()
459-
}
460-
};
443+
// Translate self_datum and take ownership of the value by
444+
// converting to an rvalue.
445+
let self_datum = unpack_datum!(
446+
bcx, expr::trans(bcx, self_expr));
447+
let self_datum = unpack_datum!(
448+
bcx, self_datum.to_rvalue_datum(bcx, "trait_callee"));
449+
450+
// Convert to by-ref since `trans_trait_callee_from_llval` wants it
451+
// that way.
452+
let self_datum = unpack_datum!(
453+
bcx, self_datum.to_ref_datum(bcx));
454+
455+
// Arrange cleanup in case something should go wrong before the
456+
// actual call occurs.
457+
let llval = self_datum.add_clean(bcx.fcx, arg_cleanup_scope);
461458

462459
let callee_ty = node_id_type(bcx, callee_id);
463-
assert!(self_scratch.kind.is_by_ref()); // FIXME why special case above??
464-
trans_trait_callee_from_llval(bcx,
465-
callee_ty,
466-
n_method,
467-
self_scratch.val)
460+
trans_trait_callee_from_llval(bcx, callee_ty, n_method, llval)
468461
}
469462

470-
pub fn trans_trait_callee_from_llval<'a>(
471-
bcx: &'a Block<'a>,
472-
callee_ty: ty::t,
473-
n_method: uint,
474-
llpair: ValueRef)
475-
-> Callee<'a> {
463+
pub fn trans_trait_callee_from_llval<'a>(bcx: &'a Block<'a>,
464+
callee_ty: ty::t,
465+
n_method: uint,
466+
llpair: ValueRef)
467+
-> Callee<'a> {
476468
/*!
477469
* Same as `trans_trait_callee()` above, except that it is given
478470
* a by-ref pointer to the object pair.
@@ -641,8 +633,8 @@ pub fn trans_trait_cast<'a>(bcx: &'a Block<'a>,
641633
/*!
642634
* Generates the code to convert from a pointer (`~T`, `&T`, etc)
643635
* into an object (`~Trait`, `&Trait`, etc). This means creating a
644-
* pair where the first word is the pointer and the second word is
645-
* an appropriate vtable.
636+
* pair where the first word is the vtable and the second word is
637+
* the pointer.
646638
*/
647639

648640
let mut bcx = bcx;

0 commit comments

Comments
 (0)