about summary refs log tree commit diff
path: root/tests/ui/autodiff/zst.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-09-18 07:32:49 +0000
committerbors <bors@rust-lang.org>2025-09-18 07:32:49 +0000
commit97a987f14c5bd948f7ee8dba75999f104a6f03a7 (patch)
treed2cce447d7a0bb1144a6378dec1554c105e4d340 /tests/ui/autodiff/zst.rs
parent4793ef5cf527339f072c39d129477ad5bb678f9e (diff)
parente04567c363e1f0417bf8bf24830c2bc536020582 (diff)
downloadrust-97a987f14c5bd948f7ee8dba75999f104a6f03a7.tar.gz
rust-97a987f14c5bd948f7ee8dba75999f104a6f03a7.zip
Auto merge of #142544 - Sa4dUs:prevent-abi-changes, r=ZuseZ4
Prevent ABI changes affect EnzymeAD

This PR handles ABI changes for autodiff input arguments to improve Enzyme compatibility. Fundamentally this adjusts activities when a function argument is lowered as an `ScalarPair`, so there's no mismatch between diff activities and args. Also removes activities corresponding to ZSTs.

fixes: https://github.com/rust-lang/rust/issues/144025

r? `@ZuseZ4`
Diffstat (limited to 'tests/ui/autodiff/zst.rs')
-rw-r--r--tests/ui/autodiff/zst.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/autodiff/zst.rs b/tests/ui/autodiff/zst.rs
new file mode 100644
index 00000000000..7b9b5f5f20b
--- /dev/null
+++ b/tests/ui/autodiff/zst.rs
@@ -0,0 +1,17 @@
+//@ compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=fat
+//@ no-prefer-dynamic
+//@ needs-enzyme
+//@ build-pass
+
+// Check that differentiating functions with ZST args does not break
+
+#![feature(autodiff)]
+
+#[core::autodiff::autodiff_forward(fd_inner, Const, Dual)]
+fn f(_zst: (), _x: &mut f64) {}
+
+fn fd(x: &mut f64, xd: &mut f64) {
+    fd_inner((), x, xd);
+}
+
+fn main() {}