Skip to content

Missing value for constant, but no error reported? With impl Trait and [(); T::SIZE]: bound #118278

@idlercloud

Description

@idlercloud

Code

#![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

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> {
   |                 ^^^^^^^^^^^^^^^^^
   |
Backtrace

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions