@@ -139,7 +139,6 @@ pub fn trans_self_arg(bcx: block,
139
139
140
140
// Compute the type of self.
141
141
let self_ty = monomorphize_type ( bcx, mentry. self_ty ) ;
142
-
143
142
let result = trans_arg_expr ( bcx,
144
143
self_ty,
145
144
mentry. self_mode ,
@@ -174,21 +173,6 @@ pub fn trans_method_callee(bcx: block,
174
173
// Replace method_self with method_static here.
175
174
let mut origin = mentry. origin;
176
175
match origin {
177
- typeck : : method_self( trait_id, method_index) => {
178
- // Get the ID of the impl we're inside.
179
- let impl_def_id = bcx. fcx. impl_id. get( ) ;
180
-
181
- debug ! ( "impl_def_id is %?" , impl_def_id) ;
182
-
183
- // Get the ID of the method we're calling.
184
- let method_name =
185
- ty:: trait_method( tcx, trait_id, method_index) . ident;
186
- let method_id =
187
- method_with_name_or_default( bcx. ccx( ) ,
188
- impl_def_id,
189
- method_name) ;
190
- origin = typeck:: method_static( method_id) ;
191
- }
192
176
typeck : : method_super( trait_id, method_index) => {
193
177
// <self_ty> is the self type for this method call
194
178
let self_ty = node_id_type( bcx, this. id) ;
@@ -213,6 +197,7 @@ pub fn trans_method_callee(bcx: block,
213
197
impl_id,
214
198
method_name) ) ;
215
199
}
200
+ typeck:: method_self ( * ) |
216
201
typeck:: method_static ( * ) | typeck:: method_param ( * ) |
217
202
typeck:: method_trait ( * ) => { }
218
203
}
@@ -250,6 +235,21 @@ pub fn trans_method_callee(bcx: block,
250
235
None => fail ! ( "trans_method_callee: missing param_substs" )
251
236
}
252
237
}
238
+
239
+ typeck:: method_self( trait_id, method_index) => {
240
+ match bcx. fcx . param_substs {
241
+ Some ( @param_substs
242
+ { self_vtable : Some ( ref vtbl) , _} ) => {
243
+ trans_monomorphized_callee ( bcx, callee_id, this, mentry,
244
+ trait_id, method_index,
245
+ copy * vtbl)
246
+ }
247
+ _ => {
248
+ fail ! ( "trans_method_callee: missing self_vtable" )
249
+ }
250
+ }
251
+ }
252
+
253
253
typeck:: method_trait( _, off, store) => {
254
254
trans_trait_callee ( bcx,
255
255
callee_id,
@@ -258,9 +258,9 @@ pub fn trans_method_callee(bcx: block,
258
258
store,
259
259
mentry. explicit_self )
260
260
}
261
- typeck :: method_self ( * ) | typeck:: method_super( * ) => {
262
- fail ! ( "method_self or method_super should have been handled \
263
- above")
261
+ typeck:: method_super( * ) => {
262
+ fail ! ( "method_super should have been handled \
263
+ above")
264
264
}
265
265
}
266
266
}
@@ -460,6 +460,9 @@ pub fn trans_monomorphized_callee(bcx: block,
460
460
typeck:: vtable_param( * ) => {
461
461
fail ! ( "vtable_param left in monomorphized function's vtable substs" ) ;
462
462
}
463
+ typeck:: vtable_self( * ) => {
464
+ fail ! ( "vtable_self left in monomorphized function's vtable substs" ) ;
465
+ }
463
466
} ;
464
467
465
468
}
0 commit comments