Skip to content

ICE:None in compiler\rustc_middle\src\ty\sty.rs #142709

Open
@sososopy

Description

@sososopy

The code is generated by a fuzzer and reduced manually
Possibly duplicated with #129882 or #128525 (but with different query stacks)

Code

#![feature(generic_const_exprs)]
struct X<
    const FN: fn() = {
        || {
            let _: fn([A; B]) -> B = B::B;
        }
    },  
>;
fn main() {}

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (c68340350 2025-06-18)
binary: rustc
commit-hash: c68340350c78eea402c4a85f8d9c1b7d3d607635
commit-date: 2025-06-18
host: x86_64-pc-windows-msvc
release: 1.89.0-nightly
LLVM version: 20.1.7

Error output

error[E0412]: cannot find type `A` in this scope
 --> .\test.rs:5:24
  |
5 |             let _: fn([A; B]) -> B = B::B;
  |                        ^ not found in this scope

error[E0425]: cannot find value `B` in this scope
 --> .\test.rs:5:27
  |
5 |             let _: fn([A; B]) -> B = B::B;
  |                           ^ not found in this scope

error[E0412]: cannot find type `B` in this scope
 --> .\test.rs:5:34
  |
5 |             let _: fn([A; B]) -> B = B::B;
  |                                  ^ not found in this scope

error[E0433]: failed to resolve: use of undeclared type `B`
 --> .\test.rs:5:38
  |
5 |             let _: fn([A; B]) -> B = B::B;
  |                                      ^ use of undeclared type `B`
Backtrace

