Skip to content

ICE on feature generic_const_exprs when trying to create comp time arrays #141801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
VirgileHenry opened this issue May 30, 2025 · 2 comments
Open
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@VirgileHenry
Copy link

Code

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

const fn arr_insert<const N: usize, T: Copy>(arr: [T; N], elem: T, index: usize) -> [T; N + 1] {
    assert!(index <= N);

    // Since we have T: Copy, we can dummy init the result
    let mut out = [elem; N + 1];
    let mut i = 0;

    while i < index {
        out[i] = arr[i];
        i += 1;
    }

    out[i] = elem;

    while i < N {
        out[i + 1] = arr[i];
        i += 1;
    }

    out
}

const MY_ARR: [i32; 3] = arr_insert([0, 2], 1, 1);

fn main() {
    assert_eq!(MY_ARR, [0, 1, 2]);
}

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (1bbd62e54 2025-05-29)
binary: rustc
commit-hash: 1bbd62e547ba5cc08ccb44c27def3d33195d2dd5
commit-date: 2025-05-29
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Error output

Compiling playground v0.0.1 (/playground)
error: internal compiler error: compiler/rustc_const_eval/src/check_consts/qualifs.rs:359:13: expected ConstKind::Param or ConstKind::Value here, found UnevaluatedConst { def: DefId(0:8 ~ playground[ab6f]::arr_insert::{constant#2}), args: [N/#0, T/#1] }


thread 'rustc' panicked at compiler/rustc_const_eval/src/check_consts/qualifs.rs:359:13:
Box<dyn Any>
stack backtrace:
   0:     0x7eb3f64a5273 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h05e9f29e57dbb2e9
   1:     0x7eb3f6c02af7 - core::fmt::write::hd2dec42d1c7eed2b
   2:     0x7eb3f649b0f3 - std::io::Write::write_fmt::he35f7ccd30502a06
   3:     0x7eb3f64a50d2 - std::sys::backtrace::BacktraceLock::print::h0f7594efff5cfc74
   4:     0x7eb3f64a8cca - std::panicking::default_hook::{{closure}}::h8c1a12024f8172d5
   5:     0x7eb3f64a884f - std::panicking::default_hook::h9b1e5be56a49e97f
   6:     0x7eb3f550d693 - std[aebe2beb07d4602e]::panicking::update_hook::<alloc[afc79f7023c726bc]::boxed::Box<rustc_driver_impl[fce054646584467]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7eb3f64a9543 - std::panicking::rust_panic_with_hook::h466604244439fd1e
   8:     0x7eb3f5549d31 - std[aebe2beb07d4602e]::panicking::begin_panic::<rustc_errors[fd968897a4afc233]::ExplicitBug>::{closure#0}
   9:     0x7eb3f553ebe6 - std[aebe2beb07d4602e]::sys::backtrace::__rust_end_short_backtrace::<std[aebe2beb07d4602e]::panicking::begin_panic<rustc_errors[fd968897a4afc233]::ExplicitBug>::{closure#0}, !>
  10:     0x7eb3f553e8c7 - std[aebe2beb07d4602e]::panicking::begin_panic::<rustc_errors[fd968897a4afc233]::ExplicitBug>
  11:     0x7eb3f55537c1 - <rustc_errors[fd968897a4afc233]::diagnostic::BugAbort as rustc_errors[fd968897a4afc233]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7eb3f5b9b32a - rustc_middle[f62d8e2871d7ed5a]::util::bug::opt_span_bug_fmt::<rustc_span[674833ee7b2aca12]::span_encoding::Span>::{closure#0}
  13:     0x7eb3f5b78b2a - rustc_middle[f62d8e2871d7ed5a]::ty::context::tls::with_opt::<rustc_middle[f62d8e2871d7ed5a]::util::bug::opt_span_bug_fmt<rustc_span[674833ee7b2aca12]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7eb3f5b7899b - rustc_middle[f62d8e2871d7ed5a]::ty::context::tls::with_context_opt::<rustc_middle[f62d8e2871d7ed5a]::ty::context::tls::with_opt<rustc_middle[f62d8e2871d7ed5a]::util::bug::opt_span_bug_fmt<rustc_span[674833ee7b2aca12]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7eb3f2ca9330 - rustc_middle[f62d8e2871d7ed5a]::util::bug::bug_fmt
  16:     0x7eb3f88e53a3 - rustc_const_eval[225f976b6d84e0d4]::check_consts::qualifs::in_operand::<rustc_const_eval[225f976b6d84e0d4]::check_consts::qualifs::HasMutInterior, <rustc_const_eval[225f976b6d84e0d4]::check_consts::resolver::TransferFunction<rustc_const_eval[225f976b6d84e0d4]::check_consts::qualifs::HasMutInterior> as rustc_middle[f62d8e2871d7ed5a]::mir::visit::Visitor>::visit_assign::{closure#0}>.cold
  17:     0x7eb3f7872de5 - <rustc_const_eval[225f976b6d84e0d4]::check_consts::resolver::FlowSensitiveAnalysis<rustc_const_eval[225f976b6d84e0d4]::check_consts::qualifs::HasMutInterior> as rustc_mir_dataflow[27782b7c2b798f03]::framework::Analysis>::apply_primary_statement_effect
  18:     0x7eb3f7874dd1 - <rustc_const_eval[225f976b6d84e0d4]::check_consts::check::Qualifs>::has_mut_interior
  19:     0x7eb3f78748ad - <rustc_const_eval[225f976b6d84e0d4]::check_consts::check::Checker>::qualifs_in_return_place
  20:     0x7eb3f7874195 - rustc_mir_transform[8802a7a466bf19d]::mir_const_qualif
  21:     0x7eb3f7873fe5 - rustc_query_impl[b8ddf5711aeae68a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_const_qualif::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 4usize]>>
  22:     0x7eb3f7873473 - rustc_query_system[e527f3fe7b1ba41c]::query::plumbing::try_execute_query::<rustc_query_impl[b8ddf5711aeae68a]::DynamicConfig<rustc_query_system[e527f3fe7b1ba41c]::query::caches::DefIdCache<rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[b8ddf5711aeae68a]::plumbing::QueryCtxt, false>
  23:     0x7eb3f78731cf - rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_const_qualif::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7eb3f3f8b030 - rustc_mir_transform[8802a7a466bf19d]::mir_promoted
  25:     0x7eb3f72a4a5a - rustc_query_impl[b8ddf5711aeae68a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 16usize]>>
  26:     0x7eb3f72a4d08 - rustc_query_system[e527f3fe7b1ba41c]::query::plumbing::try_execute_query::<rustc_query_impl[b8ddf5711aeae68a]::DynamicConfig<rustc_data_structures[63644864ec52dfbb]::vec_cache::VecCache<rustc_span[674833ee7b2aca12]::def_id::LocalDefId, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[e527f3fe7b1ba41c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[b8ddf5711aeae68a]::plumbing::QueryCtxt, false>
  27:     0x7eb3f72a4964 - rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7eb3f6edb68a - rustc_borrowck[16831c75c4923d8d]::mir_borrowck
  29:     0x7eb3f6edb519 - rustc_query_impl[b8ddf5711aeae68a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7eb3f6eda2e6 - rustc_query_system[e527f3fe7b1ba41c]::query::plumbing::try_execute_query::<rustc_query_impl[b8ddf5711aeae68a]::DynamicConfig<rustc_data_structures[63644864ec52dfbb]::vec_cache::VecCache<rustc_span[674833ee7b2aca12]::def_id::LocalDefId, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[e527f3fe7b1ba41c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[b8ddf5711aeae68a]::plumbing::QueryCtxt, false>
  31:     0x7eb3f6ed9bd2 - rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7eb3f773095b - rustc_mir_transform[8802a7a466bf19d]::mir_drops_elaborated_and_const_checked
  33:     0x7eb3f772ffef - rustc_query_impl[b8ddf5711aeae68a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7eb3f6eda2e6 - rustc_query_system[e527f3fe7b1ba41c]::query::plumbing::try_execute_query::<rustc_query_impl[b8ddf5711aeae68a]::DynamicConfig<rustc_data_structures[63644864ec52dfbb]::vec_cache::VecCache<rustc_span[674833ee7b2aca12]::def_id::LocalDefId, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[e527f3fe7b1ba41c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[b8ddf5711aeae68a]::plumbing::QueryCtxt, false>
  35:     0x7eb3f6ed9b1a - rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7eb3f7817e91 - rustc_mir_transform[8802a7a466bf19d]::mir_for_ctfe
  37:     0x7eb3f7817d0b - rustc_query_impl[b8ddf5711aeae68a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_for_ctfe::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 8usize]>>
  38:     0x7eb3f6c249bd - rustc_query_system[e527f3fe7b1ba41c]::query::plumbing::try_execute_query::<rustc_query_impl[b8ddf5711aeae68a]::DynamicConfig<rustc_query_system[e527f3fe7b1ba41c]::query::caches::DefIdCache<rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[b8ddf5711aeae68a]::plumbing::QueryCtxt, false>
  39:     0x7eb3f7b1aa22 - rustc_query_impl[b8ddf5711aeae68a]::query_impl::mir_for_ctfe::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7eb3f7addf97 - <rustc_const_eval[225f976b6d84e0d4]::interpret::eval_context::InterpCx<rustc_const_eval[225f976b6d84e0d4]::const_eval::machine::CompileTimeMachine>>::init_fn_call
  41:     0x7eb3f7b1c58f - rustc_const_eval[225f976b6d84e0d4]::const_eval::eval_queries::eval_to_allocation_raw_provider
  42:     0x7eb3f7b1b298 - rustc_query_impl[b8ddf5711aeae68a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b8ddf5711aeae68a]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 24usize]>>
  43:     0x7eb3f78f6f41 - rustc_query_system[e527f3fe7b1ba41c]::query::plumbing::try_execute_query::<rustc_query_impl[b8ddf5711aeae68a]::DynamicConfig<rustc_query_system[e527f3fe7b1ba41c]::query::caches::DefaultCache<rustc_middle[f62d8e2871d7ed5a]::ty::PseudoCanonicalInput<rustc_middle[f62d8e2871d7ed5a]::mir::interpret::GlobalId>, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[b8ddf5711aeae68a]::plumbing::QueryCtxt, false>
  44:     0x7eb3f78f6afb - rustc_query_impl[b8ddf5711aeae68a]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  45:     0x7eb3f78f3ffd - rustc_const_eval[225f976b6d84e0d4]::const_eval::eval_queries::eval_to_const_value_raw_provider
  46:     0x7eb3f78f3e00 - rustc_query_impl[b8ddf5711aeae68a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b8ddf5711aeae68a]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 24usize]>>
  47:     0x7eb3f78f27b8 - rustc_query_system[e527f3fe7b1ba41c]::query::plumbing::try_execute_query::<rustc_query_impl[b8ddf5711aeae68a]::DynamicConfig<rustc_query_system[e527f3fe7b1ba41c]::query::caches::DefaultCache<rustc_middle[f62d8e2871d7ed5a]::ty::PseudoCanonicalInput<rustc_middle[f62d8e2871d7ed5a]::mir::interpret::GlobalId>, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 24usize]>>, false, true, false>, rustc_query_impl[b8ddf5711aeae68a]::plumbing::QueryCtxt, false>
  48:     0x7eb3f78f2355 - rustc_query_impl[b8ddf5711aeae68a]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  49:     0x7eb3f6ed8c75 - rustc_hir_analysis[a4b8650fa8fb028e]::check_crate
  50:     0x7eb3f6ed4577 - rustc_interface[82c1fd2543dc0997]::passes::run_required_analyses
  51:     0x7eb3f789249e - rustc_interface[82c1fd2543dc0997]::passes::analysis
  52:     0x7eb3f7892471 - rustc_query_impl[b8ddf5711aeae68a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b8ddf5711aeae68a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 0usize]>>
  53:     0x7eb3f78954ba - rustc_query_system[e527f3fe7b1ba41c]::query::plumbing::try_execute_query::<rustc_query_impl[b8ddf5711aeae68a]::DynamicConfig<rustc_query_system[e527f3fe7b1ba41c]::query::caches::SingleCache<rustc_middle[f62d8e2871d7ed5a]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[b8ddf5711aeae68a]::plumbing::QueryCtxt, false>
  54:     0x7eb3f789507b - rustc_query_impl[b8ddf5711aeae68a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  55:     0x7eb3f7e09cbf - rustc_interface[82c1fd2543dc0997]::passes::create_and_enter_global_ctxt::<core[50b5a8f5e07183b8]::option::Option<rustc_interface[82c1fd2543dc0997]::queries::Linker>, rustc_driver_impl[fce054646584467]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  56:     0x7eb3f7df9681 - rustc_interface[82c1fd2543dc0997]::interface::run_compiler::<(), rustc_driver_impl[fce054646584467]::run_compiler::{closure#0}>::{closure#1}
  57:     0x7eb3f7db9c06 - std[aebe2beb07d4602e]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[82c1fd2543dc0997]::util::run_in_thread_with_globals<rustc_interface[82c1fd2543dc0997]::util::run_in_thread_pool_with_globals<rustc_interface[82c1fd2543dc0997]::interface::run_compiler<(), rustc_driver_impl[fce054646584467]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  58:     0x7eb3f7db98ef - <<std[aebe2beb07d4602e]::thread::Builder>::spawn_unchecked_<rustc_interface[82c1fd2543dc0997]::util::run_in_thread_with_globals<rustc_interface[82c1fd2543dc0997]::util::run_in_thread_pool_with_globals<rustc_interface[82c1fd2543dc0997]::interface::run_compiler<(), rustc_driver_impl[fce054646584467]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[50b5a8f5e07183b8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  59:     0x7eb3f7dbaebd - std::sys::pal::unix::thread::Thread::new::thread_start::h45be790786894548
  60:     0x7eb3f188aaa4 - <unknown>
  61:     0x7eb3f1917a34 - clone
  62:                0x0 - <unknown>
Backtrace

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: compiler/rustc_const_eval/src/check_consts/qualifs.rs:359:13: expected ConstKind::Param or ConstKind::Value here, found UnevaluatedConst { def: DefId(0:8 ~ playground[ab6f]::arr_insert::{constant#2}), args: [N/#0, T/#1] }


thread 'rustc' panicked at compiler/rustc_const_eval/src/check_consts/qualifs.rs:359:13:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: rustc_const_eval::check_consts::qualifs::in_operand::<rustc_const_eval::check_consts::qualifs::HasMutInterior, <rustc_const_eval::check_consts::resolver::TransferFunction<rustc_const_eval::check_consts::qualifs::HasMutInterior> as rustc_middle::mir::visit::Visitor>::visit_assign::{closure#0}>.cold
   7: <rustc_const_eval::check_consts::resolver::FlowSensitiveAnalysis<rustc_const_eval::check_consts::qualifs::HasMutInterior> as rustc_mir_dataflow::framework::Analysis>::apply_primary_statement_effect
   8: <rustc_const_eval::check_consts::check::Qualifs>::has_mut_interior
   9: <rustc_const_eval::check_consts::check::Checker>::qualifs_in_return_place
  10: rustc_mir_transform::mir_const_qualif
      [... omitted 1 frame ...]
  11: rustc_mir_transform::mir_promoted
      [... omitted 1 frame ...]
  12: rustc_borrowck::mir_borrowck
      [... omitted 1 frame ...]
  13: rustc_mir_transform::mir_drops_elaborated_and_const_checked
      [... omitted 1 frame ...]
  14: rustc_mir_transform::mir_for_ctfe
      [... omitted 1 frame ...]
  15: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::init_fn_call
  16: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
      [... omitted 1 frame ...]
  17: rustc_const_eval::const_eval::eval_queries::eval_to_const_value_raw_provider
      [... omitted 1 frame ...]
  18: rustc_hir_analysis::check_crate
  19: rustc_interface::passes::run_required_analyses
  20: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  21: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  22: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 `/playground/rustc-ice-2025-05-30T23_04_02-26.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_const_qualif] const checking `arr_insert`
#1 [mir_promoted] promoting constants in MIR for `arr_insert`
#2 [mir_borrowck] borrow-checking `arr_insert`
#3 [mir_drops_elaborated_and_const_checked] elaborating drops for `arr_insert`
#4 [mir_for_ctfe] caching mir of `arr_insert` for CTFE
#5 [eval_to_allocation_raw] const-evaluating + checking `MY_ARR`
#6 [eval_to_const_value_raw] simplifying constant for the type system `MY_ARR`
#7 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground` (bin "playground")

This is using the feature #![feature(generic_const_exprs)] !
@VirgileHenry VirgileHenry added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 30, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 30, 2025
@cushionbadak
Copy link

searched nightlies: from nightly-2025-01-01 to nightly-2025-05-30
regressed nightly: nightly-2025-01-29
searched commit range: 2f348cb...bf1b174
regressed commit: fdd1a3b

bisected with cargo-bisect-rustc v0.6.9

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --end=2025-05-30 --regress ice --preserve --script rustc -- 141801.rs
********************************************************************************
Regression in fdd1a3b02687817cea41f6bacae3d5fbed2b2cd0
********************************************************************************

Attempting to search unrolled perf builds
Found commits ["93c2c039", "a88bb5b0", "cfb91884", "b1ba7742", "28363945", "1f424b2f", "5fa0022a", "3b0743e7"]
installing 93c2c03916d98677da55d6befdebea7557c18c7a
rust-std-nightly-x86_64-unknown-linux-gnu: 30.21 MB / 30.21 MB [==================================] 100.00 % 12.68 MB/s testing...
RESULT: 93c2c03916d98677da55d6befdebea7557c18c7a, ===> Script did not ICE

installing a88bb5b0c4c03e32ba76f172bdf7152b029bf3b1
rust-std-nightly-x86_64-unknown-linux-gnu: 30.18 MB / 30.18 MB [==================================] 100.00 % 12.07 MB/s testing...
RESULT: a88bb5b0c4c03e32ba76f172bdf7152b029bf3b1, ===> Script did not ICE

installing cfb91884481dfe04e596629bb4754f3f50608a8a
rust-std-nightly-x86_64-unknown-linux-gnu: 30.20 MB / 30.20 MB [==================================] 100.00 % 12.36 MB/s testing...
RESULT: cfb91884481dfe04e596629bb4754f3f50608a8a, ===> Script did not ICE

installing b1ba7742813297d6f858eca03b84d41e6d67c6b4
rust-std-nightly-x86_64-unknown-linux-gnu: 30.16 MB / 30.16 MB [==================================] 100.00 % 11.81 MB/s testing...
RESULT: b1ba7742813297d6f858eca03b84d41e6d67c6b4, ===> Script found ICE

Regression in https://github.com/rust-lang-ci/rust/commit/b1ba7742813297d6f858eca03b84d41e6d67c6b4
The PR introducing the regression in this rollup is #135748: Lower index bounds checking to `PtrMetadata`, this time wit…

@cushionbadak
Copy link

Below short code shows the same ICE location:

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

trait Trait1 {
    const ASSOC_CONST: usize;
}

const fn generic_arr<Z: Trait1, T: Copy>(t: [T; Z::ASSOC_CONST]) -> T {
    t[0]
}

fn main() {}
Output

error: internal compiler error: compiler/rustc_const_eval/src/check_consts/qualifs.rs:359:13: expected ConstKind::Param or ConstKind::Value here, found UnevaluatedConst { def: DefId(0:8 ~ gce_1[4332]::generic_arr::{constant#0}), args: [Z/#0, T/#1] }


thread 'rustc' panicked at compiler/rustc_const_eval/src/check_consts/qualifs.rs:359:13:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: rustc_const_eval::check_consts::qualifs::in_operand::<rustc_const_eval::check_consts::qualifs::HasMutInterior, <rustc_const_eval::check_consts::resolver::TransferFunction<rustc_const_eval::check_consts::qualifs::HasMutInterior> as rustc_middle::mir::visit::Visitor>::visit_assign::{closure#0}>
   7: <rustc_const_eval::check_consts::resolver::FlowSensitiveAnalysis<rustc_const_eval::check_consts::qualifs::HasMutInterior> as rustc_mir_dataflow::framework::Analysis>::apply_primary_statement_effect
   8: <rustc_const_eval::check_consts::check::Qualifs>::has_mut_interior
   9: <rustc_const_eval::check_consts::check::Checker>::qualifs_in_return_place
  10: rustc_mir_transform::mir_const_qualif
      [... omitted 1 frame ...]
  11: rustc_mir_transform::mir_promoted
      [... omitted 1 frame ...]
  12: rustc_borrowck::mir_borrowck
      [... omitted 1 frame ...]
  13: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  14: rustc_interface::passes::run_required_analyses
  15: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  16: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 `/Users/jisukbyun/workspace/250203 scratch/rustc-ice-2025-05-31T02_19_47-32434.txt` to your bug report

query stack during panic:
#0 [mir_const_qualif] const checking `generic_arr`
#1 [mir_promoted] promoting constants in MIR for `generic_arr`
#2 [mir_borrowck] borrow-checking `generic_arr`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

Notes

  • ICE location: compiler/rustc_const_eval/src/check_consts/qualifs.rs Line-359

    let uneval = match constant.const_ {
    Const::Ty(_, ct)
    if matches!(
    ct.kind(),
    ty::ConstKind::Param(_) | ty::ConstKind::Error(_) | ty::ConstKind::Value(_)
    ) =>
    {
    None
    }
    Const::Ty(_, c) => {
    bug!("expected ConstKind::Param or ConstKind::Value here, found {:?}", c)
    }
    Const::Unevaluated(uv, _) => Some(uv),
    Const::Val(..) => None,
    };

  • Originally, I found above code with min_generic_const_args, as a mutant of tests/ui/consts/const-fn.rs

    #![allow(incomplete_features)]
    #![feature(min_generic_const_args)]
    
    trait Trait1 {
        #[type_const]
        const ASSOC_CONST: usize;
    }
    
    const fn generic_arr<Z: Trait1, T: Copy>(t: [T; Z::ASSOC_CONST]) -> T {
        t[0]
    }
    
    fn main() {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants