@@ -440,39 +440,31 @@ pub fn trans_trait_callee<'a>(
440
440
let _icx = push_ctxt ( "impl::trans_trait_callee" ) ;
441
441
let mut bcx = bcx;
442
442
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) ;
461
458
462
459
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)
468
461
}
469
462
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 > {
476
468
/*!
477
469
* Same as `trans_trait_callee()` above, except that it is given
478
470
* a by-ref pointer to the object pair.
@@ -641,8 +633,8 @@ pub fn trans_trait_cast<'a>(bcx: &'a Block<'a>,
641
633
/*!
642
634
* Generates the code to convert from a pointer (`~T`, `&T`, etc)
643
635
* 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 .
646
638
*/
647
639
648
640
let mut bcx = bcx;
0 commit comments