Skip to content

ICE on typeof(CT_PARAM) due to incorrect generic param substitution / instantiation somewhere #146384

@brutalsavage

Description

@brutalsavage

Code

#![feature(generic_const_exprs)] const fn make_tuple<const N: usize>() -> (u8::N) { } type TupleConst<const N: usize> = typeof(make_tuple::<N>());

Meta

rustc --version --verbose:

rustc 1.91.0-nightly (9c27f27ea 2025-09-08) binary: rustc commit-hash: 9c27f27ea3bab79a2fec827ef3ae0009959d60f4 commit-date: 2025-09-08 host: x86_64-unknown-linux-gnu release: 1.91.0-nightly LLVM version: 21.1.0 

Error output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> test.fuzz:1:12 | 1 | #![feature(generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = note: `#[warn(incomplete_features)]` on by default warning: unnecessary parentheses around type --> test.fuzz:3:42 | 3 | const fn make_tuple<const N: usize>() -> (u8::N) { | ^ ^ | = note: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default help: remove these parentheses | 3 - const fn make_tuple<const N: usize>() -> (u8::N) { 3 + const fn make_tuple<const N: usize>() -> u8::N { | error[E0601]: `main` function not found in crate `test` --> test.fuzz:5:61 | 5 | type TupleConst<const N: usize> = typeof(make_tuple::<N>()); | ^ consider adding a `main` function to `test.fuzz` error[E0223]: ambiguous associated type --> test.fuzz:3:43 | 3 | const fn make_tuple<const N: usize>() -> (u8::N) { | ^^^^^ | help: if there were a trait named `Example` with associated type `N` implemented for `u8`, you could use the fully-qualified path | 3 - const fn make_tuple<const N: usize>() -> (u8::N) { 3 + const fn make_tuple<const N: usize>() -> (<u8 as Example>::N) { | error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:372:13: cannot find `N/#0` in param-env: ParamEnv { caller_bounds: [], } thread 'rustc' (3869642) panicked at compiler/rustc_middle/src/ty/sty.rs:372:13: Box<dyn Any> 
Backtrace

