Skip to content

Commit 5c4b6cc

Browse files
committed
verify that our rlib check works
1 parent 1f6d3bd commit 5c4b6cc

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/ui/autodiff/autodiff_in_rlib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(autodiff)]
2+
#![crate_type = "rlib"]
3+
//@ needs-enzyme
4+
//@ compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=fat
5+
//@ build-fail
6+
7+
// We test that we fail to compile if a user applied an autodiff_ macro in src/lib.rs,
8+
// since autodiff doesn't work in libraries yet. In the past we used to just return zeros in the
9+
// autodiffed functions, which is obviously confusing and wrong, so erroring is an improvement.
10+
11+
use std::autodiff::autodiff_reverse;
12+
//~? ERROR: using the autodiff feature with library builds is not yet supported
13+
14+
#[autodiff_reverse(d_square, Duplicated, Active)]
15+
pub fn square(x: &f64) -> f64 {
16+
*x * *x
17+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: using the autodiff feature with library builds is not yet supported
2+
3+
error: aborting due to 1 previous error
4+

0 commit comments

Comments
 (0)