@@ -237,6 +237,25 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
237
237
result
238
238
}
239
239
240
+ pub fn resolve_for_vtable ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
241
+ param_env : ty:: ParamEnv < ' tcx > ,
242
+ def_id : DefId ,
243
+ substs : & ' tcx Substs < ' tcx > ) -> Option < Instance < ' tcx > > {
244
+ debug ! ( "resolve(def_id={:?}, substs={:?})" , def_id, substs) ;
245
+ let fn_sig = tcx. fn_sig ( def_id) ;
246
+ let is_vtable_shim =
247
+ fn_sig. inputs ( ) . skip_binder ( ) . len ( ) > 0 && fn_sig. input ( 0 ) . skip_binder ( ) . is_self ( ) ;
248
+ if is_vtable_shim {
249
+ debug ! ( " => associated item with unsizeable self: Self" ) ;
250
+ Some ( Instance {
251
+ def : InstanceDef :: VtableShim ( def_id) ,
252
+ substs,
253
+ } )
254
+ } else {
255
+ Instance :: resolve ( tcx, param_env, def_id, substs)
256
+ }
257
+ }
258
+
240
259
pub fn resolve_closure (
241
260
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
242
261
def_id : DefId ,
@@ -251,6 +270,14 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
251
270
_ => Instance :: new ( def_id, substs. substs )
252
271
}
253
272
}
273
+
274
+ pub fn is_vtable_shim ( & self ) -> bool {
275
+ if let InstanceDef :: VtableShim ( ..) = self . def {
276
+ true
277
+ } else {
278
+ false
279
+ }
280
+ }
254
281
}
255
282
256
283
fn resolve_associated_item < ' a , ' tcx > (
0 commit comments