Skip to content

Commit ff5a8ad

Browse files
committed
Explain the actual reason why stripping binders is fine
1 parent 2c6a12e commit ff5a8ad

File tree

1 file changed

+5
-6
lines changed
  • compiler/rustc_monomorphize/src/partitioning

1 file changed

+5
-6
lines changed

Diff for: compiler/rustc_monomorphize/src/partitioning/autodiff.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ fn adjust_activity_to_abi<'tcx>(tcx: TyCtxt<'tcx>, fn_ty: Ty<'tcx>, da: &mut Vec
1212
if !matches!(fn_ty.kind(), ty::FnDef(..)) {
1313
bug!("expected fn def for autodiff, got {:?}", fn_ty);
1414
}
15-
let fnc_binder: ty::Binder<'_, ty::FnSig<'_>> = fn_ty.fn_sig(tcx);
1615

17-
// If rustc compiles the unmodified primal, we know that this copy of the function
18-
// also has correct lifetimes. We know that Enzyme won't free the shadow too early
19-
// (or actually at all), so let's strip lifetimes when computing the layout.
20-
let x = tcx.instantiate_bound_regions_with_erased(fnc_binder);
16+
// We don't actually pass the types back into the type system.
17+
// All we do is decide how to handle the arguments.
18+
let sig = fn_ty.fn_sig(tcx).skip_binder();
19+
2120
let mut new_activities = vec![];
2221
let mut new_positions = vec![];
23-
for (i, ty) in x.inputs().iter().enumerate() {
22+
for (i, ty) in sig.inputs().iter().enumerate() {
2423
if let Some(inner_ty) = ty.builtin_deref(true) {
2524
if ty.is_fn_ptr() {
2625
// FIXME(ZuseZ4): add a nicer error, or just figure out how to support them,

0 commit comments

Comments
 (0)