Skip to content

[ICE]: calling non-const function <A as Drop>::drop` #164062

Description

@matthiaskrgr

Code

#![feature(const_precise_live_drops)]
struct A;
impl Drop for A {
    fn drop(&mut self) {}
}
static EARLY_DROP_S: i32 = (A, 0).1;

fn main() {}

Meta

rustc --version --verbose:

rustc 1.101.0-nightly (32dba69d6 2026-10-09)
binary: rustc
commit-hash: 32dba69d69c5b10ea89a4042de8d0619f7756203
commit-date: 2026-10-09
host: x86_64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.3

Error output

error[E0493]: destructor of `(A, i32)` cannot be evaluated at compile-time
 --> code.rs:4:29
  |
4 | static EARLY_DROP_S : i32 = (A,0).1;
  |                             ^^^^^ - value is dropped here
  |                             |
  |                             the destructor for this type cannot be evaluated in statics
Backtrace

thread 'rustc' (4149339) panicked at /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_const_eval/src/const_eval/machine.rs:460:21:
Box<dyn Any>
stack backtrace:
   0:     0x7f6dc021cee6 - <<std[b76485d3782cc82]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a3d7fcd5cfdd2c51]::fmt::Display>::fmt
   1:     0x7f6dc0806ddf - core[a3d7fcd5cfdd2c51]::fmt::write
   2:     0x7f6dc02334cc - <std[b76485d3782cc82]::sys::stdio::unix::Stderr as core[a3d7fcd5cfdd2c51]::io::write::Write>::write_fmt
   3:     0x7f6dc01ee1aa - std[b76485d3782cc82]::panicking::default_hook::{closure#0}
   4:     0x7f6dc0210723 - std[b76485d3782cc82]::panicking::default_hook
   5:     0x7f6dbef80775 - std[b76485d3782cc82]::panicking::update_hook::<alloc[8104f853b11633b9]::boxed::Box<rustc_driver_impl[50c5c3a0f8569617]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f6dc0210bc2 - std[b76485d3782cc82]::panicking::panic_with_hook
   7:     0x7f6dbfd9870a - std[b76485d3782cc82]::panicking::begin_panic::<rustc_span[ebedf997a91a4466]::macros::ExplicitBug>::{closure#0}
   8:     0x7f6dbfd97226 - std[b76485d3782cc82]::sys::backtrace::__rust_end_short_backtrace::<std[b76485d3782cc82]::panicking::begin_panic<rustc_span[ebedf997a91a4466]::macros::ExplicitBug>::{closure#0}, !>
   9:     0x7f6dbfd969cc - std[b76485d3782cc82]::panicking::begin_panic::<rustc_span[ebedf997a91a4466]::macros::ExplicitBug>
  10:     0x7f6dbc243c71 - rustc_span[ebedf997a91a4466]::macros::bug_impl
  11:     0x7f6dc1677a5c - <rustc_const_eval[6709b28d84b25c8d]::const_eval::machine::CompileTimeMachine as rustc_const_eval[6709b28d84b25c8d]::interpret::machine::Machine>::find_mir_or_eval_fn
  12:     0x7f6dc167b8ab - <rustc_const_eval[6709b28d84b25c8d]::interpret::eval_context::InterpCx<rustc_const_eval[6709b28d84b25c8d]::const_eval::machine::CompileTimeMachine>>::init_fn_call
  13:     0x7f6dc20e49ce - rustc_const_eval[6709b28d84b25c8d]::const_eval::eval_queries::eval_in_interpreter::<rustc_middle[5a5db90388d4e3c4]::mir::interpret::allocation::ConstAllocation>
  14:     0x7f6dc20d966f - rustc_const_eval[6709b28d84b25c8d]::const_eval::eval_queries::eval_static_initializer_provider
  15:     0x7f6dc20d9559 - rustc_query_impl[fa78e9cdac69778c]::query_vtables::eval_static_initializer::invoke_provider_fn::__rust_begin_short_backtrace
  16:     0x7f6dc11ce729 - rustc_query_impl[fa78e9cdac69778c]::execution::try_execute_query::<rustc_middle[5a5db90388d4e3c4]::query::caches::DefIdCache<rustc_middle[5a5db90388d4e3c4]::query::erase::ErasedData<[u8; 16usize]>>, false>
  17:     0x7f6dc0ea0b48 - rustc_query_impl[fa78e9cdac69778c]::query_vtables::eval_static_initializer::execute_query_non_incr::__rust_end_short_backtrace
  18:     0x7f6dc0ea1ad1 - <rustc_middle[5a5db90388d4e3c4]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[48ab5c7f3aee4011]::check_crate::{closure#1}>::{closure#0}
  19:     0x7f6dc0ea0ea5 - rustc_hir_analysis[48ab5c7f3aee4011]::check_crate
  20:     0x7f6dc0e2adb9 - rustc_interface[f1b69b3f87983cd3]::passes::analysis
  21:     0x7f6dc1a55b47 - rustc_query_impl[fa78e9cdac69778c]::execution::try_execute_query::<rustc_middle[5a5db90388d4e3c4]::query::caches::SingleCache<rustc_middle[5a5db90388d4e3c4]::query::erase::ErasedData<[u8; 0usize]>>, false>
  22:     0x7f6dc1a5592b - rustc_query_impl[fa78e9cdac69778c]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f6dc1ad890e - rustc_interface[f1b69b3f87983cd3]::interface::run_compiler::<(), rustc_driver_impl[50c5c3a0f8569617]::compiler_entrypoint::{closure#0}>::{closure#2}
  24:     0x7f6dc1b03f02 - std[b76485d3782cc82]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f1b69b3f87983cd3]::util::run_in_thread_with_globals<rustc_interface[f1b69b3f87983cd3]::util::run_in_thread_pool_with_globals<rustc_interface[f1b69b3f87983cd3]::interface::run_compiler<(), rustc_driver_impl[50c5c3a0f8569617]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  25:     0x7f6dc1b03cad - <std[b76485d3782cc82]::thread::lifecycle::spawn_unchecked<rustc_interface[f1b69b3f87983cd3]::util::run_in_thread_with_globals<rustc_interface[f1b69b3f87983cd3]::util::run_in_thread_pool_with_globals<rustc_interface[f1b69b3f87983cd3]::interface::run_compiler<(), rustc_driver_impl[50c5c3a0f8569617]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a3d7fcd5cfdd2c51]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7f6dc1b0225b - <std[b76485d3782cc82]::sys::thread::unix::Thread>::new::thread_start
  27:     0x7f6dbaa980a2 - <unknown>
  28:     0x7f6dbab2080c - <unknown>
  29:                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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-10-09T23_57_25-4149306.txt` to your bug report

note: rustc 1.101.0-nightly (32dba69d6 2026-10-09) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `EARLY_DROP_S`
#1 [analysis] running analysis passes on crate `code`
end of query stack
error: aborting due to 2 previous errors

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Oct 10, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 10, 2026
  3. lqd commented on Oct 10, 2026

    @lqd
    Member

    This should be both Intentional from #163972 and a dupe of #163973?

  4. matthiaskrgr commented on Oct 10, 2026

    @matthiaskrgr
    MemberAuthor

    ah, makes sense, closing then 👍

  5. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions