diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-04-07 08:23:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-07 08:23:34 +0200 |
| commit | 5a43d92382397ae1968a6f7f79a31e09e1e7ad5f (patch) | |
| tree | 24a784e8d75dbcbdc644ef998379b58d224aae93 /compiler/rustc_interface/src | |
| parent | 25a615bf829b9f6d6f22da537e3851043f92e5f2 (diff) | |
| parent | bf69443a9f0fa9b44aaec36c1c470ad22a325c2a (diff) | |
| download | rust-5a43d92382397ae1968a6f7f79a31e09e1e7ad5f.tar.gz rust-5a43d92382397ae1968a6f7f79a31e09e1e7ad5f.zip | |
Rollup merge of #138314 - haenoe:autodiff-inner-function, r=ZuseZ4
fix usage of `autodiff` macro with inner functions
This PR adds additional handling into the expansion step of the `std::autodiff` macro (in `compiler/rustc_builtin_macros/src/autodiff.rs`), which allows the macro to be applied to inner functions.
```rust
#![feature(autodiff)]
use std::autodiff::autodiff;
fn main() {
#[autodiff(d_inner, Forward, Dual, DualOnly)]
fn inner(x: f32) -> f32 {
x * x
}
}
```
Previously, the compiler didn't allow this due to only handling `Annotatable::Item` and `Annotatable::AssocItem` and missing the handling of `Annotatable::Stmt`. This resulted in the rather generic error
```
error: autodiff must be applied to function
--> src/main.rs:6:5
|
6 | / fn inner(x: f32) -> f32 {
7 | | x * x
8 | | }
| |_____^
error: could not compile `enzyme-test` (bin "enzyme-test") due to 1 previous error
```
This issue was originally reported [here](https://github.com/EnzymeAD/rust/issues/184).
Quick question: would it make sense to add a ui test to ensure there is no regression on this?
This is my first contribution, so I'm extra grateful for any piece of feedback!! :D
r? `@oli-obk`
Tracking issue for autodiff: #124509
Diffstat (limited to 'compiler/rustc_interface/src')
0 files changed, 0 insertions, 0 deletions
