@@ -25,7 +25,7 @@ pub enum InstanceDef<'tcx> {
25
25
/// `<T as Trait>::method` where `method` receives unsizeable `self: Self`.
26
26
VtableShim ( DefId ) ,
27
27
28
- /// `fn()` where the function is annotated with `#[track_caller]`.
28
+ /// `fn()` pointer where the function is annotated with `#[track_caller]`.
29
29
ReifyShim ( DefId ) ,
30
30
31
31
/// `<fn() as FnTrait>::call_*`
@@ -297,6 +297,28 @@ impl<'tcx> Instance<'tcx> {
297
297
result
298
298
}
299
299
300
+ pub fn resolve_for_fn_ptr (
301
+ tcx : TyCtxt < ' tcx > ,
302
+ param_env : ty:: ParamEnv < ' tcx > ,
303
+ def_id : DefId ,
304
+ substs : SubstsRef < ' tcx > ,
305
+ ) -> Option < Instance < ' tcx > > {
306
+ debug ! ( "resolve(def_id={:?}, substs={:?})" , def_id, substs) ;
307
+ let fn_sig = tcx. fn_sig ( def_id) ;
308
+ // let is_reify_shim = fn_sig.inputs().skip_binder().len() > 0
309
+ // && fn_sig.input(0).skip_binder().is_param(0)
310
+ // && tcx.generics_of(def_id).has_self;
311
+ if is_reify_shim {
312
+ debug ! ( " => fn ptr with implicit caller location" ) ;
313
+ Some ( Instance {
314
+ def : InstanceDef :: ReifyShim ( def_id) ,
315
+ substs,
316
+ } )
317
+ } else {
318
+ Instance :: resolve ( tcx, param_env, def_id, substs)
319
+ }
320
+ }
321
+
300
322
pub fn resolve_for_vtable (
301
323
tcx : TyCtxt < ' tcx > ,
302
324
param_env : ty:: ParamEnv < ' tcx > ,
0 commit comments