@@ -133,8 +133,8 @@ pub fn trans_self_arg(bcx: block,
133
133
let _icx = push_ctxt ( "impl::trans_self_arg" ) ;
134
134
let mut temp_cleanups = ~[ ] ;
135
135
136
- // Compute the type of self.
137
- let self_ty = monomorphize_type ( bcx, mentry . self_ty ) ;
136
+ // self is passed as an opaque box in the environment slot
137
+ let self_ty = ty :: mk_opaque_box ( bcx. tcx ( ) ) ;
138
138
let result = trans_arg_expr ( bcx,
139
139
self_ty,
140
140
mentry. self_mode ,
@@ -576,7 +576,6 @@ pub fn trans_trait_callee_from_llval(bcx: block,
576
576
let llbox = Load ( bcx, GEPi ( bcx, llpair, [ 0 u, abi:: trt_field_box] ) ) ;
577
577
578
578
// Munge `llself` appropriately for the type of `self` in the method.
579
- let self_mode;
580
579
match explicit_self {
581
580
ast:: sty_static => {
582
581
bcx. tcx ( ) . sess . bug ( "shouldn't see static method here" ) ;
@@ -597,12 +596,6 @@ pub fn trans_trait_callee_from_llval(bcx: block,
597
596
llself = llbox;
598
597
}
599
598
}
600
-
601
- let llscratch = alloca ( bcx, val_ty ( llself) ) ;
602
- Store ( bcx, llself, llscratch) ;
603
- llself = llscratch;
604
-
605
- self_mode = ty:: ByRef ;
606
599
}
607
600
ast:: sty_box( _) => {
608
601
// Bump the reference count on the box.
@@ -615,28 +608,20 @@ pub fn trans_trait_callee_from_llval(bcx: block,
615
608
ty:: BoxTraitStore => llself = llbox,
616
609
_ => bcx. tcx ( ) . sess . bug ( "@self receiver with non-@Trait" )
617
610
}
618
-
619
- let llscratch = alloca ( bcx, val_ty ( llself) ) ;
620
- Store ( bcx, llself, llscratch) ;
621
- llself = llscratch;
622
-
623
- self_mode = ty:: ByRef ;
624
611
}
625
612
ast:: sty_uniq( _) => {
626
613
// Pass the unique pointer.
627
614
match store {
628
615
ty:: UniqTraitStore => llself = llbox,
629
616
_ => bcx. tcx ( ) . sess . bug ( "~self receiver with non-~Trait" )
630
617
}
631
-
632
- let llscratch = alloca ( bcx, val_ty ( llself) ) ;
633
- Store ( bcx, llself, llscratch) ;
634
- llself = llscratch;
635
-
636
- self_mode = ty:: ByRef ;
637
618
}
638
619
}
639
620
621
+ let llscratch = alloca ( bcx, val_ty ( llself) ) ;
622
+ Store ( bcx, llself, llscratch) ;
623
+ llself = PointerCast ( bcx, llscratch, Type :: opaque_box ( ccx) . ptr_to ( ) ) ;
624
+
640
625
// Load the function from the vtable and cast it to the expected type.
641
626
debug ! ( "(translating trait callee) loading method" ) ;
642
627
let llcallee_ty = type_of_fn_from_ty ( ccx, callee_ty) ;
@@ -652,7 +637,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
652
637
llfn : mptr,
653
638
llself : llself,
654
639
self_ty : ty:: mk_opaque_box ( bcx. tcx ( ) ) ,
655
- self_mode : self_mode ,
640
+ self_mode : ty :: ByRef ,
656
641
explicit_self : explicit_self
657
642
/* XXX: Some(llbox) */
658
643
} )
0 commit comments