Repository: rust
Issue: ICE: const eval: `InterpErrorInfo(InterpErrorInfoInner { kind: ResourceExhaustion(MemoryExhausted) .. `
Labels: I-ICE,T-compiler,C-bug,A-mir-opt-inlining,S-bug-has-test,A-mir-opt-GVN

<!--
ICE: Rustc ./a.rs '-Zmir-opt-level=5 -Zvalidate-mir -ooutputfile -Zdump-mir-dir=dir' 'thread 'rustc' panicked at compiler/rustc_const_eval/src/const_eval/valtrees.rs:225:55: 'called `Result::unwrap()` on an `Err` value: InterpErrorInfo(InterpErrorInfoInner { kind: ResourceExhaustion(MemoryExhausted), backtrace: InterpErrorBacktrace { backtrace: None } })'', 'thread 'rustc' panicked at compiler/rustc_const_eval/src/const_eval/valtrees.rs:225:55: 'called `Result::unwrap()` on an `Err` value: InterpErrorInfo(InterpErrorInfoInner { kind: ResourceExhaustion(MemoryExhausted), backtrace: InterpErrorBacktrace { backtrace: None } })''
File: /home/gh-matthiaskrgr/tmp/a.rs
-->

auto-reduced (treereduce-rust):
````rust
//@compile-flags: -Zmir-opt-level=5 -Zvalidate-mir
pub fn function_with_bytes<const BYTES: &'static [u8; 0xa9008fb6c9d81e42_0e25730562a601c8_u128]>(
) -> &'static [u8] {
    BYTES
}

pub fn main() {
    assert_eq!(
        function_with_bytes::<b"foo {:}">(),
        &[0x41, 0x41, 0x41, 0x41]
    );
}

````

original:
````rust
pub fn function_with_bytes<const BYTES: &'static [u8; 0xa9008fb6c9d81e42_0e25730562a601c8_u128]>() -> &'static [u8] {
    BYTES
}

pub fn main() {
    assert_eq!(function_with_bytes::<b"foo {:}">(), &[0x41, 0x41, 0x41, 0x41]);
}

````

Version information
````
rustc 1.85.0-nightly (a2bcfae5c 2024-12-22)
binary: rustc
commit-hash: a2bcfae5c5d05dd7806a79194cda39108ed6cd7d
commit-date: 2024-12-22
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

````

Possibly related line of code:
https://github.com/rust-lang/rust/blob/a2bcfae5c5d05dd7806a79194cda39108ed6cd7d/compiler/rustc_const_eval/src/const_eval/valtrees.rs#L219-L231

Command:
`/home/gh-matthiaskrgr/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zvalidate-mir`

<details><summary><strong>Program output</strong></summary>
<p>

```
error: `&'static [u8; 1019347357636362696]` is forbidden as the type of a const generic parameter
 --> /run/user/1085/tmp/dir.F5Q0BVNjJitF/rustc_testrunner_tmpdir_reporting.HKYel3RV0kZB/mvce.rs:1:41
  |
1 | pub fn function_with_bytes<const BYTES: &'static [u8; 0xa9008fb6c9d81e42_0e25730562a601c8_u128]>(
  |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: the only supported types are integers, `bool`, and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
  |
1 + #![feature(adt_const_params)]
  |
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
  |
1 + #![feature(unsized_const_params)]
  |

error[E0308]: mismatched types
 --> /run/user/1085/tmp/dir.F5Q0BVNjJitF/rustc_testrunner_tmpdir_reporting.HKYel3RV0kZB/mvce.rs:1:55
  |
1 | pub fn function_with_bytes<const BYTES: &'static [u8; 0xa9008fb6c9d81e42_0e25730562a601c8_u128]>(
  |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `u128`
  |
help: change the type of the numeric literal from `u128` to `usize`
  |
1 | pub fn function_with_bytes<const BYTES: &'static [u8; 0xa9008fb6c9d81e42_0e25730562a601c8_usize]>(
  |                                                                                           ~~~~~

