Repository navigation
[ICE]: can't type-check body of DefId when borrow-checking a const expression in an array length #164572
Copy link
Copy link
Open
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
This ICE may be related to #153735 and #159169, as all three trigger the same internal compiler error: can't type-check body of DefId.
However, unlike the reproducer cases in those issues, this one does not require any unstable features and occurs during borrow checking of an array-length const expression.
The backtrace shows that rustc_borrowck::MirBorrowckCtxt::report_mutability_error invokes typeck, which eventually reaches rustc_hir_typeck::typeck_root and triggers the ICE.
I'm not sure whether these issues share the same underlying cause.
Code
type Array = [u32; {
let mut x = 2;
let y = &mut x;
let w = &mut **&mut y;
*y
}];Meta
rustc --version --verbose:
rustc 1.101.0-nightly (b6eeb93c9 2026-10-18)
binary: rustc
commit-hash: b6eeb93c992027a03e1fd120b6652546396b142c
commit-date: 2026-10-18
host: x86_64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.4
Error output
error: internal compiler error: /rustc-dev/b6eeb93c992027a03e1fd120b6652546396b142c/compiler/rustc_hir_typeck/src/lib.rs:121:9: can't type-check body of DefId(0:3 ~ test[ee2f]::Array)
--> ./test.rs:1:1
|
1 | type Array = [u32; {
| ^^^^^^^^^^
Backtrace
thread 'rustc' (2547702) panicked at /rustc-dev/b6eeb93c992027a03e1fd120b6652546396b142c/compiler/rustc_hir_typeck/src/lib.rs:121:9:
Box<dyn Any>
stack backtrace:
0: 0x7f0eb2689c16 - <<std[2197041a2d5adeae]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[b29223e0788b9091]::fmt::Display>::fmt
1: 0x7f0eb2e104e9 - core[b29223e0788b9091]::fmt::write
2: 0x7f0eb0a8a8bc - <std[2197041a2d5adeae]::sys::stdio::unix::Stderr as core[b29223e0788b9091]::io::write::Write>::write_fmt
3: 0x7f0eb265a94a - std[2197041a2d5adeae]::panicking::default_hook::{closure#0}
4: 0x7f0eb267d595 - std[2197041a2d5adeae]::panicking::default_hook
5: 0x7f0eb1406b29 - std[2197041a2d5adeae]::panicking::update_hook::<alloc[65095dd98ba263e9]::boxed::Box<rustc_driver_impl[fa7a7ce11be7f74c]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f0eb267da32 - std[2197041a2d5adeae]::panicking::panic_with_hook
7: 0x7f0eb2211717 - std[2197041a2d5adeae]::panicking::begin_panic::<rustc_span[9e032005cbbd6ec3]::macros::ExplicitBug>::{closure#0}
8: 0x7f0eb220f73e - std[2197041a2d5adeae]::sys::backtrace::__rust_end_short_backtrace::<std[2197041a2d5adeae]::panicking::begin_panic<rustc_span[9e032005cbbd6ec3]::macros::ExplicitBug>::{closure#0}, !>
9: 0x7f0eb220edcb - std[2197041a2d5adeae]::panicking::begin_panic::<rustc_span[9e032005cbbd6ec3]::macros::ExplicitBug>
10: 0x7f0eae634721 - rustc_span[9e032005cbbd6ec3]::macros::bug_impl
11: 0x7f0eafef5eff - rustc_hir_typeck[a397ac878321cd06]::typeck_with_inspect::{closure#0}::{closure#0}
12: 0x7f0eb427d7fd - rustc_hir_typeck[a397ac878321cd06]::typeck_with_inspect::{closure#0}
13: 0x7f0eb42769f0 - rustc_query_impl[dce42a22f9092267]::query_vtables::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
14: 0x7f0eb2f7b24e - rustc_query_impl[dce42a22f9092267]::execution::try_execute_query::<rustc_data_structures[958118a4c6ab3686]::vec_cache::VecCache<rustc_span[9e032005cbbd6ec3]::def_id::LocalDefId, rustc_middle[981f6d45772a0e11]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[981f6d45772a0e11]::dep_graph::graph::DepNodeIndex>, false>
15: 0x7f0eb2f7ae6b - rustc_query_impl[dce42a22f9092267]::query_vtables::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
16: 0x7f0eaee509a1 - <rustc_middle[981f6d45772a0e11]::ty::context::TyCtxt>::typeck::<rustc_span[9e032005cbbd6ec3]::def_id::LocalDefId>
17: 0x7f0eb108a8ce - <rustc_borrowck[c248656f57656a5c]::MirBorrowckCtxt>::report_mutability_error
18: 0x7f0eb424849a - rustc_borrowck[c248656f57656a5c]::borrowck_check_region_constraints
19: 0x7f0eb420f0db - <rustc_borrowck[c248656f57656a5c]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
20: 0x7f0eb2f7cb55 - rustc_borrowck[c248656f57656a5c]::mir_borrowck
21: 0x7f0eb2f7c859 - rustc_query_impl[dce42a22f9092267]::query_vtables::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
22: 0x7f0eb2f7b24e - rustc_query_impl[dce42a22f9092267]::execution::try_execute_query::<rustc_data_structures[958118a4c6ab3686]::vec_cache::VecCache<rustc_span[9e032005cbbd6ec3]::def_id::LocalDefId, rustc_middle[981f6d45772a0e11]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[981f6d45772a0e11]::dep_graph::graph::DepNodeIndex>, false>
23: 0x7f0eb2f7adb7 - rustc_query_impl[dce42a22f9092267]::query_vtables::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
24: 0x7f0eb2f78e63 - <rustc_middle[981f6d45772a0e11]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[ee6c17263c420aba]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
25: 0x7f0eb2f780f6 - rustc_interface[ee6c17263c420aba]::passes::analysis
26: 0x7f0eb3fed987 - rustc_query_impl[dce42a22f9092267]::execution::try_execute_query::<rustc_middle[981f6d45772a0e11]::query::caches::SingleCache<rustc_middle[981f6d45772a0e11]::query::erase::ErasedData<[u8; 0usize]>>, false>
27: 0x7f0eb3fed76b - rustc_query_impl[dce42a22f9092267]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
28: 0x7f0eb40cbc79 - rustc_interface[ee6c17263c420aba]::interface::run_compiler::<(), rustc_driver_impl[fa7a7ce11be7f74c]::compiler_entrypoint::{closure#0}>::{closure#2}
29: 0x7f0eb4185724 - std[2197041a2d5adeae]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ee6c17263c420aba]::util::run_in_thread_with_globals<rustc_interface[ee6c17263c420aba]::util::run_in_thread_pool_with_globals<rustc_interface[ee6c17263c420aba]::interface::run_compiler<(), rustc_driver_impl[fa7a7ce11be7f74c]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
30: 0x7f0eb41854b3 - <std[2197041a2d5adeae]::thread::lifecycle::spawn_unchecked<rustc_interface[ee6c17263c420aba]::util::run_in_thread_with_globals<rustc_interface[ee6c17263c420aba]::util::run_in_thread_pool_with_globals<rustc_interface[ee6c17263c420aba]::interface::run_compiler<(), rustc_driver_impl[fa7a7ce11be7f74c]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b29223e0788b9091]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
31: 0x7f0eb417db2d - <std[2197041a2d5adeae]::sys::thread::unix::Thread>::new::thread_start
32: 0x7f0ead08aaa4 - start_thread
at ./nptl/pthread_create.c:447:8
33: 0x7f0ead117c6c - clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
34: 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.101.0-nightly (b6eeb93c9 2026-10-18) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck_root] type-checking `Array`
#1 [mir_borrowck] borrow-checking `Array::{constant#0}`
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
maxdexh commentedon Oct 19, 2026
Note: The code is supposed to be a compile error because
yis missingmut.cargo-bisect-rustc --start=2025-09-14 --regress=iceyields nightly-2026-02-13 (somewhere between 7057231 and 47611e1)maxdexh commentedon Oct 19, 2026
Maybe #152281?
rustbot commentedon Oct 19, 2026
Assigning P-medium (discussion on Zulip).