rust-lang / rust-lang/rust

ICE: autodiff: `expected autodiff function`

Open
#150,331 1 comment 0 reactions 1 assignee View on GitHub

@Aditya-PS-05 is already working on this.

Since Dec 24, 2025.

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):

//@compile-flags: -Clink-dead-code=true --crate-type=lib
#![feature(autodiff)]
#[core::autodiff::autodiff_forward(fd_inner, Const, Dual)]
fn _zst(_zst: (), d: f64) {}

original:

#![feature(autodiff)]
#[core::autodiff::autodiff_forward(fd_inner, Const, Dual)]
fn _zst(_zst : (), d : f64) {}

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 -Clink-dead-code=true --crate-type=lib

Program output

warning: unused variable: `d`
 --> /tmp/icemaker_global_tempdir.4K5QMhZtihrW/rustc_testrunner_tmpdir_reporting.xgmodUgqMMc5/mvce.rs:3:19
  |
3 | fn _zst(_zst: (), d: f64) {}
  |                   ^ help: if this is intentional, prefix it with an underscore: `_d`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

error: internal compiler error: /rustc-dev/2ca7bcd03b87b52f7055a59b817443b0ac4a530d/compiler/rustc_monomorphize/src/collector/autodiff.rs:44:18: expected autodiff function


