Skip to content

ICE: fake borrows are always indirect #136298

Closed
@matthiaskrgr

Description

@matthiaskrgr
Member

auto-reduced (treereduce-rust):

const ARR: [u16] = [42, 43, 44, 500, 46, 47];

const BONG: [i32; (ARR[0] - 41) as usize] = [5];

original:

const ARR: [u16] = [42, 43, 44, 500, 46, 47];
const IDX: usize = 3;
const VAL: i32 = ARR[IDX];
const BONG: [i32; (ARR[0] - 41) as usize] = [5];
const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
//~^ ERROR: mismatched types
//~| expected an array
const BOO: [i32; (ARR[0] - 41) as u8] = [5, 99];
//~^ ERROR: mismatched types
//~| expected an array

fn main() {
    let _ = VAL;
}

Version information

rustc 1.86.0-nightly (e6f12c8b7 2025-01-30)
binary: rustc
commit-hash: e6f12c8b7d8d5c821c32fb2739ea01d1d874c58a
commit-date: 2025-01-30
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Possibly related line of code:

}
}
Rvalue::RawPtr(RawPtrKind::FakeForPtrMetadata, place) => {
// These are only inserted for slice length, so the place must already be indirect.
// This implies we do not have to worry about whether the borrow escapes.
assert!(place.is_indirect(), "fake borrows are always indirect");
}
Rvalue::Cast(
CastKind::PointerCoercion(
PointerCoercion::MutToConstPointer
| PointerCoercion::ArrayToPointer

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.45pNVAwEMplG/rustc_testrunner_tmpdir_reporting.ZlwAFcmDkhGl/mvce.rs:3:49
  |
3 | const BONG: [i32; (ARR[0] - 41) as usize] = [5];
  |                                                 ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.45pNVAwEMplG/rustc_testrunner_tmpdir_reporting.ZlwAFcmDkhGl/mvce.rs`

error[E0277]: the size for values of type `[u16]` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.45pNVAwEMplG/rustc_testrunner_tmpdir_reporting.ZlwAFcmDkhGl/mvce.rs:1:12
  |
1 | const ARR: [u16] = [42, 43, 44, 500, 46, 47];
  |            ^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `[u16]`

error[E0308]: mismatched types
 --> /tmp/icemaker_global_tempdir.45pNVAwEMplG/rustc_testrunner_tmpdir_reporting.ZlwAFcmDkhGl/mvce.rs:1:20
  |
1 | const ARR: [u16] = [42, 43, 44, 500, 46, 47];
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u16]`, found `[u16; 6]`

error[E0277]: the size for values of type `[u16]` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.45pNVAwEMplG/rustc_testrunner_tmpdir_reporting.ZlwAFcmDkhGl/mvce.rs:1:20
  |
1 | const ARR: [u16] = [42, 43, 44, 500, 46, 47];
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `[u16]`
  = note: constant expressions must have a statically known size


thread 'rustc' panicked at compiler/rustc_const_eval/src/check_consts/check.rs:637:17:
fake borrows are always indirect
stack backtrace:
   0:     0x73cd7b62d410 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h32b76eca82481332
   1:     0x73cd7be138e6 - core::fmt::write::h6aab99975a3e1e0d
   2:     0x73cd7cd04bd1 - std::io::Write::write_fmt::h07e3041152301b92
   3:     0x73cd7b62d272 - std::sys::backtrace::BacktraceLock::print::h11198f536c423f0e
   4:     0x73cd7b62f6f2 - std::panicking::default_hook::{{closure}}::hedf2549fe54c612d
   5:     0x73cd7b62f57a - std::panicking::default_hook::h5cafcda49fcb475d
   6:     0x73cd7a789e99 - std[65c60797a113df8d]::panicking::update_hook::<alloc[26d4a3e3ec5433a5]::boxed::Box<rustc_driver_impl[88e265ae9927f55c]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x73cd7b630273 - std::panicking::rust_panic_with_hook::h9e0ce671ec08e8dc
   8:     0x73cd7b62ff36 - std::panicking::begin_panic_handler::{{closure}}::h1bdae80e81a52f07
   9:     0x73cd7b62d8f9 - std::sys::backtrace::__rust_end_short_backtrace::hba69e255f02ebb17
  10:     0x73cd7b62fc2d - rust_begin_unwind
  11:     0x73cd78252710 - core::panicking::panic_fmt::hb5ac2b35a2382f0f
  12:     0x73cd7c5d6a48 - <rustc_const_eval[82ed6d24565cf389]::check_consts::check::Checker as rustc_middle[c95cf357e72e9a85]::mir::visit::Visitor>::visit_basic_block_data
  13:     0x73cd7c5d4ed8 - <rustc_const_eval[82ed6d24565cf389]::check_consts::check::Checker>::check_body
  14:     0x73cd7c5b8fc3 - rustc_mir_transform[5e669e96cb5351c6]::mir_const_qualif
  15:     0x73cd7c5b8ea5 - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::mir_const_qualif::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 4usize]>>
  16:     0x73cd7c5b8431 - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_query_system[ff51b95ecba2cb21]::query::caches::DefIdCache<rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  17:     0x73cd7c5b81a2 - rustc_query_impl[a79c5430108c0b60]::query_impl::mir_const_qualif::get_query_non_incr::__rust_end_short_backtrace
  18:     0x73cd7c5b7fcb - rustc_middle[c95cf357e72e9a85]::query::plumbing::query_get_at::<rustc_query_system[ff51b95ecba2cb21]::query::caches::DefIdCache<rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 4usize]>>>
  19:     0x73cd79357ccb - rustc_mir_transform[5e669e96cb5351c6]::mir_promoted
  20:     0x73cd7c1e0dd4 - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 16usize]>>
  21:     0x73cd7c1e1097 - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_data_structures[9c6ee9e9e5334c83]::vec_cache::VecCache<rustc_span[cb34d841a75ac9bc]::def_id::LocalDefId, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[ff51b95ecba2cb21]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  22:     0x73cd7c1e0cda - rustc_query_impl[a79c5430108c0b60]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  23:     0x73cd7ceb0aef - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 8usize]>>
  24:     0x73cd7c1a580e - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_data_structures[9c6ee9e9e5334c83]::vec_cache::VecCache<rustc_span[cb34d841a75ac9bc]::def_id::LocalDefId, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[ff51b95ecba2cb21]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  25:     0x73cd7c1a5325 - rustc_query_impl[a79c5430108c0b60]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  26:     0x73cd7c1a4337 - rustc_mir_transform[5e669e96cb5351c6]::mir_drops_elaborated_and_const_checked
  27:     0x73cd7c1a3e65 - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 8usize]>>
  28:     0x73cd7c1a580e - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_data_structures[9c6ee9e9e5334c83]::vec_cache::VecCache<rustc_span[cb34d841a75ac9bc]::def_id::LocalDefId, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[ff51b95ecba2cb21]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  29:     0x73cd7c1a0dcd - rustc_query_impl[a79c5430108c0b60]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  30:     0x73cd7c5b8e80 - rustc_middle[c95cf357e72e9a85]::query::plumbing::query_get_at::<rustc_data_structures[9c6ee9e9e5334c83]::vec_cache::VecCache<rustc_span[cb34d841a75ac9bc]::def_id::LocalDefId, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[ff51b95ecba2cb21]::dep_graph::graph::DepNodeIndex>>
  31:     0x73cd7c5bb02e - rustc_mir_transform[5e669e96cb5351c6]::mir_for_ctfe
  32:     0x73cd7c5bafa3 - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::mir_for_ctfe::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 8usize]>>
  33:     0x73cd7bef265f - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_query_system[ff51b95ecba2cb21]::query::caches::DefIdCache<rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  34:     0x73cd7bef059f - rustc_query_impl[a79c5430108c0b60]::query_impl::mir_for_ctfe::get_query_non_incr::__rust_end_short_backtrace
  35:     0x73cd7bef06e4 - <rustc_const_eval[82ed6d24565cf389]::interpret::eval_context::InterpCx<rustc_const_eval[82ed6d24565cf389]::const_eval::machine::CompileTimeMachine>>::load_mir
  36:     0x73cd797a0ab8 - rustc_const_eval[82ed6d24565cf389]::const_eval::eval_queries::eval_to_allocation_raw_provider
  37:     0x73cd7c67309c - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 24usize]>>
  38:     0x73cd7c672a3a - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_query_system[ff51b95ecba2cb21]::query::caches::DefaultCache<rustc_middle[c95cf357e72e9a85]::ty::PseudoCanonicalInput<rustc_middle[c95cf357e72e9a85]::mir::interpret::GlobalId>, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  39:     0x73cd7c6726bb - rustc_query_impl[a79c5430108c0b60]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  40:     0x73cd7c64f46d - rustc_const_eval[82ed6d24565cf389]::const_eval::valtrees::eval_to_valtree
  41:     0x73cd7c64f23e - <rustc_const_eval[82ed6d24565cf389]::provide::{closure#0} as core[b38de05c6bab522f]::ops::function::FnOnce<(rustc_middle[c95cf357e72e9a85]::ty::context::TyCtxt, rustc_middle[c95cf357e72e9a85]::ty::PseudoCanonicalInput<rustc_middle[c95cf357e72e9a85]::mir::interpret::GlobalId>)>>::call_once
  42:     0x73cd7c64f1d0 - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 24usize]>>
  43:     0x73cd7c64f189 - <rustc_query_impl[a79c5430108c0b60]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[b38de05c6bab522f]::ops::function::FnOnce<(rustc_middle[c95cf357e72e9a85]::ty::context::TyCtxt, rustc_middle[c95cf357e72e9a85]::ty::PseudoCanonicalInput<rustc_middle[c95cf357e72e9a85]::mir::interpret::GlobalId>)>>::call_once
  44:     0x73cd7c672b13 - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_query_system[ff51b95ecba2cb21]::query::caches::DefaultCache<rustc_middle[c95cf357e72e9a85]::ty::PseudoCanonicalInput<rustc_middle[c95cf357e72e9a85]::mir::interpret::GlobalId>, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  45:     0x73cd7c67242d - rustc_query_impl[a79c5430108c0b60]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
  46:     0x73cd7c7acb0c - rustc_middle[c95cf357e72e9a85]::query::plumbing::query_get_at::<rustc_query_system[ff51b95ecba2cb21]::query::caches::DefaultCache<rustc_middle[c95cf357e72e9a85]::ty::PseudoCanonicalInput<rustc_middle[c95cf357e72e9a85]::mir::interpret::GlobalId>, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 24usize]>>>
  47:     0x73cd7c7ac122 - <rustc_middle[c95cf357e72e9a85]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
  48:     0x73cd7c7abfb9 - <rustc_middle[c95cf357e72e9a85]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  49:     0x73cd7c7abcf7 - rustc_trait_selection[d3a832fb8e061b24]::traits::try_evaluate_const
  50:     0x73cd7c7ab783 - <rustc_trait_selection[d3a832fb8e061b24]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[6a899794ba15143]::fold::TypeFolder<rustc_middle[c95cf357e72e9a85]::ty::context::TyCtxt>>::fold_const
  51:     0x73cd7c7c39ae - <rustc_middle[c95cf357e72e9a85]::ty::Ty as rustc_type_ir[6a899794ba15143]::fold::TypeSuperFoldable<rustc_middle[c95cf357e72e9a85]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_trait_selection[d3a832fb8e061b24]::traits::normalize::AssocTypeNormalizer>
  52:     0x73cd7c46cc59 - <rustc_hir_analysis[52c5e5868dd20650]::check::wfcheck::WfCheckingCtxt>::normalize::<rustc_middle[c95cf357e72e9a85]::ty::Ty>
  53:     0x73cd7c470bdd - rustc_hir_analysis[52c5e5868dd20650]::check::wfcheck::check_item_type
  54:     0x73cd7c465741 - rustc_hir_analysis[52c5e5868dd20650]::check::wfcheck::check_well_formed
  55:     0x73cd7c464187 - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 1usize]>>
  56:     0x73cd7c463c29 - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_data_structures[9c6ee9e9e5334c83]::vec_cache::VecCache<rustc_span[cb34d841a75ac9bc]::def_id::LocalDefId, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[ff51b95ecba2cb21]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  57:     0x73cd7c463686 - rustc_query_impl[a79c5430108c0b60]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  58:     0x73cd7c4612ac - rustc_hir_analysis[52c5e5868dd20650]::check::wfcheck::check_mod_type_wf
  59:     0x73cd7c4610cb - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 1usize]>>
  60:     0x73cd7cd85948 - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_query_system[ff51b95ecba2cb21]::query::caches::DefaultCache<rustc_span[cb34d841a75ac9bc]::def_id::LocalModDefId, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  61:     0x73cd7cd856f0 - rustc_query_impl[a79c5430108c0b60]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  62:     0x73cd7c1a10e6 - rustc_hir_analysis[52c5e5868dd20650]::check_crate
  63:     0x73cd7c19dc64 - rustc_interface[3e4af95fb941106a]::passes::run_required_analyses
  64:     0x73cd7cd002de - rustc_interface[3e4af95fb941106a]::passes::analysis
  65:     0x73cd7cd002af - rustc_query_impl[a79c5430108c0b60]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a79c5430108c0b60]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 0usize]>>
  66:     0x73cd7ccec015 - rustc_query_system[ff51b95ecba2cb21]::query::plumbing::try_execute_query::<rustc_query_impl[a79c5430108c0b60]::DynamicConfig<rustc_query_system[ff51b95ecba2cb21]::query::caches::SingleCache<rustc_middle[c95cf357e72e9a85]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a79c5430108c0b60]::plumbing::QueryCtxt, false>
  67:     0x73cd7ccebd4e - rustc_query_impl[a79c5430108c0b60]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  68:     0x73cd7ce0be69 - rustc_interface[3e4af95fb941106a]::passes::create_and_enter_global_ctxt::<core[b38de05c6bab522f]::option::Option<rustc_interface[3e4af95fb941106a]::queries::Linker>, rustc_driver_impl[88e265ae9927f55c]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  69:     0x73cd7cd5a498 - rustc_interface[3e4af95fb941106a]::interface::run_compiler::<(), rustc_driver_impl[88e265ae9927f55c]::run_compiler::{closure#0}>::{closure#1}
  70:     0x73cd7cc75f35 - std[65c60797a113df8d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[3e4af95fb941106a]::util::run_in_thread_with_globals<rustc_interface[3e4af95fb941106a]::util::run_in_thread_pool_with_globals<rustc_interface[3e4af95fb941106a]::interface::run_compiler<(), rustc_driver_impl[88e265ae9927f55c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  71:     0x73cd7cc75c19 - <<std[65c60797a113df8d]::thread::Builder>::spawn_unchecked_<rustc_interface[3e4af95fb941106a]::util::run_in_thread_with_globals<rustc_interface[3e4af95fb941106a]::util::run_in_thread_pool_with_globals<rustc_interface[3e4af95fb941106a]::interface::run_compiler<(), rustc_driver_impl[88e265ae9927f55c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b38de05c6bab522f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  72:     0x73cd7cc753ab - std::sys::pal::unix::thread::Thread::new::thread_start::h7b9c2e4fdae6f3c1
  73:     0x73cd76ea339d - <unknown>
  74:     0x73cd76f2849c - <unknown>
  75:                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.86.0-nightly (e6f12c8b7 2025-01-30) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_const_qualif] const checking `BONG::{constant#0}`
#1 [mir_promoted] promoting constants in MIR for `BONG::{constant#0}`
#2 [mir_borrowck] borrow-checking `BONG::{constant#0}`
#3 [mir_drops_elaborated_and_const_checked] elaborating drops for `BONG::{constant#0}`
#4 [mir_for_ctfe] caching mir of `BONG::{constant#0}` for CTFE
#5 [eval_to_allocation_raw] const-evaluating + checking `BONG::{constant#0}`
#6 [eval_to_valtree] evaluating type-level constant
#7 [check_well_formed] checking that `BONG` is well-formed
#8 [check_mod_type_wf] checking that types are well-formed in top-level module
#9 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0308, E0601.
For more information about an error, try `rustc --explain E0277`.

Activity

added
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.
on Jan 30, 2025
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Jan 30, 2025
matthiaskrgr

matthiaskrgr commented on Jan 30, 2025

@matthiaskrgr
MemberAuthor
const A: [u16] = [0];
const B: &[i32] = &[0; A[0] as usize];

pub fn main() {}
matthiaskrgr

matthiaskrgr commented on Jan 30, 2025

@matthiaskrgr
MemberAuthor

bisects to #135748 🐱 cc @compiler-errors

compiler-errors

compiler-errors commented on Jan 30, 2025

@compiler-errors
Member

more minimal:

const ONE: [u16] = [1];

const TWO: u16 = ONE[0];
added a commit that references this issue on Jan 31, 2025

Rollup merge of rust-lang#136325 - compiler-errors:indirectly, r=Ralf…

f1daf9e
added a commit that references this issue on Jan 31, 2025
875d516
removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 1, 2025
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

      Participants

      @matthiaskrgr@compiler-errors@saethlin@rustbot

      Issue actions

        ICE: `fake borrows are always indirect` · Issue #136298 · rust-lang/rust