Closed
Description
auto-reduced (treereduce-rust):
#![feature(min_generic_const_args)]
pub trait Tr<A> {
const SIZE: usize;
}
fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
original:
//@ check-pass
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
pub trait Tr<A> {
#[type_const]
const SIZE: usize;
}
fn mk_array<T: Tr<{ Tr::N }>>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {
[(); T::SIZE]
}
fn main() {}
Version information
rustc 1.88.0-nightly (62c5f58f5 2025-05-04)
binary: rustc
commit-hash: 62c5f58f57670ce65e7fec34f8c4ba00c27da2d9
commit-date: 2025-05-04
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.4
Possibly related line of code:
rust/compiler/rustc_middle/src/ty/mod.rs
Lines 602 to 614 in 62c5f58
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2 -Clink-dead-code=true -Zvalidate-mir --edition=2024
Program output
error[E0412]: cannot find type `T` in this scope
--> /tmp/icemaker_global_tempdir.Oua5GnodnFsV/rustc_testrunner_tmpdir_reporting.oxonLTTvXSSr/mvce.rs:7:17
|
3 | pub trait Tr<A> {
| --------------- similarly named trait `Tr` defined here
...
7 | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| ^
|
help: a trait with a similar name exists
|
7 | fn mk_array(_x: Tr) -> [(); <T as Tr<bool>>::SIZE] {}
| +
help: you might be missing a type parameter
|
7 | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| +++
error[E0412]: cannot find type `T` in this scope
--> /tmp/icemaker_global_tempdir.Oua5GnodnFsV/rustc_testrunner_tmpdir_reporting.oxonLTTvXSSr/mvce.rs:7:29
|
3 | pub trait Tr<A> {
| --------------- similarly named trait `Tr` defined here
...
7 | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| ^
|
help: a trait with a similar name exists
|
7 | fn mk_array(_x: T) -> [(); <Tr as Tr<bool>>::SIZE] {}
| +
help: you might be missing a type parameter
|
7 | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| +++
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.Oua5GnodnFsV/rustc_testrunner_tmpdir_reporting.oxonLTTvXSSr/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
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.Oua5GnodnFsV/rustc_testrunner_tmpdir_reporting.oxonLTTvXSSr/mvce.rs:7:53
|
7 | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Oua5GnodnFsV/rustc_testrunner_tmpdir_reporting.oxonLTTvXSSr/mvce.rs`
thread 'rustc' panicked at compiler/rustc_middle/src/ty/mod.rs:608:25:
expected a const, but found a type
stack backtrace:
0: 0x7324f2712223 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6b332601350bb5c6
1: 0x7324f2e059c7 - core::fmt::write::hb5fe01a95abc29e1
2: 0x7324f3e98f91 - std::io::Write::write_fmt::h1a9a2af5dd87e4f4
3: 0x7324f2712082 - std::sys::backtrace::BacktraceLock::print::hac93dfc7377e4e4f
4: 0x7324f2715eca - std::panicking::default_hook::{{closure}}::h18accd01c87ea8a4
5: 0x7324f2715a4f - std::panicking::default_hook::h6459f689707c1046
6: 0x7324f175ea33 - std[e3983e566f061714]::panicking::update_hook::<alloc[b6e091bb297dae1f]::boxed::Box<rustc_driver_impl[5d6200e4aea60082]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7324f2716743 - std::panicking::rust_panic_with_hook::h70d11df0afe220d6
8: 0x7324f271643a - std::panicking::begin_panic_handler::{{closure}}::h2419c2a21ca71abf
9: 0x7324f27126e9 - std::sys::backtrace::__rust_end_short_backtrace::hbf27e53c84a7889f
10: 0x7324f27160fd - __rustc[69bf9ee49405c344]::rust_begin_unwind
11: 0x7324ef07abe0 - core::panicking::panic_fmt::h20040fc1a566cc6e
12: 0x7324f041d76b - core::option::expect_failed::h21ba9be59cf7b568
13: 0x7324f1df8dac - <rustc_middle[6b8e0ac128082c0d]::ty::Term>::expect_const
14: 0x7324f39c0bc2 - <rustc_trait_selection[75470f24c5ad7214]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[6c8d148d64442fb8]::fold::TypeFolder<rustc_middle[6b8e0ac128082c0d]::ty::context::TyCtxt>>::fold_const
15: 0x7324f2fbe1d1 - <rustc_middle[6b8e0ac128082c0d]::ty::Ty as rustc_type_ir[6c8d148d64442fb8]::fold::TypeSuperFoldable<rustc_middle[6b8e0ac128082c0d]::ty::context::TyCtxt>>::super_fold_with::<rustc_trait_selection[75470f24c5ad7214]::traits::normalize::AssocTypeNormalizer>
16: 0x7324f33e822e - <rustc_hir_analysis[aac2cbd98712a32f]::check::wfcheck::WfCheckingCtxt>::normalize::<rustc_middle[6b8e0ac128082c0d]::ty::Ty>
17: 0x7324f33f850e - rustc_hir_analysis[aac2cbd98712a32f]::check::wfcheck::check_fn_or_method
18: 0x7324f33e9879 - rustc_hir_analysis[aac2cbd98712a32f]::check::wfcheck::check_item_fn
19: 0x7324f36a4091 - rustc_hir_analysis[aac2cbd98712a32f]::check::wfcheck::check_well_formed
20: 0x7324f36a21e5 - rustc_query_impl[bb33f36fe50a9360]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bb33f36fe50a9360]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6b8e0ac128082c0d]::query::erase::Erased<[u8; 1usize]>>
21: 0x7324f3136c77 - rustc_query_system[54ce3036e317418]::query::plumbing::try_execute_query::<rustc_query_impl[bb33f36fe50a9360]::DynamicConfig<rustc_data_structures[79c7d893e4c18eef]::vec_cache::VecCache<rustc_span[79c1c5c8104510f4]::def_id::LocalDefId, rustc_middle[6b8e0ac128082c0d]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[54ce3036e317418]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[bb33f36fe50a9360]::plumbing::QueryCtxt, true>
22: 0x7324f313642f - rustc_query_impl[bb33f36fe50a9360]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
23: 0x7324f369e7e5 - rustc_hir_analysis[aac2cbd98712a32f]::check::wfcheck::check_mod_type_wf
24: 0x7324f369e5df - rustc_query_impl[bb33f36fe50a9360]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bb33f36fe50a9360]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6b8e0ac128082c0d]::query::erase::Erased<[u8; 1usize]>>
25: 0x7324f3da8bd5 - rustc_query_system[54ce3036e317418]::query::plumbing::try_execute_query::<rustc_query_impl[bb33f36fe50a9360]::DynamicConfig<rustc_query_system[54ce3036e317418]::query::caches::DefaultCache<rustc_span[79c1c5c8104510f4]::def_id::LocalModDefId, rustc_middle[6b8e0ac128082c0d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[bb33f36fe50a9360]::plumbing::QueryCtxt, true>
26: 0x7324f3da96ba - rustc_query_impl[bb33f36fe50a9360]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
27: 0x7324f30de972 - rustc_hir_analysis[aac2cbd98712a32f]::check_crate
28: 0x7324f312635f - rustc_interface[25c3c47d512a17f3]::passes::run_required_analyses
29: 0x7324f3d9df9e - rustc_interface[25c3c47d512a17f3]::passes::analysis
30: 0x7324f3d9df6d - rustc_query_impl[bb33f36fe50a9360]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bb33f36fe50a9360]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6b8e0ac128082c0d]::query::erase::Erased<[u8; 0usize]>>
31: 0x7324f3d9a9c0 - rustc_query_system[54ce3036e317418]::query::plumbing::try_execute_query::<rustc_query_impl[bb33f36fe50a9360]::DynamicConfig<rustc_query_system[54ce3036e317418]::query::caches::SingleCache<rustc_middle[6b8e0ac128082c0d]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[bb33f36fe50a9360]::plumbing::QueryCtxt, true>
32: 0x7324f3d9a3f5 - rustc_query_impl[bb33f36fe50a9360]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
33: 0x7324f3d1e0be - rustc_interface[25c3c47d512a17f3]::passes::create_and_enter_global_ctxt::<core[7fd0d062384da063]::option::Option<rustc_interface[25c3c47d512a17f3]::queries::Linker>, rustc_driver_impl[5d6200e4aea60082]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
34: 0x7324f3e6c7dc - rustc_interface[25c3c47d512a17f3]::interface::run_compiler::<(), rustc_driver_impl[5d6200e4aea60082]::run_compiler::{closure#0}>::{closure#1}
35: 0x7324f3e8fa3e - std[e3983e566f061714]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[25c3c47d512a17f3]::util::run_in_thread_with_globals<rustc_interface[25c3c47d512a17f3]::util::run_in_thread_pool_with_globals<rustc_interface[25c3c47d512a17f3]::interface::run_compiler<(), rustc_driver_impl[5d6200e4aea60082]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
36: 0x7324f3e8feb4 - <<std[e3983e566f061714]::thread::Builder>::spawn_unchecked_<rustc_interface[25c3c47d512a17f3]::util::run_in_thread_with_globals<rustc_interface[25c3c47d512a17f3]::util::run_in_thread_pool_with_globals<rustc_interface[25c3c47d512a17f3]::interface::run_compiler<(), rustc_driver_impl[5d6200e4aea60082]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7fd0d062384da063]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
37: 0x7324f3e912ab - std::sys::pal::unix::thread::Thread::new::thread_start::h18c419b796c40416
38: 0x7324edc9e70a - <unknown>
39: 0x7324edd22aac - <unknown>
40: 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.88.0-nightly (62c5f58f5 2025-05-04) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir
query stack during panic:
#0 [check_well_formed] checking that `mk_array` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted
Some errors have detailed explanations: E0412, E0601.
For more information about an error, try `rustc --explain E0412`.
@rustbot label +F-min_generic_const_args +-Zvalidate-mir
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Category: This is a bug.`#![feature(min_generic_const_args)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: A bisection has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.