Skip to content

[ICE]: Type system constant with non valtree'able type evaluated but no error emitted #166128

Open

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(gca_min_const_items)]
#![feature(adt_const_params)]
#![feature(gca_const_items)]
#![feature(const_param_ty_unchecked)]

trait Trait {
    const F: fn();
}

fn take<T>()
where
    T: Trait<F = { || {} }>,
{
}

fn main() {}

original:

#![feature(const_param_ty_unchecked, const_param_ty_trait)]

trait Trait {
    const F: fn();
}

fn take<T>() where T: Trait<F = { || {} }> {}
//~^ ERROR using function pointers as const generic parameters is forbidden

fn main() {}

Version information

rustc 1.102.0-nightly (59cbdee2e 2026-11-17)
binary: rustc
commit-hash: 59cbdee2e7b3ee50e44b460561c43c9e3023d9f0
commit-date: 2026-11-17
host: x86_64-unknown-linux-gnu
release: 1.102.0-nightly
LLVM version: 23.1.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(gca_min_const_items) -Zcrate-attr=feature(adt_const_params) -Zcrate-attr=feature(gca_const_items)

Program output

warning: the feature `gca_min_const_items` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(gca_min_const_items)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = 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 `gca_const_items` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(gca_const_items)]
  |            ^^^^^^^^^^^^^^^
  |
  = note: see issue #151972 <https://github.com/rust-lang/rust/issues/151972> for more information

warning: the feature `const_param_ty_unchecked` is internal to the compiler or standard library
 --> /tmp/icemaker_global_tempdir.Qjmcv1Iutx3H/rustc_testrunner_tmpdir_reporting.GVZF7zyahNjq/mvce.rs:1:12
  |
1 | #![feature(const_param_ty_unchecked)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default

warning: trait `Trait` is never used
 --> /tmp/icemaker_global_tempdir.Qjmcv1Iutx3H/rustc_testrunner_tmpdir_reporting.GVZF7zyahNjq/mvce.rs:3:7
  |
3 | trait Trait {
  |       ^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: function `take` is never used
 --> /tmp/icemaker_global_tempdir.Qjmcv1Iutx3H/rustc_testrunner_tmpdir_reporting.GVZF7zyahNjq/mvce.rs:7:4
  |
7 | fn take<T>()
  |    ^^^^

warning: 5 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: Type system constant with non valtree'able type evaluated but no error emitted
 |
 = note: delayed at /rustc-dev/59cbdee2e7b3ee50e44b460561c43c9e3023d9f0/compiler/rustc_middle/src/ty/context/impl_interner.rs:641:20
            0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
            1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
            2: <rustc_errors::diagnostic::Diag>::emit_err
            3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
            4: <rustc_middle::ty::context::TyCtxt as rustc_type_ir::interner::Interner>::delay_bug::<&str>
            5: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_const
            6: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_no_fast_paths
            7: <rustc_trait_selection::solve::delegate::SolverDelegate as rustc_next_trait_solver::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal::{closure#0}
            8: <rustc_next_trait_solver::normalize::NormalizationFolder<rustc_infer::infer::InferCtxt, rustc_middle::ty::context::TyCtxt, rustc_trait_selection::solve::normalize::normalize_with_universes<alloc::vec::Vec<rustc_middle::ty::predicate::Clause>>::{closure#0}>>::normalize_alias_term
            9: <rustc_next_trait_solver::normalize::NormalizationFolder<rustc_infer::infer::InferCtxt, rustc_middle::ty::context::TyCtxt, rustc_trait_selection::solve::normalize::normalize_with_universes<alloc::vec::Vec<rustc_middle::ty::predicate::Clause>>::{closure#0}> as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_const::{closure#0}
           10: <rustc_infer::infer::at::At as rustc_trait_selection::traits::normalize::NormalizeExt>::normalize::<alloc::vec::Vec<rustc_middle::ty::predicate::Clause>>
           11: rustc_trait_selection::traits::do_normalize_clauses
           12: rustc_trait_selection::traits::normalize_param_env_or_error
           13: rustc_ty_utils::ty::param_env
           14: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefIdCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
           15: rustc_query_impl::query_vtables::param_env::execute_query_non_incr::__rust_end_short_backtrace
           16: rustc_hir_analysis::check::wfcheck::check_item_fn
           17: rustc_hir_analysis::check::check::check_item_type
           18: rustc_hir_analysis::check::wfcheck::check_well_formed
           19: rustc_query_impl::query_vtables::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
           20: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 1]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
           21: rustc_query_impl::query_vtables::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
           22: <rustc_middle::hir::ModuleItems>::par_opaques::<rustc_hir_analysis::check::wfcheck::check_type_wf::{closure#5}>::{closure#0}
           23: <rustc_thread_pool::job::HeapJob<<rustc_thread_pool::scope::Scope>::spawn<rustc_data_structures::sync::parallel::par_range_internal<rustc_data_structures::sync::parallel::try_par_for_each_in<rustc_hir::hir::ImplItemId, rustc_span::ErrorGuaranteed, [rustc_hir::hir::ImplItemId], <rustc_middle::hir::ModuleItems>::par_impl_items<rustc_hir_analysis::check::wfcheck::check_type_wf::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#1}::{closure#0}>::{closure#0}> as rustc_thread_pool::job::Job>::execute
           24: <rustc_thread_pool::registry::WorkerThread>::wait_or_steal_until_cold
           25: <rustc_thread_pool::registry::ThreadBuilder>::run
           26: std::sys::backtrace::__rust_begin_short_backtrace::<<rustc_thread_pool::ThreadPoolBuilder>::build_scoped<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#6}::{closure#0}::{closure#0}, rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#6}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
           27: <std::thread::lifecycle::spawn_unchecked<<rustc_thread_pool::ThreadPoolBuilder>::build_scoped<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#6}::{closure#0}::{closure#0}, rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#6}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
           28: <std::sys::thread::unix::Thread>::new::thread_start
           29: <unknown>
           30: <unknown>
         

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: rustc 1.102.0-nightly (59cbdee2e 2026-11-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(gca_min_const_items) -Z crate-attr=feature(adt_const_params) -Z crate-attr=feature(gca_const_items) -Z dump-mir-dir=dir

query stack during panic:
end of query stack

@rustbot label +F-const_param_ty_unchecked +F-const_param_ty_trait +F-gca_min_const_items +F-adt_const_params +F-gca_const_items

Activity

  1. added
    I-ICE
    T-compiler
    C-bug
    on Nov 17, 2026
  2. added
    needs-triage
    on Nov 17, 2026
  3. rustbot commented on Nov 17, 2026

    @rustbot
    Collaborator

    Error: Unknown labels: F-const_param_ty_trait, F-const_param_ty_unchecked

    Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

  4. added
    F-adt_const_params
    F-gca_min_const_items
    F-gca_const_items
    S-found-by-fuzzing
    on Nov 17, 2026
  5. bit-aloo commented on Nov 18, 2026

    @bit-aloo
    Member

    @rustbot claim

  6. khyperia commented on Nov 18, 2026

    @khyperia
    Member

    just an informational note, this is very related to #161131

    fns can't be supported in type system constants, and so we check them against ConstParamTy. fns do not implement ConstParamTy so we error and don't evaluate them... except if we enable #![feature(const_param_ty_unchecked)] in which case, full beans ahead, kaboom.

  7. added a commit that references this issue on Nov 20, 2026
  8. added a commit that references this issue on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugF-adt_const_paramsF-gca_const_itemsF-gca_min_const_itemsI-ICES-found-by-fuzzingT-compilerneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions