Repository: rust
Issue: Missing value for constant, but no error reported? With impl Trait and `[(); T::SIZE]:` bound
Labels: A-diagnostics,I-ICE,A-trait-system,E-needs-test,T-compiler,C-bug,F-generic_const_exprs,S-has-mcve,requires-incomplete-features

<!--
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
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

pub trait Foo {
    const SIZE: usize;
}

impl Foo for u64 {
    const SIZE: usize = 8;
}

pub struct Wrapper<T>
where
    T: Foo,
    [(); T::SIZE]:, // Remove this trait bound and everything will be ok
{
    pub t: T,
}

pub fn bar() -> Wrapper<impl Foo> {
    Wrapper { t: 10 }
}
```


### 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.76.0-nightly (a57770440 2023-11-16)
binary: rustc
commit-hash: a57770440f1ebe5b992551d3bcc489ae211908d4
commit-date: 2023-11-16
host: x86_64-pc-windows-msvc
release: 1.76.0-nightly
LLVM version: 17.0.5
```

### Error output

```
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Missing value for constant, but no error reported?
  --> src\lib.rs:20:17
   |
20 | pub fn bar() -> Wrapper<impl Foo> {
   |                 ^^^^^^^^^^^^^^^^^
   |
```

<!--
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>

```
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Missing value for constant, but no error reported?
  --> src\lib.rs:20:17
   |
20 | pub fn bar() -> Wrapper<impl Foo> {
   |                 ^^^^^^^^^^^^^^^^^
   |
note: delayed at compiler\rustc_trait_selection\src\traits\const_evaluatable.rs:77:71
         0: std::backtrace::Backtrace::force_capture
         1: std::backtrace::Backtrace::capture
         2: <rustc_errors::HandlerInner>::emit_diagnostic
         3: RNvXNvNtNtNtCsfdc4zcIYLoJ_21rustc_trait_selection6traits15error_reporting16on_unimplemented76__DERIVE_rustc_errors_DecorateLint_a_FOR_MissingOptionsForOnUnimplementedAttrNtB4_36MissingOptionsForOnUnimplementedAttrINtNtCs8xPSDAFGckV_12rustc_errors10diagnos
         4: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
         5: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
         6: rustc_trait_selection::traits::specialize::specializes
         7: <rustc_trait_selection::traits::engine::ObligationCtxt>::assumed_wf_types_and_report_errors
         8: rustc_hir_analysis::check::dropck::check_drop_impl
         9: rustc_hir_analysis::check::wfcheck::check_well_formed
        10: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
        11: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
        12: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        13: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
        14: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        15: rustc_privacy::check_private_in_public
        16: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        17: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        18: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        19: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        20: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        21: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        22: rustc_privacy::effective_visibilities
        23: <rustc_hir_analysis::collect::resolve_bound_vars::BoundVarContext as rustc_hir::intravisit::Visitor>::visit_trait_item
        24: rustc_hir_analysis::check_crate
        25: rustc_interface::passes::analysis
        26: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        27: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        28: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        29: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        30: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        31: rustc_driver_impl::main
        32: rustc_driver_impl::args::arg_expand_all
        33: rustc_driver_impl::args::arg_expand_all
        34: rustc_driver_impl::args::arg_expand_all
        35: rustc_driver_impl::main
        36: rustc_driver_impl::main
        37: std::sys::windows::thread::Thread::new
        38: BaseThreadInitThunk
        39: RtlUserThreadStart
  --> src\lib.rs:20:17
   |
20 | pub fn bar() -> Wrapper<impl Foo> {
   |                 ^^^^^^^^^^^^^^^^^

error: internal compiler error: `report_selection_error` did not emit an error
  --> src\lib.rs:20:17
   |
20 | pub fn bar() -> Wrapper<impl Foo> {
   |                 ^^^^^^^^^^^^^^^^^
   |
note: delayed at compiler\rustc_trait_selection\src\traits\error_reporting\type_err_ctxt_ext.rs:366:22
         0: std::backtrace::Backtrace::force_capture
         1: std::backtrace::Backtrace::capture
         2: <rustc_errors::HandlerInner>::emit_diagnostic
         3: RNvXNvNtNtNtCsfdc4zcIYLoJ_21rustc_trait_selection6traits15error_reporting16on_unimplemented76__DERIVE_rustc_errors_DecorateLint_a_FOR_MissingOptionsForOnUnimplementedAttrNtB4_36MissingOptionsForOnUnimplementedAttrINtNtCs8xPSDAFGckV_12rustc_errors10diagnos
         4: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
         5: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
         6: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
         7: <rustc_trait_selection::traits::engine::ObligationCtxt>::assumed_wf_types_and_report_errors
         8: rustc_hir_analysis::check::dropck::check_drop_impl
         9: rustc_hir_analysis::check::wfcheck::check_well_formed
        10: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
        11: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
        12: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        13: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
        14: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        15: rustc_privacy::check_private_in_public
        16: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        17: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        18: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        19: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        20: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        21: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        22: rustc_privacy::effective_visibilities
        23: <rustc_hir_analysis::collect::resolve_bound_vars::BoundVarContext as rustc_hir::intravisit::Visitor>::visit_trait_item
        24: rustc_hir_analysis::check_crate
        25: rustc_interface::passes::analysis
        26: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        27: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        28: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        29: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        30: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
        31: rustc_driver_impl::main
        32: rustc_driver_impl::args::arg_expand_all
        33: rustc_driver_impl::args::arg_expand_all
        34: rustc_driver_impl::args::arg_expand_all
        35: rustc_driver_impl::main
        36: rustc_driver_impl::main
        37: std::sys::windows::thread::Thread::new
        38: BaseThreadInitThunk
        39: RtlUserThreadStart
  --> src\lib.rs:20:17
   |
20 | pub fn bar() -> Wrapper<impl Foo> {
   |                 ^^^^^^^^^^^^^^^^^

error: internal compiler error: expected fulfillment errors
  |
  = note: delayed at compiler\rustc_trait_selection\src\traits\error_reporting\type_err_ctxt_ext.rs:215:23
             0: std::backtrace::Backtrace::force_capture
             1: std::backtrace::Backtrace::capture
             2: <rustc_errors::HandlerInner>::emit_diagnostic
             3: RNvXNvNtNtNtCsfdc4zcIYLoJ_21rustc_trait_selection6traits15error_reporting16on_unimplemented76__DERIVE_rustc_errors_DecorateLint_a_FOR_MissingOptionsForOnUnimplementedAttrNtB4_36MissingOptionsForOnUnimplementedAttrINtNtCs8xPSDAFGckV_12rustc_errors10diagnos
             4: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
             5: <rustc_trait_selection::traits::engine::ObligationCtxt>::assumed_wf_types_and_report_errors
             6: rustc_hir_analysis::check::dropck::check_drop_impl
             7: rustc_hir_analysis::check::wfcheck::check_well_formed
             8: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
             9: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
            10: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            11: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::load_side_effects
            12: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            13: rustc_privacy::check_private_in_public
            14: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
            15: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            16: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            17: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            18: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            19: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            20: rustc_privacy::effective_visibilities
            21: <rustc_hir_analysis::collect::resolve_bound_vars::BoundVarContext as rustc_hir::intravisit::Visitor>::visit_trait_item
            22: rustc_hir_analysis::check_crate
            23: rustc_interface::passes::analysis
            24: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            25: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            26: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            27: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            28: rustc_query_impl::profiling_support::alloc_self_profile_query_strings
            29: rustc_driver_impl::main
            30: rustc_driver_impl::args::arg_expand_all
            31: rustc_driver_impl::args::arg_expand_all
            32: rustc_driver_impl::args::arg_expand_all
            33: rustc_driver_impl::main
            34: rustc_driver_impl::main
            35: std::sys::windows::thread::Thread::new
            36: BaseThreadInitThunk
            37: RtlUserThreadStart


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 attach the file at `C:\Idler\Code\lab\test-rust\rustc-ice-2023-11-25T09_27_07-25892.txt` to your bug report

note: compiler flags: --crate-type lib -C panic=abort -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
```

</p>
</details>