Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE for enum discriminant being a const generic #111012

Closed
programmerjake opened this issue Apr 30, 2023 · 0 comments · Fixed by #111215
Closed

ICE for enum discriminant being a const generic #111012

programmerjake opened this issue Apr 30, 2023 · 0 comments · Fixed by #111215
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@programmerjake
Copy link
Member

Code

pub enum E<const V: isize> {
    V = V,
}

Meta

version from playground:

1.69.0 (84c898d65 2023-04-16)

also occurs on nightly, from playground:

rustc 1.71.0-nightly (87b1f891e 2023-04-29)

Error output

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: enum discriminant depends on generics
 --> src/lib.rs:2:9
  |
2 |     V = V,
  |         ^
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
             3: <rustc_middle::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis::collect::CollectItemTypesVisitor>
             4: rustc_hir_analysis::collect::collect_mod_item_types
             5: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::collect_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
             6: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_mod_item_types
             7: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#0}::{closure#0}::{closure#0}>
             8: <rustc_session::session::Session>::track_errors::<rustc_hir_analysis::check_crate::{closure#0}, ()>
             9: rustc_hir_analysis::check_crate
            10: rustc_interface::passes::analysis
            11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            13: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            14: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
            15: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            16: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            17: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            18: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/alloc/src/boxed.rs:1962:9
            19: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/alloc/src/boxed.rs:1962:9
            20: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/sys/unix/thread.rs:108:17
            21: start_thread
            22: clone
          

error: internal compiler error: enum discriminant depends on generics
 --> src/lib.rs:2:9
  |
2 |     V = V,
  |         ^
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_middle::ty::VariantDef>>, <rustc_index::slice::IndexSlice<rustc_abi::VariantIdx, rustc_middle::ty::VariantDef>>::iter_enumerated::{closure#0}>, <rustc_middle::ty::adt::AdtDef>::discriminants::{closure#0}> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::traits::iterator::Iterator::for_each::call<(rustc_abi::VariantIdx, rustc_middle::ty::util::Discr), <alloc::vec::Vec<(rustc_abi::VariantIdx, rustc_middle::ty::util::Discr)>>::extend_trusted<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_middle::ty::VariantDef>>, <rustc_index::slice::IndexSlice<rustc_abi::VariantIdx, rustc_middle::ty::VariantDef>>::iter_enumerated::{closure#0}>, <rustc_middle::ty::adt::AdtDef>::discriminants::{closure#0}>>::{closure#0}>::{closure#0}>
             3: <alloc::vec::Vec<(rustc_abi::VariantIdx, rustc_middle::ty::util::Discr)> as alloc::vec::spec_from_iter::SpecFromIter<(rustc_abi::VariantIdx, rustc_middle::ty::util::Discr), core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_middle::ty::VariantDef>>, <rustc_index::slice::IndexSlice<rustc_abi::VariantIdx, rustc_middle::ty::VariantDef>>::iter_enumerated::{closure#0}>, <rustc_middle::ty::adt::AdtDef>::discriminants::{closure#0}>>>::from_iter
             4: rustc_hir_analysis::check::check::check_mod_item_types
             5: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
             6: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
             7: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
             8: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#6}>
             9: rustc_hir_analysis::check_crate
            10: rustc_interface::passes::analysis
            11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            13: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            14: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
            15: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            16: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            17: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            18: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/alloc/src/boxed.rs:1962:9
            19: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/alloc/src/boxed.rs:1962:9
            20: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/sys/unix/thread.rs:108:17
            21: start_thread
            22: clone
          

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: rustc 1.71.0-nightly (87b1f891e 2023-04-29) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack
error: could not compile `playground` (lib)
@programmerjake programmerjake added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 30, 2023
@BoxyUwU BoxyUwU self-assigned this Apr 30, 2023
@bors bors closed this as completed in 363d158 May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants