ICE expected len of array pat to be definite
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
#![feature(min_generic_const_args)]
#![feature(macroless_const_item_generic_const_args)]
#[derive(Eq, PartialEq)]
struct Data([u8; N]);
const DATA: Data = Data([1, 2, 3, 4]);
fn main() {
match DATA {
DATA | _ => {}
}
}
original:
#![feature(min_generic_const_args)]
#![feature(macroless_const_item_generic_const_args)]
#![feature(min_adt_const_params)]
use std::marker::ConstParamTy;
const N: usize = todo!();
#[derive(Eq, PartialEq, ConstParamTy)]
struct Data([u8; N]);
const DATA: Data = Data([1, 2, 3, 4]);
fn main() {
match DATA {
DATA | _ => {}
}
}
Version information
rustc 1.100.0-nightly (92801ede8 2026-09-16)
binary: rustc
commit-hash: 92801ede88f6c10e34df6976a4cfde40142585f2
commit-date: 2026-09-16
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1
Possibly related line of code:
https://github.com/rust-lang/rust/blob/92801ede88f6c10e34df6976a4cfde40142585f2/compiler/rustc_pattern_analysis/src/rustc.rs#L655-L667
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error[E0425]: cannot find value `N` in this scope
--> /tmp/icemaker_global_tempdir.5yEo0NROFV2x/rustc_testrunner_tmpdir_reporting.UM3VgftQGpdK/mvce.rs:5:18
|
5 | struct Data([u8; N]);
| ^ not found in this scope
|
help: you might be missing a const parameter
|
5 | struct Data<const N: /* Type */>([u8; N]);
| +++++++++++++++++++++
error[E0425]: cannot find value `N` in this scope
--> /tmp/icemaker_global_tempdir.5yEo0NROFV2x/rustc_testrunner_tmpdir_reporting.UM3VgftQGpdK/mvce.rs:5:18
|
5 | struct Data([u8; N]);
| ^ not found in this scope
|
help: you might be missing a const parameter
|
5 | struct Data<const N: /* Type */>([u8; N]);
| +++++++++++++++++++++
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.5yEo0NROFV2x/rustc_testrunner_tmpdir_reporting.UM3VgftQGpdK/mvce.rs:1:12
|
1 | #![feature(min_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `macroless_const_item_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.5yEo0NROFV2x/rustc_testrunner_tmpdir_reporting.UM3VgftQGpdK/mvce.rs:2:12
|
2 | #![feature(macroless_const_item_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #162540 <https://github.com/rust-lang/rust/issues/162540> for more information
error[E0741]: `Data` must implement `ConstParamTy` to be used as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.5yEo0NROFV2x/rustc_testrunner_tmpdir_reporting.UM3VgftQGpdK/mvce.rs:7:13
|
7 | const DATA: Data = Data([1, 2, 3, 4]);
| ^^^^
|
help: add `#[derive(ConstParamTy)]` to the struct
|
5 + #[derive(ConstParamTy)]
6 | struct Data([u8; N]);
|
thread 'rustc' (1836374) panicked at /rustc-dev/92801ede88f6c10e34df6976a4cfde40142585f2/compiler/rustc_pattern_analysis/src/rustc.rs:661:30:
expected len of array pat to be definite
stack backtrace:
0: 0x7f4202681956 - <<std[720dee8f8bfdc813]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[bf8227dabe305445]::fmt::Display>::fmt
1: 0x7f4202e09cd1 - core[bf8227dabe305445]::fmt::write
2: 0x7f420269691c - <std[720dee8f8bfdc813]::sys::stdio::unix::Stderr as core[bf8227dabe305445]::io::write::Write>::write_fmt
3: 0x7f420265445a - std[720dee8f8bfdc813]::panicking::default_hook::{closure#0}
4: 0x7f4202675f03 - std[720dee8f8bfdc813]::panicking::default_hook
5: 0x7f420138509f - std[720dee8f8bfdc813]::panicking::update_hook::<alloc[fc315bf851adfeb5]::boxed::Box<rustc_driver_impl[249e893f59edbaf7]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f42026763a2 - std[720dee8f8bfdc813]::panicking::panic_with_hook
7: 0x7f4202654512 - std[720dee8f8bfdc813]::panicking::panic_handler::{closure#0}
8: 0x7f420264b339 - std[720dee8f8bfdc813]::sys::backtrace::__rust_end_short_backtrace::<std[720dee8f8bfdc813]::panicking::panic_handler::{closure#0}, !>
9: 0x7f42026560ed - __rustc[ea5107eac9713e7a]::rust_begin_unwind
10: 0x7f41ff106c3c - core[bf8227dabe305445]::panicking::panic_fmt
11: 0x7f420002e804 - core[bf8227dabe305445]::option::expect_failed
12: 0x7f41ff8a7a81 - <rustc_pattern_analysis[775ecf7cf9c27cfa]::rustc::RustcPatCtxt>::lower_pat
13: 0x7f41ff8a6b7b - <rustc_pattern_analysis[775ecf7cf9c27cfa]::rustc::RustcPatCtxt>::lower_pat
14: 0x7f41ff8a712d - <rustc_pattern_analysis[775ecf7cf9c27cfa]::rustc::RustcPatCtxt>::lower_pat
15: 0x7f4203fa0ddd - <rustc_mir_build[52c1d15651296a42]::thir::pattern::check_match::MatchVisitor>::check_match
16: 0x7f4202e0d714 - <rustc_mir_build[52c1d15651296a42]::thir::pattern::check_match::MatchVisitor as rustc_middle[249b3c20e033e7b6]::thir::visit::Visitor>::visit_expr
17: 0x7f4202e0d2ec - <rustc_mir_build[52c1d15651296a42]::thir::pattern::check_match::MatchVisitor as rustc_middle[249b3c20e033e7b6]::thir::visit::Visitor>::visit_expr
18: 0x7f4202e0d341 - <rustc_mir_build[52c1d15651296a42]::thir::pattern::check_match::MatchVisitor as rustc_middle[249b3c20e033e7b6]::thir::visit::Visitor>::visit_expr
19: 0x7f4202e0d2ec - <rustc_mir_build[52c1d15651296a42]::thir::pattern::check_match::MatchVisitor as rustc_middle[249b3c20e033e7b6]::thir::visit::Visitor>::visit_expr
20: 0x7f42034af1a5 - rustc_mir_build[52c1d15651296a42]::thir::pattern::check_match::check_match
21: 0x7f42034aeddb - rustc_query_impl[fa11e8f5231da85c]::query_vtables::check_match::invoke_provider_fn::__rust_begin_short_backtrace
22: 0x7f4203bad861 - rustc_query_impl[fa11e8f5231da85c]::execution::try_execute_query::<rustc_data_structures[33f959ba2bf10398]::vec_cache::VecCache<rustc_span[28e02c8c6c40f43e]::def_id::LocalDefId, rustc_middle[249b3c20e033e7b6]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[249b3c20e033e7b6]::dep_graph::graph::DepNodeIndex>, false>
23: 0x7f4203bad5d5 - rustc_query_impl[fa11e8f5231da85c]::query_vtables::check_match::execute_query_non_incr::__rust_end_short_backtrace
24: 0x7f4203777a1f - rustc_mir_build[52c1d15651296a42]::builder::build_mir_inner_impl
25: 0x7f4202e2432a - rustc_mir_transform[43fbec4f37f8ce5b]::mir_built
26: 0x7f42034b3f75 - rustc_query_impl[fa11e8f5231da85c]::execution::try_execute_query::<rustc_data_structures[33f959ba2bf10398]::vec_cache::VecCache<rustc_span[28e02c8c6c40f43e]::def_id::LocalDefId, rustc_middle[249b3c20e033e7b6]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[249b3c20e033e7b6]::dep_graph::graph::DepNodeIndex>, false>
27: 0x7f42034b3c67 - rustc_query_impl[fa11e8f5231da85c]::query_vtables::mir_built::execute_query_non_incr::__rust_end_short_backtrace
28: 0x7f42034a1b86 - rustc_mir_build[52c1d15651296a42]::check_unsafety::check_unsafety
29: 0x7f42034b7b1e - rustc_query_impl[fa11e8f5231da85c]::execution::try_execute_query::<rustc_data_structures[33f959ba2bf10398]::vec_cache::VecCache<rustc_span[28e02c8c6c40f43e]::def_id::LocalDefId, rustc_middle[249b3c20e033e7b6]::query::erase::ErasedData<[u8; 0usize]>, rustc_middle[249b3c20e033e7b6]::dep_graph::graph::DepNodeIndex>, false>
30: 0x7f42034b7895 - rustc_query_impl[fa11e8f5231da85c]::query_vtables::check_unsafety::execute_query_non_incr::__rust_end_short_backtrace
31: 0x7f42034b6693 - <rustc_middle[249b3c20e033e7b6]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[758637dfb6969226]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
32: 0x7f42034b5a94 - rustc_interface[758637dfb6969226]::passes::analysis
33: 0x7f42040029ca - rustc_query_impl[fa11e8f5231da85c]::execution::try_execute_query::<rustc_middle[249b3c20e033e7b6]::query::caches::SingleCache<rustc_middle[249b3c20e033e7b6]::query::erase::ErasedData<[u8; 0usize]>>, false>
34: 0x7f42040027ab - rustc_query_impl[fa11e8f5231da85c]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
35: 0x7f42040f93af - rustc_interface[758637dfb6969226]::interface::run_compiler::<(), rustc_driver_impl[249e893f59edbaf7]::run_compiler::{closure#0}>::{closure#2}
36: 0x7f4204171402 - std[720dee8f8bfdc813]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[758637dfb6969226]::util::run_in_thread_with_globals<rustc_interface[758637dfb6969226]::util::run_in_thread_pool_with_globals<rustc_interface[758637dfb6969226]::interface::run_compiler<(), rustc_driver_impl[249e893f59edbaf7]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
37: 0x7f42041711ad - <std[720dee8f8bfdc813]::thread::lifecycle::spawn_unchecked<rustc_interface[758637dfb6969226]::util::run_in_thread_with_globals<rustc_interface[758637dfb6969226]::util::run_in_thread_pool_with_globals<rustc_interface[758637dfb6969226]::interface::run_compiler<(), rustc_driver_impl[249e893f59edbaf7]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[bf8227dabe305445]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
38: 0x7f420417bee1 - <std[720dee8f8bfdc813]::sys::thread::unix::Thread>::new::thread_start
39: 0x7f41fce980a2 - <unknown>
40: 0x7f41fcf2080c - <unknown>
41: 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.100.0-nightly (92801ede8 2026-09-16) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [check_match] match-checking `main`
#1 [mir_built] building MIR for `main`
#2 [check_unsafety] unsafety-checking `main`
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors; 2 warnings emitted
Some errors have detailed explanations: E0425, E0741.
For more information about an error, try `rustc --explain E0425`.
@rustbot label +F-min_generic_const_args +F-min_adt_const_params
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the minimized a.rs reproducer with the nightly toolchain and inspect compiler/rustc_pattern_analysis/src/rustc.rs around lines 655-667, especially the lower_pat path that expects an array-pattern length to be definite. Confirm the panic and trace how the match-checking query reaches it. Done means the reproducer no longer triggers an ICE and a regression test covers this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100