thread 'rustc' (3569155) panicked at /rustc-dev/2ca7bcd03b87b52f7055a59b817443b0ac4a530d/compiler/rustc_monomorphize/src/collector/autodiff.rs:44:18:
Box<dyn Any>
stack backtrace:
   0:     0x7f6c07a2c3a3 - <<std[243ef3771c46e43a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c088ff38143eb53e]::fmt::Display>::fmt
   1:     0x7f6c08010648 - core[c088ff38143eb53e]::fmt::write
   2:     0x7f6c07a42af6 - <std[243ef3771c46e43a]::sys::stdio::unix::Stderr as std[243ef3771c46e43a]::io::Write>::write_fmt
   3:     0x7f6c07a02b48 - std[243ef3771c46e43a]::panicking::default_hook::{closure#0}
   4:     0x7f6c07a20213 - std[243ef3771c46e43a]::panicking::default_hook
   5:     0x7f6c06a10d77 - std[243ef3771c46e43a]::panicking::update_hook::<alloc[baa86124b2c3e6f2]::boxed::Box<rustc_driver_impl[e986b619aabff65e]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f6c07a204f2 - std[243ef3771c46e43a]::panicking::panic_with_hook
   7:     0x7f6c06a4dec1 - std[243ef3771c46e43a]::panicking::begin_panic::<rustc_errors[c64784b3ec03c9d3]::ExplicitBug>::{closure#0}
   8:     0x7f6c06a3e166 - std[243ef3771c46e43a]::sys::backtrace::__rust_end_short_backtrace::<std[243ef3771c46e43a]::panicking::begin_panic<rustc_errors[c64784b3ec03c9d3]::ExplicitBug>::{closure#0}, !>
   9:     0x7f6c06a3b7a9 - std[243ef3771c46e43a]::panicking::begin_panic::<rustc_errors[c64784b3ec03c9d3]::ExplicitBug>
  10:     0x7f6c06a6beb1 - <rustc_errors[c64784b3ec03c9d3]::diagnostic::BugAbort as rustc_errors[c64784b3ec03c9d3]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f6c0700d2e9 - rustc_middle[395a2484b1db1a27]::util::bug::opt_span_bug_fmt::<rustc_span[f0a4c422aa13deb9]::span_encoding::Span>::{closure#0}
  12:     0x7f6c0700d472 - rustc_middle[395a2484b1db1a27]::ty::context::tls::with_opt::<rustc_middle[395a2484b1db1a27]::util::bug::opt_span_bug_fmt<rustc_span[f0a4c422aa13deb9]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f6c06ffe77b - rustc_middle[395a2484b1db1a27]::ty::context::tls::with_context_opt::<rustc_middle[395a2484b1db1a27]::ty::context::tls::with_opt<rustc_middle[395a2484b1db1a27]::util::bug::opt_span_bug_fmt<rustc_span[f0a4c422aa13deb9]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f6c0541a5b4 - rustc_middle[395a2484b1db1a27]::util::bug::bug_fmt
  15:     0x7f6c0841ce27 - <rustc_monomorphize[890c893552912303]::collector::MirUsedCollector as rustc_middle[395a2484b1db1a27]::mir::visit::Visitor>::visit_terminator
  16:     0x7f6c084117a2 - rustc_monomorphize[890c893552912303]::collector::items_of_instance
  17:     0x7f6c08411032 - rustc_query_impl[3af702bc24a35b84]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3af702bc24a35b84]::query_impl::items_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[395a2484b1db1a27]::query::erase::Erased<[u8; 32usize]>>
  18:     0x7f6c086fb094 - rustc_query_system[fae14337e0c02060]::query::plumbing::try_execute_query::<rustc_query_impl[3af702bc24a35b84]::DynamicConfig<rustc_query_system[fae14337e0c02060]::query::caches::DefaultCache<(rustc_middle[395a2484b1db1a27]::ty::instance::Instance, rustc_middle[395a2484b1db1a27]::mir::mono::CollectionMode), rustc_middle[395a2484b1db1a27]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[3af702bc24a35b84]::plumbing::QueryCtxt, false>
  19:     0x7f6c086facb7 - rustc_query_impl[3af702bc24a35b84]::query_impl::items_of_instance::get_query_non_incr::__rust_end_short_backtrace
  20:     0x7f6c086f95d7 - rustc_monomorphize[890c893552912303]::collector::collect_items_rec::{closure#0}
  21:     0x7f6c0943d157 - rustc_monomorphize[890c893552912303]::collector::collect_items_rec
  22:     0x7f6c083a8921 - rustc_monomorphize[890c893552912303]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  23:     0x7f6c089b733a - rustc_monomorphize[890c893552912303]::partitioning::collect_and_partition_mono_items
  24:     0x7f6c094fa896 - rustc_query_impl[3af702bc24a35b84]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3af702bc24a35b84]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[395a2484b1db1a27]::query::erase::Erased<[u8; 24usize]>>
  25:     0x7f6c094fa85b - <rustc_query_impl[3af702bc24a35b84]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[c088ff38143eb53e]::ops::function::FnOnce<(rustc_middle[395a2484b1db1a27]::ty::context::TyCtxt, ())>>::call_once
  26:     0x7f6c094fa3b6 - 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; 24usize]>>, false, false, false>, rustc_query_impl[3af702bc24a35b84]::plumbing::QueryCtxt, false>
  27:     0x7f6c094fa15b - rustc_query_impl[3af702bc24a35b84]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f6c08c866fe - rustc_codegen_ssa[21f8591ee52006ec]::back::symbol_export::exported_generic_symbols_provider_local
  29:     0x7f6c08f00b75 - rustc_query_impl[3af702bc24a35b84]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3af702bc24a35b84]::query_impl::exported_generic_symbols::dynamic_query::{closure#2}::{closure#0}, rustc_middle[395a2484b1db1a27]::query::erase::Erased<[u8; 16usize]>>
  30:     0x7f6c08f00b4b - <rustc_query_impl[3af702bc24a35b84]::query_impl::exported_generic_symbols::dynamic_query::{closure#2} as core[c088ff38143eb53e]::ops::function::FnOnce<(rustc_middle[395a2484b1db1a27]::ty::context::TyCtxt, rustc_span[f0a4c422aa13deb9]::def_id::CrateNum)>>::call_once
  31:     0x7f6c08efe9a6 - rustc_query_system[fae14337e0c02060]::query::plumbing::try_execute_query::<rustc_query_impl[3af702bc24a35b84]::DynamicConfig<rustc_data_structures[75601f20e3d68749]::vec_cache::VecCache<rustc_span[f0a4c422aa13deb9]::def_id::CrateNum, rustc_middle[395a2484b1db1a27]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[fae14337e0c02060]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[3af702bc24a35b84]::plumbing::QueryCtxt, false>
  32:     0x7f6c08efe4cc - rustc_query_impl[3af702bc24a35b84]::query_impl::exported_generic_symbols::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7f6c08ac1653 - <rustc_metadata[39a13e8e21b894d2]::rmeta::encoder::EncodeContext>::encode_crate_root
  34:     0x7f6c09507b90 - <rustc_metadata[39a13e8e21b894d2]::rmeta::encoder::encode_metadata::{closure#3} as core[c088ff38143eb53e]::ops::function::FnOnce<(rustc_middle[395a2484b1db1a27]::ty::context::TyCtxt, &std[243ef3771c46e43a]::path::Path)>>::call_once
  35:     0x7f6c09504893 - rustc_metadata[39a13e8e21b894d2]::rmeta::encoder::encode_metadata
  36:     0x7f6c09025a01 - rustc_metadata[39a13e8e21b894d2]::fs::encode_and_write_metadata
  37:     0x7f6c093ac56e - <rustc_interface[577997324878ea43]::queries::Linker>::codegen_and_build_linker
  38:     0x7f6c093a9299 - <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}
  39:     0x7f6c0923cc8a - rustc_interface[577997324878ea43]::interface::run_compiler::<(), rustc_driver_impl[e986b619aabff65e]::run_compiler::{closure#0}>::{closure#1}
  40:     0x7f6c0918ffce - 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}, ()>
  41:     0x7f6c0918fda0 - <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}
  42:     0x7f6c09195b38 - <std[243ef3771c46e43a]::sys::thread::unix::Thread>::new::thread_start
  43:     0x7f6c02a9698b - <unknown>
  44:     0x7f6c02b1a9cc - <unknown>
  45:                0x0 - <unknown>

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

note: compiler flags: -C link-dead-code=true --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
#0 [items_of_instance] collecting items used by `fd_inner`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
#2 [exported_generic_symbols] collecting exported generic symbols for crate `0`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted


@rustbot label +F-autodiff

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.