error[E0308]: mismatched types
 --> /run/user/1085/tmp/dir.F5Q0BVNjJitF/rustc_testrunner_tmpdir_reporting.HKYel3RV0kZB/mvce.rs:8:31
  |
8 |         function_with_bytes::<b"foo {:}">(),
  |                               ^^^^^^^^^^ expected an array with a size of 1019347357636362696, found one with a size of 7

thread 'rustc' panicked at compiler/rustc_const_eval/src/const_eval/valtrees.rs:225:55:
called `Result::unwrap()` on an `Err` value: InterpErrorInfo(InterpErrorInfoInner { kind: ResourceExhaustion(MemoryExhausted), backtrace: InterpErrorBacktrace { backtrace: None } })
stack backtrace:
   0:     0x73f0e04b775a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he57e0fea652ab9fd
   1:     0x73f0e0c13866 - core::fmt::write::hd55e7fc717febc4b
   2:     0x73f0e1b48bd1 - std::io::Write::write_fmt::h78281f831863065d
   3:     0x73f0e04b75b2 - std::sys::backtrace::BacktraceLock::print::h7acbe748d8539c38
   4:     0x73f0e04b9aaa - std::panicking::default_hook::{{closure}}::hea23bfd5c34c8db7
   5:     0x73f0e04b98f3 - std::panicking::default_hook::hff2113baba127713
   6:     0x73f0df62ecc8 - std[e6d36fd50c659ae0]::panicking::update_hook::<alloc[4740fe411def7ec4]::boxed::Box<rustc_driver_impl[89e0991809749e6d]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x73f0e04ba2a8 - std::panicking::rust_panic_with_hook::hfc1c16069db4c6ff
   8:     0x73f0e04b9f9a - std::panicking::begin_panic_handler::{{closure}}::hb21d96c911822c44
   9:     0x73f0e04b7c09 - std::sys::backtrace::__rust_end_short_backtrace::h8e09f77e03188563
  10:     0x73f0e04b9c5d - rust_begin_unwind
  11:     0x73f0dd19c340 - core::panicking::panic_fmt::hfa3a678dda58d831
  12:     0x73f0dd63d256 - core::result::unwrap_failed::h9cfde6874ed92b87
  13:     0x73f0e1b7a5f3 - rustc_const_eval[c45611a6115a718]::const_eval::valtrees::create_valtree_place
  14:     0x73f0e13c7150 - rustc_const_eval[c45611a6115a718]::const_eval::valtrees::valtree_to_ref
  15:     0x73f0e1727db9 - rustc_const_eval[c45611a6115a718]::const_eval::valtrees::valtree_to_const_value
  16:     0x73f0e1727b72 - <rustc_const_eval[c45611a6115a718]::provide::{closure#1} as core[a17736bada842104]::ops::function::FnOnce<(rustc_middle[5e0371d42ed41497]::ty::context::TyCtxt, (rustc_middle[5e0371d42ed41497]::ty::Ty, rustc_middle[5e0371d42ed41497]::ty::consts::valtree::ValTree))>>::call_once
  17:     0x73f0e1727b2e - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::valtree_to_const_val::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 24usize]>>
  18:     0x73f0e1727aed - <rustc_query_impl[a3a64fb382d359d2]::query_impl::valtree_to_const_val::dynamic_query::{closure#2} as core[a17736bada842104]::ops::function::FnOnce<(rustc_middle[5e0371d42ed41497]::ty::context::TyCtxt, (rustc_middle[5e0371d42ed41497]::ty::Ty, rustc_middle[5e0371d42ed41497]::ty::consts::valtree::ValTree))>>::call_once
  19:     0x73f0e1726c89 - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_query_system[7ed8f12aa9c699c]::query::caches::DefaultCache<(rustc_middle[5e0371d42ed41497]::ty::Ty, rustc_middle[5e0371d42ed41497]::ty::consts::valtree::ValTree), rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  20:     0x73f0e17269bb - rustc_query_impl[a3a64fb382d359d2]::query_impl::valtree_to_const_val::get_query_non_incr::__rust_end_short_backtrace
  21:     0x73f0e1711e25 - <rustc_mir_transform[93024dc8ef41ddad]::gvn::VnState>::insert
  22:     0x73f0e1708aef - <rustc_mir_transform[93024dc8ef41ddad]::gvn::VnState>::simplify_operand
  23:     0x73f0e170aab5 - <rustc_mir_transform[93024dc8ef41ddad]::gvn::VnState>::simplify_rvalue
  24:     0x73f0de6fae3e - <rustc_mir_transform[93024dc8ef41ddad]::gvn::GVN as rustc_mir_transform[93024dc8ef41ddad]::pass_manager::MirPass>::run_pass
  25:     0x73f0e0c0ee6e - rustc_mir_transform[93024dc8ef41ddad]::pass_manager::run_passes_inner
  26:     0x73f0e0d4215f - rustc_mir_transform[93024dc8ef41ddad]::optimized_mir
  27:     0x73f0e0d41a2b - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>
  28:     0x73f0e0d0f21f - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_query_system[7ed8f12aa9c699c]::query::caches::DefIdCache<rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  29:     0x73f0e0d0e6f3 - rustc_query_impl[a3a64fb382d359d2]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  30:     0x73f0ddbc6df9 - <rustc_middle[5e0371d42ed41497]::ty::context::TyCtxt>::instance_mir
  31:     0x73f0e0ebc514 - rustc_interface[36124661c84dc53c]::passes::run_required_analyses
  32:     0x73f0e1b4ca5e - rustc_interface[36124661c84dc53c]::passes::analysis
  33:     0x73f0e1b4ca2f - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 0usize]>>
  34:     0x73f0e1ba7855 - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_query_system[7ed8f12aa9c699c]::query::caches::SingleCache<rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  35:     0x73f0e1ba758e - rustc_query_impl[a3a64fb382d359d2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x73f0e1c437de - rustc_interface[36124661c84dc53c]::passes::create_and_enter_global_ctxt::<core[a17736bada842104]::option::Option<rustc_interface[36124661c84dc53c]::queries::Linker>, rustc_driver_impl[89e0991809749e6d]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  37:     0x73f0e1bc2aa8 - rustc_interface[36124661c84dc53c]::interface::run_compiler::<(), rustc_driver_impl[89e0991809749e6d]::run_compiler::{closure#0}>::{closure#1}
  38:     0x73f0e1a51311 - std[e6d36fd50c659ae0]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[36124661c84dc53c]::util::run_in_thread_with_globals<rustc_interface[36124661c84dc53c]::util::run_in_thread_pool_with_globals<rustc_interface[36124661c84dc53c]::interface::run_compiler<(), rustc_driver_impl[89e0991809749e6d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  39:     0x73f0e1a517a6 - <<std[e6d36fd50c659ae0]::thread::Builder>::spawn_unchecked_<rustc_interface[36124661c84dc53c]::util::run_in_thread_with_globals<rustc_interface[36124661c84dc53c]::util::run_in_thread_pool_with_globals<rustc_interface[36124661c84dc53c]::interface::run_compiler<(), rustc_driver_impl[89e0991809749e6d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a17736bada842104]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x73f0e1a52d81 - std::sys::pal::unix::thread::Thread::new::thread_start::h0cedf7b69d2cc02b
  41:     0x73f0dbc9ca94 - start_thread
                               at ./nptl/pthread_create.c:447:8
  42:     0x73f0dbd29c3c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
  43:                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.85.0-nightly (a2bcfae5c 2024-12-22) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 -Z validate-mir -Z dump-mir-dir=dir

query stack during panic:
#0 [valtree_to_const_val] converting type-level constant value to mir constant value
#1 [optimized_mir] optimizing MIR for `main`
end of query stack
error: aborting due to 3 previous errors

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

```

</p>
</details>

<!--
query stack:
#0 [valtree_to_const_val] converting type-level constant value to mir constant value
#1 [optimized_mir] optimizing MIR for `main`

-->