rust/compiler/rustc_builtin_macros
Matthias Krüger caa2d008f9
Rollup merge of #138231 - Sa4dUs:autodiff-ice, r=ZuseZ4
Prevent ICE in autodiff validation by emitting user-friendly errors

This PR moves `valid_ret_activity` and `valid_input_activity` checks to the macro expansion phase in compiler/rustc_builtin_macros/src/autodiff.rs, replacing the following internal compiler error (ICE):
```
error: internal compiler error:
compiler/rustc_codegen_ssa/src/codegen_attrs.rs:935:13:
Invalid input activity Dual for Reverse mode
```
with a more user-friendly message.

The issue specifically affected the test file `tests/ui/autodiff/autodiff_illegal.rs`, impacting the functions `f5` and `f6`.

The ICE can be reproduced by following [Enzyme's Rustbook](https://enzymead.github.io/rustbook/installation.html) installation guide.

Additionally, this PR adds tests for invalid return activity in `autodiff_illegal.rs`, which previously triggered an unnoticed ICE before these fixes.

r? ``@oli-obk``
2025-03-11 19:35:29 +01:00
..
src Rollup merge of #138231 - Sa4dUs:autodiff-ice, r=ZuseZ4 2025-03-11 19:35:29 +01:00
Cargo.toml Remove unnecessary [lints.rust] sections. 2025-03-11 12:11:04 +11:00
messages.ftl Combine autodiff errors together 2025-03-11 09:37:53 +01:00