thread 'rustc' panicked at compiler\rustc_middle\src\ty\sty.rs:365:36:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7fff7ce1b5d2 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7fff7ce1b5d2 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7fff7ce1b5d2 - std::sys::backtrace::_print_fmt
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\sys\backtrace.rs:66
   3:     0x7fff7ce1b5d2 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\sys\backtrace.rs:39
   4:     0x7fff7ce4e32b - core::fmt::rt::Argument::fmt
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\core\src\fmt\rt.rs:173
   5:     0x7fff7ce4e32b - core::fmt::write
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\core\src\fmt\mod.rs:1460
   6:     0x7fff7ce111b7 - std::io::default_write_fmt
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\io\mod.rs:639
   7:     0x7fff7ce111b7 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\io\mod.rs:1954
   8:     0x7fff7ce1b415 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\sys\backtrace.rs:42
   9:     0x7fff7ce211fa - std::panicking::default_hook::closure$0
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\panicking.rs:300
  10:     0x7fff7ce20f90 - std::panicking::default_hook
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\panicking.rs:327
  11:     0x7fff7e5c8df7 - core[7913bd6e64290783]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[86baf848793ac088]::Level, &str), usize), <((rustc_lint_defs[86baf848793ac088]::Level, &str), usize) as core[7913bd6e64290783]::cmp::PartialOrd>::lt>
  12:     0x7fff7ce21e4e - std::panicking::rust_panic_with_hook
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\panicking.rs:841
  13:     0x7fff7ce21b82 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\panicking.rs:699
  14:     0x7fff7ce1c37f - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\sys\backtrace.rs:168
  15:     0x7fff7ce217ce - std::panicking::begin_panic_handler
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\panicking.rs:697
  16:     0x7fff7ff79e51 - core::panicking::panic_fmt
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\core\src\panicking.rs:75
  17:     0x7fff7ff79f0d - core::panicking::panic
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\core\src\panicking.rs:145
  18:     0x7fff7ff79dce - core::option::unwrap_failed
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\core\src\option.rs:2072
  19:     0x7fff7e4d61a7 - <rustc_middle[7a9f6d0772b0e5ea]::ty::sty::ParamConst>::find_ty_from_env
  20:     0x7fff7dece6ae - <rustc_trait_selection[380248135e80b586]::traits::fulfill::FulfillProcessor as rustc_data_structures[201c6ced6e2f5255]::obligation_forest::ObligationProcessor>::process_obligation
  21:     0x7fff7ddbb28f - <rustc_data_structures[201c6ced6e2f5255]::obligation_forest::ObligationForest<rustc_trait_selection[380248135e80b586]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[380248135e80b586]::traits::fulfill::FulfillProcessor>
  22:     0x7fff7d11952a - rustc_hir_typeck[882b3cd343a194b5]::typeck
  23:     0x7fff7d00e5cb - <<rustc_hir_typeck[882b3cd343a194b5]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[c6b2233d270133a9]::visit::TypeVisitor<rustc_middle[7a9f6d0772b0e5ea]::ty::context::TyCtxt>>::visit_ty
  24:     0x7fff7d0758e3 - <<rustc_hir_typeck[882b3cd343a194b5]::fn_ctxt::FnCtxt>::collect_impl_trait_clauses_from_hir_ty::CollectClauses as rustc_hir[14c811bc678e5da3]::intravisit::Visitor>::visit_ty
  25:     0x7fff7d00f248 - <<rustc_hir_typeck[882b3cd343a194b5]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[c6b2233d270133a9]::visit::TypeVisitor<rustc_middle[7a9f6d0772b0e5ea]::ty::context::TyCtxt>>::visit_ty
  26:     0x7fff7d00cdfd - <<rustc_hir_typeck[882b3cd343a194b5]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[c6b2233d270133a9]::visit::TypeVisitor<rustc_middle[7a9f6d0772b0e5ea]::ty::context::TyCtxt>>::visit_ty
  27:     0x7fff7d13b5dd - <rustc_hir_typeck[882b3cd343a194b5]::upvar::InferBorrowKind as rustc_hir_typeck[882b3cd343a194b5]::expr_use_visitor::Delegate>::borrow
  28:     0x7fff7d0e25c0 - rustc_hir_typeck[882b3cd343a194b5]::typeck
  29:     0x7fff7dd5e26b - rustc_query_impl[361a4cf8fe8cc9a1]::plumbing::query_key_hash_verify_all
  30:     0x7fff7dca458e - RINvNtNtCsfUzTRJIdkm9_18rustc_query_system5query8plumbing17try_execute_queryINtCs4DZekDd09mT_16rustc_query_impl13DynamicConfigINtNtCs2KVqGvLot8v_21rustc_data_structures9vec_cache8VecCacheNtNtCsctD8KnfPWOA_10rustc_span6def_id10LocalDefIdINtNtNtCsawIwdSmi5Ly
  31:     0x7fff7dd65552 - rustc_query_impl[361a4cf8fe8cc9a1]::plumbing::query_key_hash_verify_all
  32:     0x7fff7d50ff24 - rustc_mir_build[79dfbe29b966379e]::thir::cx::thir_body
  33:     0x7fff7dd5e4d9 - rustc_query_impl[361a4cf8fe8cc9a1]::plumbing::query_key_hash_verify_all
  34:     0x7fff7dc9ba57 - RINvNtNtCsfUzTRJIdkm9_18rustc_query_system5query8plumbing17try_execute_queryINtCs4DZekDd09mT_16rustc_query_impl13DynamicConfigINtNtCs2KVqGvLot8v_21rustc_data_structures9vec_cache8VecCacheNtNtCsctD8KnfPWOA_10rustc_span6def_id10LocalDefIdINtNtNtCsawIwdSmi5Ly
  35:     0x7fff7dd613e5 - rustc_query_impl[361a4cf8fe8cc9a1]::plumbing::query_key_hash_verify_all
  36:     0x7fff7db42366 - rustc_ty_utils[7e201f528f137b00]::consts::thir_abstract_const
  37:     0x7fff7dd5d11e - rustc_query_impl[361a4cf8fe8cc9a1]::plumbing::query_key_hash_verify_all
  38:     0x7fff7dd3cdad - RINvNtNtCsfUzTRJIdkm9_18rustc_query_system5query8plumbing17try_execute_queryINtCs4DZekDd09mT_16rustc_query_impl13DynamicConfigINtNtCs2KVqGvLot8v_21rustc_data_structures9vec_cache8VecCacheNtNtCsctD8KnfPWOA_10rustc_span6def_id8CrateNumINtNtNtCsawIwdSmi5Ly_12
  39:     0x7fff7dc06fc6 - RINvNtNtCsfUzTRJIdkm9_18rustc_query_system5query8plumbing17try_execute_queryINtCs4DZekDd09mT_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCsawIwdSmi5Ly_12rustc_middle5query5erase6ErasedAhj10_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  40:     0x7fff7dd616d9 - rustc_query_impl[361a4cf8fe8cc9a1]::plumbing::query_key_hash_verify_all
  41:     0x7fff7e423cd7 - <<rustc_middle[7a9f6d0772b0e5ea]::ty::context::TyCtxt>::expand_abstract_consts::Expander as rustc_type_ir[c6b2233d270133a9]::fold::TypeFolder<rustc_middle[7a9f6d0772b0e5ea]::ty::context::TyCtxt>>::fold_const
  42:     0x7fff7cac9402 - rustc_trait_selection[380248135e80b586]::traits::const_evaluatable::is_const_evaluatable
  43:     0x7fff7decf106 - <rustc_trait_selection[380248135e80b586]::traits::fulfill::FulfillProcessor as rustc_data_structures[201c6ced6e2f5255]::obligation_forest::ObligationProcessor>::process_obligation
  44:     0x7fff7ddbb28f - <rustc_data_structures[201c6ced6e2f5255]::obligation_forest::ObligationForest<rustc_trait_selection[380248135e80b586]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[380248135e80b586]::traits::fulfill::FulfillProcessor>
  45:     0x7fff7de3e9fb - <alloc[32e310b5ae9da1df]::raw_vec::RawVec<rustc_type_ir[c6b2233d270133a9]::search_graph::stack::StackEntry<rustc_middle[7a9f6d0772b0e5ea]::ty::context::TyCtxt>>>::grow_one
  46:     0x7fff7d1ba229 - rustc_hir_analysis[f7c4d306c9c42c19]::check::wfcheck::check_well_formed
  47:     0x7fff7d211a6c - rustc_hir_analysis[f7c4d306c9c42c19]::check_crate
  48:     0x7fff7d1b322c - rustc_hir_analysis[f7c4d306c9c42c19]::check::wfcheck::check_well_formed
  49:     0x7fff7dd5cb1b - rustc_query_impl[361a4cf8fe8cc9a1]::plumbing::query_key_hash_verify_all
  50:     0x7fff7dc9f697 - RINvNtNtCsfUzTRJIdkm9_18rustc_query_system5query8plumbing17try_execute_queryINtCs4DZekDd09mT_16rustc_query_impl13DynamicConfigINtNtCs2KVqGvLot8v_21rustc_data_structures9vec_cache8VecCacheNtNtCsctD8KnfPWOA_10rustc_span6def_id10LocalDefIdINtNtNtCsawIwdSmi5Ly
  51:     0x7fff7dd6b4a5 - rustc_query_impl[361a4cf8fe8cc9a1]::plumbing::query_key_hash_verify_all
  52:     0x7fff7d1bdf5c - rustc_hir_analysis[f7c4d306c9c42c19]::check::wfcheck::check_type_wf
  53:     0x7fff7c9c785b - <alloc[32e310b5ae9da1df]::sync::Arc<rustc_session[a3cae7cc1c4ed774]::cstore::CrateSource>>::drop_slow
  54:     0x7fff7c8d5b8a - RINvNtNtCsfUzTRJIdkm9_18rustc_query_system5query8plumbing17try_execute_queryINtCs4DZekDd09mT_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCsawIwdSmi5Ly_12rustc_middle5query5erase6ErasedAhj1_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  55:     0x7fff7c9dd263 - rustc_query_impl[361a4cf8fe8cc9a1]::query_system
  56:     0x7fff7d205d3b - rustc_hir_analysis[f7c4d306c9c42c19]::check_crate
  57:     0x7fff7ce8a0e6 - rustc_interface[d1b5364f93a0f68a]::passes::analysis
  58:     0x7fff7c9cbf9a - <alloc[32e310b5ae9da1df]::sync::Arc<rustc_session[a3cae7cc1c4ed774]::cstore::CrateSource>>::drop_slow
  59:     0x7fff7c8d187a - RINvNtNtCsfUzTRJIdkm9_18rustc_query_system5query8plumbing17try_execute_queryINtCs4DZekDd09mT_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCsawIwdSmi5Ly_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  60:     0x7fff7c9d2393 - rustc_query_impl[361a4cf8fe8cc9a1]::query_system
  61:     0x7fff79318390 - std[b79617825e2e9698]::sys::backtrace::__rust_begin_short_backtrace::<<std[b79617825e2e9698]::thread::Builder>::spawn_unchecked_<ctrlc[5263c6e5b7d8593f]::set_handler_inner<rustc_driver_impl[e9b880bf27d4a298]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  62:     0x7fff793129f6 - std[b79617825e2e9698]::sys::backtrace::__rust_begin_short_backtrace::<<std[b79617825e2e9698]::thread::Builder>::spawn_unchecked_<ctrlc[5263c6e5b7d8593f]::set_handler_inner<rustc_driver_impl[e9b880bf27d4a298]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  63:     0x7fff7930e3ef - RINvNtNtCsfLdZ09muTc2_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCsi0gJWNUH6L6_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCsk45zuI9qXCS_17rustc_driver_i
  64:     0x7fff7931c70d - std[b79617825e2e9698]::sys::backtrace::__rust_begin_short_backtrace::<<std[b79617825e2e9698]::thread::Builder>::spawn_unchecked_<ctrlc[5263c6e5b7d8593f]::set_handler_inner<rustc_driver_impl[e9b880bf27d4a298]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  65:     0x7fff7ce25a1d - alloc::boxed::impl$28::call_once
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\alloc\src\boxed.rs:1966
  66:     0x7fff7ce25a1d - alloc::boxed::impl$28::call_once
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\alloc\src\boxed.rs:1966
  67:     0x7fff7ce25a1d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/c68340350c78eea402c4a85f8d9c1b7d3d607635/library\std\src\sys\pal\windows\thread.rs:56
  68:     0x7ff84fc97374 - BaseThreadInitThunk
  69:     0x7ff85139cc91 - 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

query stack during panic:
#0 [typeck] type-checking `X::{constant#0}`
#1 [thir_body] building THIR for `X::{constant#0}`
#2 [thir_abstract_const] building an abstract representation for `X::{constant#0}`
#3 [check_well_formed] checking that `X` is well-formed
#4 [check_type_wf] checking that types are well-formed
#5 [analysis] running analysis passes on this crate
end of query stack

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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions