about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize/src/partitioning/autodiff.rs
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-02-24 09:22:41 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-03-11 08:40:35 +0000
commitff5a8ad2abb45955dbeda46273242d6f0186cf2c (patch)
tree75e05048312ba66b05ae28d892edae7f8dd42cec /compiler/rustc_monomorphize/src/partitioning/autodiff.rs
parent2c6a12ec44d0426c8939123c2f2cf27d2217de13 (diff)
downloadrust-ff5a8ad2abb45955dbeda46273242d6f0186cf2c.tar.gz
rust-ff5a8ad2abb45955dbeda46273242d6f0186cf2c.zip
Explain the actual reason why stripping binders is fine
Diffstat (limited to 'compiler/rustc_monomorphize/src/partitioning/autodiff.rs')
-rw-r--r--compiler/rustc_monomorphize/src/partitioning/autodiff.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning/autodiff.rs b/compiler/rustc_monomorphize/src/partitioning/autodiff.rs
index 0c855508434..378b98c2807 100644
--- a/compiler/rustc_monomorphize/src/partitioning/autodiff.rs
+++ b/compiler/rustc_monomorphize/src/partitioning/autodiff.rs
@@ -12,15 +12,14 @@ fn adjust_activity_to_abi<'tcx>(tcx: TyCtxt<'tcx>, fn_ty: Ty<'tcx>, da: &mut Vec
     if !matches!(fn_ty.kind(), ty::FnDef(..)) {
         bug!("expected fn def for autodiff, got {:?}", fn_ty);
     }
-    let fnc_binder: ty::Binder<'_, ty::FnSig<'_>> = fn_ty.fn_sig(tcx);
 
-    // If rustc compiles the unmodified primal, we know that this copy of the function
-    // also has correct lifetimes. We know that Enzyme won't free the shadow too early
-    // (or actually at all), so let's strip lifetimes when computing the layout.
-    let x = tcx.instantiate_bound_regions_with_erased(fnc_binder);
+    // We don't actually pass the types back into the type system.
+    // All we do is decide how to handle the arguments.
+    let sig = fn_ty.fn_sig(tcx).skip_binder();
+
     let mut new_activities = vec![];
     let mut new_positions = vec![];
-    for (i, ty) in x.inputs().iter().enumerate() {
+    for (i, ty) in sig.inputs().iter().enumerate() {
         if let Some(inner_ty) = ty.builtin_deref(true) {
             if ty.is_fn_ptr() {
                 // FIXME(ZuseZ4): add a nicer error, or just figure out how to support them,