Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE:expected const for N/#0 (N/#0/0) but found Type(A<N/#0>) when instantiating args=[A<N/#0>] #138226

Open
sososopy opened this issue Mar 8, 2025 · 0 comments
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` F-min_generic_const_args `#![feature(min_generic_const_args)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sososopy
Copy link

sososopy commented Mar 8, 2025

Code

#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
struct A<const N: usize>;
impl<const N: usize> A<N> {
    const FOUR: usize = 4;
    fn test() {
        let _ = [0; Self::FOUR];
    }
}
fn main() {}

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (f5a1ef712 2025-03-07)
binary: rustc
commit-hash: f5a1ef7121ad661b5a21a1d02941c8064d54ee0b
commit-date: 2025-03-07
host: x86_64-pc-windows-msvc
release: 1.87.0-nightly
LLVM version: 20.1.0

Error output

<output>
Backtrace

thread 'rustc' panicked at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b\compiler\rustc_type_ir\src\binder.rs:763:9:
expected const for `N/#0` (N/#0/0) but found Type(A<N/#0>) when instantiating args=[A<N/#0>]
stack backtrace:
   0:     0x7ff835466c63 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ff835466c63 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff835466c63 - std::sys::backtrace::_print_fmt
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\sys\backtrace.rs:66
   3:     0x7ff835466c63 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\sys\backtrace.rs:39
   4:     0x7ff83549a02a - core::fmt::rt::Argument::fmt
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\core\src\fmt\rt.rs:177
   5:     0x7ff83549a02a - core::fmt::write
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\core\src\fmt\mod.rs:1449
   6:     0x7ff83545c9d7 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\io\mod.rs:1890
   7:     0x7ff835466aa5 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\sys\backtrace.rs:42
   8:     0x7ff83546ae19 - std::panicking::default_hook::closure$0
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\panicking.rs:298
   9:     0x7ff83546ac08 - std::panicking::default_hook
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\panicking.rs:325
  10:     0x7ff8369ff347 - core[a49717954fd349d5]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[c763add0498415dc]::Level, &str), usize), <((rustc_lint_defs[c763add0498415dc]::Level, &str), usize) as core[a49717954fd349d5]::cmp::PartialOrd>::lt>
  11:     0x7ff83546baae - std::panicking::rust_panic_with_hook
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\panicking.rs:839
  12:     0x7ff83546b809 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\panicking.rs:704
  13:     0x7ff83546775f - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\sys\backtrace.rs:168
  14:     0x7ff83546b40e - std::panicking::begin_panic_handler
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\panicking.rs:695
  15:     0x7ff8382c8bf1 - core::panicking::panic_fmt
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\core\src\panicking.rs:75
  16:     0x7ff837f85b4a - <rustc_type_ir[589600bd6aed6b9b]::binder::ArgFolder<rustc_middle[a635f052194163b9]::ty::context::TyCtxt>>::const_param_expected
  17:     0x7ff8352ba80d - <alloc[fd90ba3301162542]::sync::Arc<rustc_query_system[711562fb18ebc613]::dep_graph::serialized::SerializedDepGraph>>::drop_slow
  18:     0x7ff8368fd339 - <rustc_middle[a635f052194163b9]::ty::context::TyCtxt>::mk_bound_variable_kinds
  19:     0x7ff8368fc62a - <rustc_middle[a635f052194163b9]::ty::context::TyCtxt>::mk_bound_variable_kinds
  20:     0x7ff83689b10f - <rustc_middle[a635f052194163b9]::ty::generics::GenericPredicates>::instantiate
  21:     0x7ff83640c80f - rustc_trait_selection[70257543d9e64c63]::traits::wf::clause_obligations
  22:     0x7ff836358614 - <rustc_trait_selection[70257543d9e64c63]::traits::wf::WfPredicates as rustc_type_ir[589600bd6aed6b9b]::visit::TypeVisitor<rustc_middle[a635f052194163b9]::ty::context::TyCtxt>>::visit_const
  23:     0x7ff8363641c1 - <rustc_trait_selection[70257543d9e64c63]::traits::fulfill::FulfillProcessor as rustc_data_structures[b8e807b0329c5e35]::obligation_forest::ObligationProcessor>::process_obligation
  24:     0x7ff8362c8f8b - <rustc_data_structures[b8e807b0329c5e35]::obligation_forest::ObligationForest<rustc_trait_selection[70257543d9e64c63]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[70257543d9e64c63]::traits::fulfill::FulfillProcessor>
  25:     0x7ff8356e93c1 - rustc_hir_typeck[5dfdb3193f74140]::typeck
  26:     0x7ff835609d47 - <<rustc_hir_typeck[5dfdb3193f74140]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[589600bd6aed6b9b]::visit::TypeVisitor<rustc_middle[a635f052194163b9]::ty::context::TyCtxt>>::visit_ty
  27:     0x7ff835611839 - <<rustc_hir_typeck[5dfdb3193f74140]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[589600bd6aed6b9b]::visit::TypeVisitor<rustc_middle[a635f052194163b9]::ty::context::TyCtxt>>::visit_ty
  28:     0x7ff83566ae0c - <<rustc_hir_typeck[5dfdb3193f74140]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[589600bd6aed6b9b]::visit::TypeVisitor<rustc_middle[a635f052194163b9]::ty::context::TyCtxt>>::visit_ty
  29:     0x7ff83566cbb9 - <<rustc_hir_typeck[5dfdb3193f74140]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[589600bd6aed6b9b]::visit::TypeVisitor<rustc_middle[a635f052194163b9]::ty::context::TyCtxt>>::visit_ty
  30:     0x7ff83560bdfd - <<rustc_hir_typeck[5dfdb3193f74140]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[589600bd6aed6b9b]::visit::TypeVisitor<rustc_middle[a635f052194163b9]::ty::context::TyCtxt>>::visit_ty
  31:     0x7ff8356c6a08 - rustc_hir_typeck[5dfdb3193f74140]::typeck
  32:     0x7ff83570cdcd - <rustc_hir_typeck[5dfdb3193f74140]::upvar::InferBorrowKind as rustc_hir_typeck[5dfdb3193f74140]::expr_use_visitor::Delegate>::borrow
  33:     0x7ff8356bfbbf - rustc_hir_typeck[5dfdb3193f74140]::typeck
  34:     0x7ff83620ce7b - rustc_query_impl[b69aee932fe91357]::plumbing::query_key_hash_verify_all
  35:     0x7ff836156051 - RINvNtNtCs9HWllMiJxcJ_18rustc_query_system5query8plumbing17try_execute_queryINtCsfG0cl2i4BMx_16rustc_query_impl13DynamicConfigINtNtCsfSfDFhv6ONJ_21rustc_data_structures9vec_cache8VecCacheNtNtCsc9bkXepKnRD_10rustc_span6def_id10LocalDefIdINtNtNtCsegJBPcicXKD
  36:     0x7ff836215133 - rustc_query_impl[b69aee932fe91357]::plumbing::query_key_hash_verify_all
  37:     0x7ff835733944 - RINvMs6_NtCs86fv54unOYr_9hashbrown3rawINtB6_8RawTablejE14reserve_rehashNCINvNtNtCsfxNsec2025j_8indexmap3map4core8get_hashTNtNtNtCsegJBPcicXKD_12rustc_middle2ty9predicate6ClauseNtNtCsc9bkXepKnRD_10rustc_span13span_encoding4SpanEuE0ECs6deNT1wm63v_18rustc_hir
  38:     0x7ff8357baf71 - rustc_hir_analysis[485f70a961e5d363]::check_crate
  39:     0x7ff8354e346f - rustc_interface[ee21df1734f8ab0f]::passes::resolver_for_lowering_raw
  40:     0x7ff831e48479 - rustc_interface[ee21df1734f8ab0f]::passes::analysis
  41:     0x7ff834fe6baa - <alloc[fd90ba3301162542]::sync::Arc<rustc_session[8146d5d0b944a82b]::config::OutputFilenames>>::drop_slow
  42:     0x7ff834ef46a4 - RINvNtNtCs9HWllMiJxcJ_18rustc_query_system5query8plumbing17try_execute_queryINtCsfG0cl2i4BMx_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCsegJBPcicXKD_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  43:     0x7ff834fec6a4 - rustc_query_impl[b69aee932fe91357]::query_system
  44:     0x7ff831e0dcd2 - RINvNtNtCsiw7LomwTgZ5_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCslLIMKTelctO_5alloc5boxed3BoxDINtNtNtCse86O2quqQfh_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsbsz
  45:     0x7ff831e06264 - RINvNtNtCsiw7LomwTgZ5_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCslLIMKTelctO_5alloc5boxed3BoxDINtNtNtCse86O2quqQfh_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsbsz
  46:     0x7ff831dfef03 - RINvNtNtCsiw7LomwTgZ5_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCskrzvsuieKkd_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCsbsz2LbB1MIu_17rustc_driver_i
  47:     0x7ff831e12ed0 - RINvNtNtCsiw7LomwTgZ5_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCslLIMKTelctO_5alloc5boxed3BoxDINtNtNtCse86O2quqQfh_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsbsz
  48:     0x7ff83547c23d - alloc::boxed::impl$28::call_once
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\alloc\src\boxed.rs:1970
  49:     0x7ff83547c23d - alloc::boxed::impl$28::call_once
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\alloc\src\boxed.rs:1970
  50:     0x7ff83547c23d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/f5a1ef7121ad661b5a21a1d02941c8064d54ee0b/library\std\src\sys\pal\windows\thread.rs:56
  51:     0x7ff8f6c87374 - BaseThreadInitThunk
  52:     0x7ff8f777cc91 - RtlUserThreadStart

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: please attach the file at `D:\rust_test\test1\src\rustc-ice-2025-03-08T13_23_09-24280.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `<impl at .\ttt\test.rs:126:1: 126:26>::test`
#1 [analysis] running analysis passes on this crate
end of query stack

@sososopy sososopy added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 8, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 8, 2025
@jieyouxu jieyouxu added F-inherent_associated_types `#![feature(inherent_associated_types)]` F-min_generic_const_args `#![feature(min_generic_const_args)]` labels Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` F-min_generic_const_args `#![feature(min_generic_const_args)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants