rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.29k stars 12.58k forks source link

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

Open idlercloud opened 10 months ago

idlercloud commented 10 months ago

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 { | ^^^^^^^^^^^^^^^^^ | 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: ::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: ::process_obligation 6: rustc_trait_selection::traits::specialize::specializes 7: ::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: ::load_side_effects 11: ::load_side_effects 12: rustc_query_impl::profiling_support::alloc_self_profile_query_strings 13: ::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: ::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 { | ^^^^^^^^^^^^^^^^^ error: internal compiler error: `report_selection_error` did not emit an error --> src\lib.rs:20:17 | 20 | pub fn bar() -> Wrapper { | ^^^^^^^^^^^^^^^^^ | 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: ::emit_diagnostic 3: RNvXNvNtNtNtCsfdc4zcIYLoJ_21rustc_trait_selection6traits15error_reporting16on_unimplemented76__DERIVE_rustc_errors_DecorateLint_a_FOR_MissingOptionsForOnUnimplementedAttrNtB4_36MissingOptionsForOnUnimplementedAttrINtNtCs8xPSDAFGckV_12rustc_errors10diagnos 4: ::report_selection_error 5: ::report_fulfillment_error 6: ::report_fulfillment_errors 7: ::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: ::load_side_effects 11: ::load_side_effects 12: rustc_query_impl::profiling_support::alloc_self_profile_query_strings 13: ::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: ::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 { | ^^^^^^^^^^^^^^^^^ 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: ::emit_diagnostic 3: RNvXNvNtNtNtCsfdc4zcIYLoJ_21rustc_trait_selection6traits15error_reporting16on_unimplemented76__DERIVE_rustc_errors_DecorateLint_a_FOR_MissingOptionsForOnUnimplementedAttrNtB4_36MissingOptionsForOnUnimplementedAttrINtNtCs8xPSDAFGckV_12rustc_errors10diagnos 4: ::report_fulfillment_errors 5: ::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: ::load_side_effects 9: ::load_side_effects 10: rustc_query_impl::profiling_support::alloc_self_profile_query_strings 11: ::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: ::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 ```

matthiaskrgr commented 10 months ago

Might be duplicate of https://github.com/rust-lang/rust/issues/110378