@@ -129,28 +129,20 @@ pub fn trans_method(ccx: @mut CrateContext,
129
129
130
130
pub fn trans_self_arg ( bcx : block ,
131
131
base : @ast:: expr ,
132
+ temp_cleanups : & mut ~[ ValueRef ] ,
132
133
mentry : typeck:: method_map_entry ) -> Result {
133
134
let _icx = push_ctxt ( "impl::trans_self_arg" ) ;
134
- let mut temp_cleanups = ~[ ] ;
135
135
136
136
// self is passed as an opaque box in the environment slot
137
137
let self_ty = ty:: mk_opaque_box ( bcx. tcx ( ) ) ;
138
- let result = trans_arg_expr ( bcx,
139
- self_ty,
140
- mentry. self_mode ,
141
- mentry. explicit_self ,
142
- base,
143
- & mut temp_cleanups,
144
- None ,
145
- DontAutorefArg ) ;
146
-
147
- // FIXME(#3446)---this is wrong, actually. The temp_cleanups
148
- // should be revoked only after all arguments have been passed.
149
- for temp_cleanups. iter( ) . advance |c| {
150
- revoke_clean( bcx, * c)
151
- }
152
-
153
- return result;
138
+ trans_arg_expr ( bcx,
139
+ self_ty,
140
+ mentry. self_mode ,
141
+ mentry. explicit_self ,
142
+ base,
143
+ temp_cleanups,
144
+ None ,
145
+ DontAutorefArg )
154
146
}
155
147
156
148
pub fn trans_method_callee ( bcx : block ,
@@ -203,12 +195,14 @@ pub fn trans_method_callee(bcx: block,
203
195
match origin {
204
196
typeck:: method_static( did) => {
205
197
let callee_fn = callee:: trans_fn_ref ( bcx, did, callee_id) ;
206
- let Result { bcx, val} = trans_self_arg ( bcx, this, mentry) ;
198
+ let mut temp_cleanups = ~[ ] ;
199
+ let Result { bcx, val} = trans_self_arg ( bcx, this, & mut temp_cleanups, mentry) ;
207
200
Callee {
208
201
bcx : bcx,
209
202
data : Method ( MethodData {
210
203
llfn : callee_fn. llfn ,
211
204
llself : val,
205
+ temp_cleanup : temp_cleanups. head_opt ( ) . map ( |& v| * v) ,
212
206
self_ty : node_id_type ( bcx, this. id ) ,
213
207
self_mode : mentry. self_mode ,
214
208
explicit_self : mentry. explicit_self
@@ -254,9 +248,8 @@ pub fn trans_method_callee(bcx: block,
254
248
store,
255
249
mentry. explicit_self )
256
250
}
257
- typeck:: method_super( * ) => {
258
- fail ! ( "method_super should have been handled \
259
- above")
251
+ typeck:: method_super( * ) => {
252
+ fail ! ( "method_super should have been handled above" )
260
253
}
261
254
}
262
255
}
@@ -413,8 +406,9 @@ pub fn trans_monomorphized_callee(bcx: block,
413
406
bcx. ccx ( ) , impl_did, mname) ;
414
407
415
408
// obtain the `self` value:
409
+ let mut temp_cleanups = ~[ ] ;
416
410
let Result { bcx, val : llself_val} =
417
- trans_self_arg ( bcx, base, mentry) ;
411
+ trans_self_arg ( bcx, base, & mut temp_cleanups , mentry) ;
418
412
419
413
// create a concatenated set of substitutions which includes
420
414
// those from the impl and those from the method:
@@ -441,6 +435,7 @@ pub fn trans_monomorphized_callee(bcx: block,
441
435
data : Method ( MethodData {
442
436
llfn : llfn_val,
443
437
llself : llself_val,
438
+ temp_cleanup : temp_cleanups. head_opt ( ) . map ( |& v| * v) ,
444
439
self_ty : node_id_type ( bcx, base. id ) ,
445
440
self_mode : mentry. self_mode ,
446
441
explicit_self : mentry. explicit_self
@@ -636,6 +631,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
636
631
data : Method ( MethodData {
637
632
llfn : mptr,
638
633
llself : llself,
634
+ temp_cleanup : None ,
639
635
self_ty : ty:: mk_opaque_box ( bcx. tcx ( ) ) ,
640
636
self_mode : ty:: ByRef ,
641
637
explicit_self : explicit_self
0 commit comments