@@ -6,7 +6,7 @@ use rustc_codegen_ssa::common::TypeKind;
66use rustc_codegen_ssa:: traits:: { BaseTypeCodegenMethods , BuilderMethods } ;
77use rustc_data_structures:: thin_vec:: ThinVec ;
88use rustc_hir:: attrs:: RustcAutodiff ;
9- use rustc_middle:: ty:: { Instance , PseudoCanonicalInput , TyCtxt , TypingEnv } ;
9+ use rustc_middle:: ty:: { PseudoCanonicalInput , Ty , TyCtxt , TypingEnv } ;
1010use rustc_middle:: { bug, ty} ;
1111use rustc_target:: callconv:: PassMode ;
1212use tracing:: debug;
@@ -18,25 +18,23 @@ use crate::llvm::{self, TRUE, Type, Value};
1818
1919pub ( crate ) fn adjust_activity_to_abi < ' tcx > (
2020 tcx : TyCtxt < ' tcx > ,
21- instance : Instance < ' tcx > ,
21+ fn_ptr_ty : Ty < ' tcx > ,
2222 typing_env : TypingEnv < ' tcx > ,
2323 da : & mut ThinVec < DiffActivity > ,
2424) {
25- let fn_ty = instance. ty ( tcx, typing_env) ;
26-
27- if !matches ! ( fn_ty. kind( ) , ty:: FnDef ( ..) ) {
28- bug ! ( "expected fn def for autodiff, got {:?}" , fn_ty) ;
25+ if !matches ! ( fn_ptr_ty. kind( ) , ty:: FnPtr ( ..) ) {
26+ bug ! ( "expected fn ptr for autodiff, got {:?}" , fn_ptr_ty) ;
2927 }
3028
3129 // We don't actually pass the types back into the type system.
3230 // All we do is decide how to handle the arguments.
33- let sig = fn_ty. fn_sig ( tcx) . skip_binder ( ) ;
31+ let fn_sig = fn_ptr_ty. fn_sig ( tcx) ;
32+ let sig = fn_sig. skip_binder ( ) ;
3433
3534 // FIXME(Sa4dUs): pass proper varargs once we have support for differentiating variadic functions
36- let Ok ( fn_abi) =
37- tcx. fn_abi_of_instance ( typing_env. as_query_input ( ( instance, ty:: List :: empty ( ) ) ) )
35+ let Ok ( fn_abi) = tcx. fn_abi_of_fn_ptr ( typing_env. as_query_input ( ( fn_sig, ty:: List :: empty ( ) ) ) )
3836 else {
39- bug ! ( "failed to get fn_abi of instance with empty varargs" ) ;
37+ bug ! ( "failed to get fn_abi of fn_ptr with empty varargs" ) ;
4038 } ;
4139
4240 let mut new_activities = vec ! [ ] ;
0 commit comments