Repository: rust
Issue: internal compiler error: Missing value for constant, but no error reported?
Labels: I-ICE,T-compiler,C-bug,F-generic_const_exprs,S-has-mcve,S-bug-has-test

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

```Rust
#![feature(generic_const_exprs)]

struct Struct;
trait Trait {
    const CONST: usize = 0;
}
impl Trait for Struct {}

fn f_<T>() {}

trait DynTrait {
    fn f(&self);
}

impl<T> DynTrait for T
where
    T: Trait,
    [(); T::CONST]:,
{
    fn f(&self) {
        f_::<T>()
    }
}

fn main() {
    Box::new(Struct).f();
}

```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.85.0-nightly (9e136a30a 2024-12-19)
binary: rustc
commit-hash: 9e136a30a965bf4e63f03095c57df7257bf96fd6
commit-date: 2024-12-19
host: x86_64-pc-windows-msvc
release: 1.85.0-nightly
LLVM version: 19.1.6
```

### Error output

```
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: Missing value for constant, but no error reported?
  |
  = note: delayed at compiler\rustc_trait_selection\src\traits\const_evaluatable.rs:74:68 - disabled backtrace

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 `C:\Users\agero\Documents\projets\ramsey-dl\rustc-ice-2024-12-21T13_27_24-551924.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `reproduce_crash` (bin "reproduce_crash") generated 2 warnings
error: could not compile `reproduce_crash` (bin "reproduce_crash"); 2 warnings emitted

Caused by:
  process didn't exit successfully: `C:\Users\agero\.rustup\toolchains\nightly-2024-12-20-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name reproduce_crash --edition=2024 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=119 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs) --check-cfg "cfg(feature, values())" -C metadata=f41a790c0ca691fa --out-dir C:\Users\agero\Documents\projets\ramsey-dl\target\debug\deps -C incremental=C:\Users\agero\Documents\projets\ramsey-dl\target\debug\incremental -L dependency=C:\Users\agero\Documents\projets\ramsey-dl\target\debug\deps` (exit code: 101)
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
delayed bug: Missing value for constant, but no error reported?
   0: std::backtrace_rs::backtrace::dbghelp64::trace
             at /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2: std::backtrace::Backtrace::create
             at /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/library\std\src\backtrace.rs:331
   3: std::backtrace::Backtrace::capture
             at /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/library\std\src\backtrace.rs:296
   4: <rustc_errors::DiagCtxtHandle>::flush_delayed
   5: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
   6: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   7: <hashbrown::raw::RawTable<usize>>::reserve_rehash::<indexmap::map::core::get_hash<rustc_middle::ty::region::Region, ()>::{closure#0}>
   8: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
   9: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_root_obligation
  10: rustc_traits::evaluate_obligation::evaluate_obligation
  11: rustc_query_impl::plumbing::query_key_hash_verify_all
  12: RINvNtNtCsQCwQoe5Jo1_18rustc_query_system5query8plumbing17try_execute_queryINtCs4qpE3tcYOsg_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs4xXlGRTpLhK_13rustc_type_ir9canonical19CanonicalQueryInputNtNtNtCsabap53b4qYL_12rustc_middle2ty
  13: rustc_query_impl::plumbing::query_key_hash_verify_all
  14: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  15: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::predicate_may_hold
  16: <alloc::raw_vec::RawVec<rustc_hir_typeck::method::probe::Candidate>>::grow_one
  17: rustc_hir_typeck::method::probe::method_autoderef_steps
  18: rustc_hir_typeck::method::probe::method_autoderef_steps
  19: rustc_hir_typeck::typeck
  20: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  21: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  22: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  23: rustc_hir_typeck::typeck
  24: rustc_hir_typeck::typeck
  25: rustc_query_impl::plumbing::query_key_hash_verify_all
  26: RINvNtNtCsQCwQoe5Jo1_18rustc_query_system5query8plumbing17try_execute_queryINtCs4qpE3tcYOsg_16rustc_query_impl13DynamicConfigINtNtCsl5fsRWpEAH1_21rustc_data_structures9vec_cache8VecCacheNtNtCshwu7G5mdp9_10rustc_span6def_id10LocalDefIdINtNtNtCsabap53b4qYL_1
  27: rustc_query_impl::plumbing::query_key_hash_verify_all
  28: RINvMs6_NtCsfSe2htisICB_9hashbrown3rawINtB6_8RawTablejE14reserve_rehashNCINvNtNtCsggveAX2leLM_8indexmap3map4core8get_hashTNtNtNtCsabap53b4qYL_12rustc_middle2ty9predicate6ClauseNtNtCshwu7G5mdp9_10rustc_span13span_encoding4SpanEuE0ECs4Qtc6Yytiwo_18rustc_hir_
  29: rustc_hir_analysis::check_crate
  30: rustc_interface::passes::resolver_for_lowering_raw
  31: rustc_interface::passes::analysis
  32: <alloc::sync::Arc<rustc_session::cstore::CrateSource>>::drop_slow
  33: RINvNtNtCsQCwQoe5Jo1_18rustc_query_system5query8plumbing17try_execute_queryINtCs4qpE3tcYOsg_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCsabap53b4qYL_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3r_KB3r_ENtNtB1e_8plumbing9QueryCtxt
  34: rustc_query_impl::query_system
  35: RINvNtNtCs8RqLblBvRGN_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsjGo8snB8Fhu_5alloc5boxed3BoxDINtNtNtCs6jWqyqrNxNm_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs36X
  36: RINvNtNtCs8RqLblBvRGN_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsjGo8snB8Fhu_5alloc5boxed3BoxDINtNtNtCs6jWqyqrNxNm_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs36X
  37: RINvNtNtCs8RqLblBvRGN_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCsjzFb9IgEjHS_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCs36XBSsR0b4J_17rustc_driver_i
  38: RINvNtNtCs8RqLblBvRGN_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsjGo8snB8Fhu_5alloc5boxed3BoxDINtNtNtCs6jWqyqrNxNm_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs36X
  39: alloc::boxed::impl$28::call_once
             at /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/library\alloc\src\boxed.rs:1970
  40: alloc::boxed::impl$28::call_once
             at /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/library\alloc\src\boxed.rs:1970
  41: std::sys::pal::windows::thread::impl$0::new::thread_start
             at /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/library\std\src\sys\pal\windows\thread.rs:55
  42: BaseThreadInitThunk
  43: RtlUserThreadStart



rustc version: 1.85.0-nightly (9e136a30a 2024-12-19)
platform: x86_64-pc-windows-msvc
```

</p>
</details>