@@ -237,6 +237,25 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
237237 result
238238 }
239239
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+
240259 pub fn resolve_closure (
241260 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
242261 def_id : DefId ,
@@ -251,6 +270,14 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
251270 _ => Instance :: new ( def_id, substs. substs )
252271 }
253272 }
273+
274+ pub fn is_vtable_shim ( & self ) -> bool {
275+ if let InstanceDef :: VtableShim ( ..) = self . def {
276+ true
277+ } else {
278+ false
279+ }
280+ }
254281}
255282
256283fn resolve_associated_item < ' a , ' tcx > (
0 commit comments