rust-lang / rust-lang/rust

ICE: autodiff: `not an ident?`

Open
#150,328 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-autodiff I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

snippet:

use std::autodiff::autodiff_reverse;
#[autodiff_reverse(1, Active, Duplicated)]
fn f21(3: f32) -> f32;

Version information

rustc 1.94.0-nightly (2ca7bcd03 2025-12-23)
binary: rustc
commit-hash: 2ca7bcd03b87b52f7055a59b817443b0ac4a530d
commit-date: 2025-12-23
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0658]: use of unstable library feature `autodiff`
 --> /tmp/icemaker_global_tempdir.4K5QMhZtihrW/rustc_testrunner_tmpdir_reporting.VV23HFe9zAyb/mvce.rs:2:3
  |
2 | #[autodiff_reverse(1, Active, Duplicated)]
  |   ^^^^^^^^^^^^^^^^
  |
  = note: see issue #124509 <https://github.com/rust-lang/rust/issues/124509> for more information
  = help: add `#![feature(autodiff)]` to the crate attributes to enable
  = note: this compiler was built on 2025-12-23; consider upgrading it if it is out of date

error: invalid return activity Duplicated in Reverse Mode
 --> /tmp/icemaker_global_tempdir.4K5QMhZtihrW/rustc_testrunner_tmpdir_reporting.VV23HFe9zAyb/mvce.rs:2:1
  |
2 | #[autodiff_reverse(1, Active, Duplicated)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


thread 'rustc' (3569151) panicked at /rustc-dev/2ca7bcd03b87b52f7055a59b817443b0ac4a530d/compiler/rustc_builtin_macros/src/autodiff.rs:744:17:
not an ident?
stack backtrace:
   0:     0x7f64c982c3a3 - <<std[243ef3771c46e43a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c088ff38143eb53e]::fmt::Display>::fmt
   1:     0x7f64c9e10648 - core[c088ff38143eb53e]::fmt::write
   2:     0x7f64c9842af6 - <std[243ef3771c46e43a]::sys::stdio::unix::Stderr as std[243ef3771c46e43a]::io::Write>::write_fmt
   3:     0x7f64c9802b48 - std[243ef3771c46e43a]::panicking::default_hook::{closure#0}
   4:     0x7f64c9820213 - std[243ef3771c46e43a]::panicking::default_hook
   5:     0x7f64c8810d77 - std[243ef3771c46e43a]::panicking::update_hook::<alloc[baa86124b2c3e6f2]::boxed::Box<rustc_driver_impl[e986b619aabff65e]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f64c98204f2 - std[243ef3771c46e43a]::panicking::panic_with_hook
   7:     0x7f64c9802c3a - std[243ef3771c46e43a]::panicking::panic_handler::{closure#0}
   8:     0x7f64c97f9c19 - std[243ef3771c46e43a]::sys::backtrace::__rust_end_short_backtrace::<std[243ef3771c46e43a]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f64c98046fd - __rustc[6d0b6af41dd8415b]::rust_begin_unwind
  10:     0x7f64c69e611c - core[c088ff38143eb53e]::panicking::panic_fmt
  11:     0x7f64c85a4326 - rustc_builtin_macros[c43dc9e402b49fb2]::autodiff::llvm_enzyme::gen_enzyme_decl
  12:     0x7f64c85a5a6a - rustc_builtin_macros[c43dc9e402b49fb2]::autodiff::llvm_enzyme::expand_with_mode
  13:     0x7f64c85b81f8 - <rustc_builtin_macros[c43dc9e402b49fb2]::autodiff::llvm_enzyme::expand_reverse as rustc_expand[7ba574a324a285b6]::base::MultiItemModifier>::expand
  14:     0x7f64cb41a288 - <rustc_expand[7ba574a324a285b6]::expand::MacroExpander>::fully_expand_fragment
  15:     0x7f64cb3fec12 - <rustc_expand[7ba574a324a285b6]::expand::MacroExpander>::expand_crate
  16:     0x7f64ca5715f3 - rustc_interface[577997324878ea43]::passes::configure_and_expand
  17:     0x7f64cb01bad8 - rustc_interface[577997324878ea43]::passes::resolver_for_lowering_raw
  18:     0x7f64cb01b84d - rustc_query_impl[3af702bc24a35b84]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3af702bc24a35b84]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[395a2484b1db1a27]::query::erase::Erased<[u8; 16usize]>>
  19:     0x7f64cb01b827 - <rustc_query_impl[3af702bc24a35b84]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[c088ff38143eb53e]::ops::function::FnOnce<(rustc_middle[395a2484b1db1a27]::ty::context::TyCtxt, ())>>::call_once
  20:     0x7f64cafcb35f - rustc_query_system[fae14337e0c02060]::query::plumbing::try_execute_query::<rustc_query_impl[3af702bc24a35b84]::DynamicConfig<rustc_query_system[fae14337e0c02060]::query::caches::SingleCache<rustc_middle[395a2484b1db1a27]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[3af702bc24a35b84]::plumbing::QueryCtxt, false>
  21:     0x7f64cafcaec4 - rustc_query_impl[3af702bc24a35b84]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  22:     0x7f64cb1a90f8 - <rustc_interface[577997324878ea43]::passes::create_and_enter_global_ctxt<core[c088ff38143eb53e]::option::Option<rustc_interface[577997324878ea43]::queries::Linker>, rustc_driver_impl[e986b619aabff65e]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[c088ff38143eb53e]::ops::function::FnOnce<(&rustc_session[9908f9ef7e13fd8d]::session::Session, rustc_middle[395a2484b1db1a27]::ty::context::CurrentGcx, alloc[baa86124b2c3e6f2]::sync::Arc<rustc_data_structures[75601f20e3d68749]::jobserver::Proxy>, &std[243ef3771c46e43a]::sync::once_lock::OnceLock<rustc_middle[395a2484b1db1a27]::ty::context::GlobalCtxt>, &rustc_data_structures[75601f20e3d68749]::sync::worker_local::WorkerLocal<rustc_middle[395a2484b1db1a27]::arena::Arena>, &rustc_data_structures[75601f20e3d68749]::sync::worker_local::WorkerLocal<rustc_hir[38bedddefeb6b9a6]::Arena>, rustc_driver_impl[e986b619aabff65e]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  23:     0x7f64cb03cc8a - rustc_interface[577997324878ea43]::interface::run_compiler::<(), rustc_driver_impl[e986b619aabff65e]::run_compiler::{closure#0}>::{closure#1}
  24:     0x7f64caf8ffce - std[243ef3771c46e43a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[577997324878ea43]::util::run_in_thread_with_globals<rustc_interface[577997324878ea43]::util::run_in_thread_pool_with_globals<rustc_interface[577997324878ea43]::interface::run_compiler<(), rustc_driver_impl[e986b619aabff65e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  25:     0x7f64caf8fda0 - <std[243ef3771c46e43a]::thread::lifecycle::spawn_unchecked<rustc_interface[577997324878ea43]::util::run_in_thread_with_globals<rustc_interface[577997324878ea43]::util::run_in_thread_pool_with_globals<rustc_interface[577997324878ea43]::interface::run_compiler<(), rustc_driver_impl[e986b619aabff65e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c088ff38143eb53e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7f64caf95b38 - <std[243ef3771c46e43a]::sys::thread::unix::Thread>::new::thread_start
  27:     0x7f64c489698b - <unknown>
  28:     0x7f64c491a9cc - <unknown>
  29:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.94.0-nightly (2ca7bcd03 2025-12-23) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with compiler/rustc_builtin_macros/src/autodiff.rs at line 744 and reproduce the ICE using the issue's notanident.rs snippet with the reported nightly rustc. Trace the autodiff reverse-mode expansion and its handling of the invalid parameter or return activity. Done means the input reports diagnostics without panicking, with a regression test covering the reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.