ICE: autodiff: `segments.len() == 1`
Open
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
auto-reduced (treereduce-rust):
#[core::autodiff::autodiff_forward(::autodiff)]
fn main() {}
original:
#![feature(autodiff)]
#[core::autodiff::autodiff_forward(::autodiff)]
fn main() {}
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.eRqldW7npjLk/mvce.rs:1:3
|
1 | #[core::autodiff::autodiff_forward(::autodiff)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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
thread 'rustc' (3569183) panicked at /rustc-dev/2ca7bcd03b87b52f7055a59b817443b0ac4a530d/compiler/rustc_builtin_macros/src/autodiff.rs:59:9:
assertion failed: segments.len() == 1
stack backtrace:
0: 0x7f7310c2c3a3 - <<std[243ef3771c46e43a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c088ff38143eb53e]::fmt::Display>::fmt
1: 0x7f7311210648 - core[c088ff38143eb53e]::fmt::write
2: 0x7f7310c42af6 - <std[243ef3771c46e43a]::sys::stdio::unix::Stderr as std[243ef3771c46e43a]::io::Write>::write_fmt
3: 0x7f7310c02b48 - std[243ef3771c46e43a]::panicking::default_hook::{closure#0}
4: 0x7f7310c20213 - std[243ef3771c46e43a]::panicking::default_hook
5: 0x7f730fc10d77 - std[243ef3771c46e43a]::panicking::update_hook::<alloc[baa86124b2c3e6f2]::boxed::Box<rustc_driver_impl[e986b619aabff65e]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f7310c204f2 - std[243ef3771c46e43a]::panicking::panic_with_hook
7: 0x7f7310c02c3a - std[243ef3771c46e43a]::panicking::panic_handler::{closure#0}
8: 0x7f7310bf9c19 - std[243ef3771c46e43a]::sys::backtrace::__rust_end_short_backtrace::<std[243ef3771c46e43a]::panicking::panic_handler::{closure#0}, !>
9: 0x7f7310c046fd - __rustc[6d0b6af41dd8415b]::rust_begin_unwind
10: 0x7f730dde611c - core[c088ff38143eb53e]::panicking::panic_fmt
11: 0x7f730d3bd872 - core[c088ff38143eb53e]::panicking::panic
12: 0x7f730f9a21ca - rustc_builtin_macros[c43dc9e402b49fb2]::autodiff::llvm_enzyme::first_ident
13: 0x7f730f9a5a9c - rustc_builtin_macros[c43dc9e402b49fb2]::autodiff::llvm_enzyme::expand_with_mode
14: 0x7f730f9b8198 - <rustc_builtin_macros[c43dc9e402b49fb2]::autodiff::llvm_enzyme::expand_forward as rustc_expand[7ba574a324a285b6]::base::MultiItemModifier>::expand
15: 0x7f731281a288 - <rustc_expand[7ba574a324a285b6]::expand::MacroExpander>::fully_expand_fragment
16: 0x7f73127fec12 - <rustc_expand[7ba574a324a285b6]::expand::MacroExpander>::expand_crate
17: 0x7f73119715f3 - rustc_interface[577997324878ea43]::passes::configure_and_expand
18: 0x7f731241bad8 - rustc_interface[577997324878ea43]::passes::resolver_for_lowering_raw
19: 0x7f731241b84d - 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]>>
20: 0x7f731241b827 - <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
21: 0x7f73123cb35f - 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>
22: 0x7f73123caec4 - rustc_query_impl[3af702bc24a35b84]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
23: 0x7f73125a90f8 - <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}
24: 0x7f731243cc8a - rustc_interface[577997324878ea43]::interface::run_compiler::<(), rustc_driver_impl[e986b619aabff65e]::run_compiler::{closure#0}>::{closure#1}
25: 0x7f731238ffce - 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}, ()>
26: 0x7f731238fda0 - <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}
27: 0x7f7312395b38 - <std[243ef3771c46e43a]::sys::thread::unix::Thread>::new::thread_start
28: 0x7f730bc9698b - <unknown>
29: 0x7f730bd1a9cc - <unknown>
30: 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 1 previous error
For more information about this error, try `rustc --explain E0658`.
@rustbot label +F-autodiff
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reduced and original reproductions in the issue and inspect compiler/rustc_builtin_macros/src/autodiff.rs at the assertion on line 59. Run the reproducer with the reported nightly to confirm the ICE and trace how the autodiff attribute arguments are parsed. Done means the invalid input no longer triggers an internal compiler error and instead receives an appropriate diagnostic.
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
- Needs clarification
- Newbie friendliness
- 35/100