stack backtrace: 0: 0x7fca785afec3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf30880b118ce69a7 1: 0x7fca78c01bd8 - core::fmt::write::h2adee94c9530c769 2: 0x7fca78564cf1 - std::io::Write::write_fmt::hf9fd682cd305994d 3: 0x7fca78575e12 - std::sys::backtrace::BacktraceLock::print::h2e8eaa47e6244167 4: 0x7fca7857bd59 - std::panicking::default_hook::{{closure}}::hce66ca19674736b6 5: 0x7fca7857b883 - std::panicking::default_hook::h378eb22e7f245ba6 6: 0x7fca775c3707 - std[60f4c921464387a8]::panicking::update_hook::<alloc[af66c0f7f367d3a4]::boxed::Box<rustc_driver_impl[6e5208ea2b150886]::install_ice_hook::{closure#1}>>::{closure#0} 7: 0x7fca7857c17f - std::panicking::panic_with_hook::h107561c887d41fb4 8: 0x7fca775ffdc1 - std[60f4c921464387a8]::panicking::begin_panic::<rustc_errors[a4bc384b506279c9]::ExplicitBug>::{closure#0} 9: 0x7fca775f37a6 - std[60f4c921464387a8]::sys::backtrace::__rust_end_short_backtrace::<std[60f4c921464387a8]::panicking::begin_panic<rustc_errors[a4bc384b506279c9]::ExplicitBug>::{closure#0}, !> 10: 0x7fca775f3435 - std[60f4c921464387a8]::panicking::begin_panic::<rustc_errors[a4bc384b506279c9]::ExplicitBug> 11: 0x7fca7760b551 - <rustc_errors[a4bc384b506279c9]::diagnostic::BugAbort as rustc_errors[a4bc384b506279c9]::diagnostic::EmissionGuarantee>::emit_producing_guarantee 12: 0x7fca77ba508a - rustc_middle[62f76fb1ad15f043]::util::bug::opt_span_bug_fmt::<rustc_span[84d5e499882068e4]::span_encoding::Span>::{closure#0} 13: 0x7fca77ba524a - rustc_middle[62f76fb1ad15f043]::ty::context::tls::with_opt::<rustc_middle[62f76fb1ad15f043]::util::bug::opt_span_bug_fmt<rustc_span[84d5e499882068e4]::span_encoding::Span>::{closure#0}, !>::{closure#0} 14: 0x7fca77b93e1b - rustc_middle[62f76fb1ad15f043]::ty::context::tls::with_context_opt::<rustc_middle[62f76fb1ad15f043]::ty::context::tls::with_opt<rustc_middle[62f76fb1ad15f043]::util::bug::opt_span_bug_fmt<rustc_span[84d5e499882068e4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !> 15: 0x7fca74cc2560 - rustc_middle[62f76fb1ad15f043]::util::bug::bug_fmt 16: 0x7fca794dd78b - <rustc_trait_selection[15dd98a8352583f4]::traits::fulfill::FulfillProcessor as rustc_data_structures[d45417cb7c5e80c2]::obligation_forest::ObligationProcessor>::process_obligation 17: 0x7fca78c04e49 - <rustc_data_structures[d45417cb7c5e80c2]::obligation_forest::ObligationForest<rustc_trait_selection[15dd98a8352583f4]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[15dd98a8352583f4]::traits::fulfill::FulfillProcessor> 18: 0x7fca7925dd4b - <rustc_hir_typeck[4caaa11dff9d1644]::fn_ctxt::FnCtxt>::check_expr_call 19: 0x7fca792873e7 - <rustc_hir_typeck[4caaa11dff9d1644]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args 20: 0x7fca79117a91 - rustc_hir_typeck[4caaa11dff9d1644]::typeck_with_inspect::{closure#0} 21: 0x7fca79112836 - rustc_query_impl[d503ea7333d9f192]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d503ea7333d9f192]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 8usize]>> 22: 0x7fca78e2f345 - rustc_query_system[36926af04fc30fbf]::query::plumbing::try_execute_query::<rustc_query_impl[d503ea7333d9f192]::DynamicConfig<rustc_data_structures[d45417cb7c5e80c2]::vec_cache::VecCache<rustc_span[84d5e499882068e4]::def_id::LocalDefId, rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[36926af04fc30fbf]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[d503ea7333d9f192]::plumbing::QueryCtxt, false> 23: 0x7fca78e2ed89 - rustc_query_impl[d503ea7333d9f192]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace 24: 0x7fca78e18582 - rustc_hir_analysis[84a042027edab4a]::collect::type_of::type_of 25: 0x7fca78c1c7e6 - rustc_query_impl[d503ea7333d9f192]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d503ea7333d9f192]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 8usize]>> 26: 0x7fca78c1b479 - rustc_query_system[36926af04fc30fbf]::query::plumbing::try_execute_query::<rustc_query_impl[d503ea7333d9f192]::DynamicConfig<rustc_query_system[36926af04fc30fbf]::query::caches::DefIdCache<rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d503ea7333d9f192]::plumbing::QueryCtxt, false> 27: 0x7fca78c1b01d - rustc_query_impl[d503ea7333d9f192]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace 28: 0x7fca7963bdcc - <dyn rustc_hir_analysis[84a042027edab4a]::hir_ty_lowering::HirTyLowerer>::lower_ty::{closure#0} 29: 0x7fca78e16a28 - rustc_hir_analysis[84a042027edab4a]::collect::type_of::type_of 30: 0x7fca78c1c7e6 - rustc_query_impl[d503ea7333d9f192]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d503ea7333d9f192]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 8usize]>> 31: 0x7fca78c1b479 - rustc_query_system[36926af04fc30fbf]::query::plumbing::try_execute_query::<rustc_query_impl[d503ea7333d9f192]::DynamicConfig<rustc_query_system[36926af04fc30fbf]::query::caches::DefIdCache<rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d503ea7333d9f192]::plumbing::QueryCtxt, false> 32: 0x7fca78c1b01d - rustc_query_impl[d503ea7333d9f192]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace 33: 0x7fca79613973 - rustc_hir_analysis[84a042027edab4a]::check::check::check_item_type 34: 0x7fca7960bc27 - rustc_hir_analysis[84a042027edab4a]::check::wfcheck::check_well_formed 35: 0x7fca7960bc09 - rustc_query_impl[d503ea7333d9f192]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d503ea7333d9f192]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 1usize]>> 36: 0x7fca7960b449 - rustc_query_system[36926af04fc30fbf]::query::plumbing::try_execute_query::<rustc_query_impl[d503ea7333d9f192]::DynamicConfig<rustc_data_structures[d45417cb7c5e80c2]::vec_cache::VecCache<rustc_span[84d5e499882068e4]::def_id::LocalDefId, rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[36926af04fc30fbf]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[d503ea7333d9f192]::plumbing::QueryCtxt, false> 37: 0x7fca7960af56 - rustc_query_impl[d503ea7333d9f192]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace 38: 0x7fca79607075 - rustc_hir_analysis[84a042027edab4a]::check::wfcheck::check_type_wf 39: 0x7fca79606f65 - rustc_query_impl[d503ea7333d9f192]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d503ea7333d9f192]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 1usize]>> 40: 0x7fca79c09048 - rustc_query_system[36926af04fc30fbf]::query::plumbing::try_execute_query::<rustc_query_impl[d503ea7333d9f192]::DynamicConfig<rustc_query_system[36926af04fc30fbf]::query::caches::SingleCache<rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d503ea7333d9f192]::plumbing::QueryCtxt, false> 41: 0x7fca79c08e0e - rustc_query_impl[d503ea7333d9f192]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace 42: 0x7fca78e3a539 - rustc_hir_analysis[84a042027edab4a]::check_crate 43: 0x7fca78e272f0 - rustc_interface[f234d5aad18497a0]::passes::analysis 44: 0x7fca78e26fa1 - rustc_query_impl[d503ea7333d9f192]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d503ea7333d9f192]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 0usize]>> 45: 0x7fca79c0f526 - rustc_query_system[36926af04fc30fbf]::query::plumbing::try_execute_query::<rustc_query_impl[d503ea7333d9f192]::DynamicConfig<rustc_query_system[36926af04fc30fbf]::query::caches::SingleCache<rustc_middle[62f76fb1ad15f043]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[d503ea7333d9f192]::plumbing::QueryCtxt, false> 46: 0x7fca79c0f17c - rustc_query_impl[d503ea7333d9f192]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 47: 0x7fca79ed35a4 - rustc_interface[f234d5aad18497a0]::passes::create_and_enter_global_ctxt::<core[494a681d6e07a62e]::option::Option<rustc_interface[f234d5aad18497a0]::queries::Linker>, rustc_driver_impl[6e5208ea2b150886]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0} 48: 0x7fca79e734be - rustc_interface[f234d5aad18497a0]::interface::run_compiler::<(), rustc_driver_impl[6e5208ea2b150886]::run_compiler::{closure#0}>::{closure#1} 49: 0x7fca79db3c78 - std[60f4c921464387a8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f234d5aad18497a0]::util::run_in_thread_with_globals<rustc_interface[f234d5aad18497a0]::util::run_in_thread_pool_with_globals<rustc_interface[f234d5aad18497a0]::interface::run_compiler<(), rustc_driver_impl[6e5208ea2b150886]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()> 50: 0x7fca79db395c - <<std[60f4c921464387a8]::thread::Builder>::spawn_unchecked_<rustc_interface[f234d5aad18497a0]::util::run_in_thread_with_globals<rustc_interface[f234d5aad18497a0]::util::run_in_thread_pool_with_globals<rustc_interface[f234d5aad18497a0]::interface::run_compiler<(), rustc_driver_impl[6e5208ea2b150886]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[494a681d6e07a62e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 51: 0x7fca79db9e8d - std::sys::pal::unix::thread::Thread::new::thread_start::h0ed16f40fa4b751a 52: 0x7fca7386bac3 - start_thread at ./nptl/pthread_create.c:442:8 53: 0x7fca738fd850 - __GI___clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81:0 54: 0x0 - <unknown> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`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.requires-incomplete-featuresThis issue requires the use of incomplete features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions