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] Const generics + Const normalization + Specialization #72845

Closed
Sydre opened this issue Jun 1, 2020 · 6 comments · Fixed by #91551
Closed

[ICE] Const generics + Const normalization + Specialization #72845

Sydre opened this issue Jun 1, 2020 · 6 comments · Fixed by #91551
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-test Call 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)]` F-specialization `#![feature(specialization)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Sydre
Copy link

Sydre commented Jun 1, 2020

Found while toying around #20400.

Code

#![feature(const_generics)]
#![feature(specialization)]
#![allow(incomplete_features)]

//--------------------------------------------------

trait Depth {
    const C: usize;
}

trait Type {
    type AT: Depth;
}

//--------------------------------------------------

enum Predicate<const B: bool> {}

trait Satisfied {}

impl Satisfied for Predicate<true> {}

//--------------------------------------------------

trait Spec1 {}

impl<T: Type> Spec1 for T where Predicate<{T::AT::C > 0}>: Satisfied {}

trait Spec2: Spec1 {}

impl<T: Type + Spec1> Spec2 for T where Predicate<{T::AT::C > 1}>: Satisfied {}

//--------------------------------------------------

trait Foo {
    fn Bar();
}

impl<T: Spec1> Foo for T {
    default fn Bar() {}
}

impl<T: Spec2> Foo for T {
    fn Bar() {}
}

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (74e804683 2020-05-30) running on x86_64-unknown-linux-gnu

Error output

error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:37: could not fully normalize `Const { ty: usize, val: Unevaluated(DefId(0:4 ~ playground[3575]::Depth[0]::C[0]), [<T as Type>::AT], None) }`
Backtrace

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:907:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:490
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc_middle::ty::context::tls::with_opt::{{closure}}
  17: rustc_middle::ty::context::tls::with_opt
  18: rustc_middle::util::bug::opt_span_bug_fmt
  19: rustc_middle::util::bug::bug_fmt
  20: rustc_middle::ty::context::GlobalCtxt::enter_local
  21: rustc_traits::normalize_erasing_regions::normalize_generic_arg_after_erasing_regions
  22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::normalize_generic_arg_after_erasing_regions>::compute
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::get_query_impl
  26: <rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_middle::ty::fold::TypeFolder>::fold_const
  27: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::subst_and_normalize_erasing_regions
  28: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_operand
  29: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
  30: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  31: rustc_mir::const_eval::eval_queries::const_eval_raw_provider
  32: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_raw>::compute
  33: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  34: rustc_query_system::query::plumbing::get_query_impl::{{closure}}
  35: rustc_query_system::query::plumbing::get_query_impl
  36: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  37: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute
  38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  39: rustc_data_structures::stack::ensure_sufficient_stack
  40: rustc_query_system::query::plumbing::get_query_impl
  41: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  42: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  43: rustc_infer::infer::InferCtxt::const_eval_resolve
  44: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation::{{closure}}
  45: rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations
  46: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_where_possible
  47: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_all_or_error
  48: rustc_infer::infer::InferCtxt::save_and_restore_in_snapshot_flag
  49: rustc_trait_selection::traits::specialize::fulfill_implication
  50: rustc_middle::ty::context::GlobalCtxt::enter_local
  51: rustc_trait_selection::traits::specialize::specializes
  52: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::specializes>::compute
  53: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  54: rustc_data_structures::stack::ensure_sufficient_stack
  55: rustc_query_system::query::plumbing::get_query_impl
  56: rustc_middle::ty::context::GlobalCtxt::enter_local
  57: rustc_trait_selection::traits::coherence::overlapping_impls
  58: <rustc_middle::traits::specialization_graph::Children as rustc_trait_selection::traits::specialize::specialization_graph::ChildrenExt>::insert
  59: <rustc_middle::traits::specialization_graph::Graph as rustc_trait_selection::traits::specialize::specialization_graph::GraphExt>::insert
  60: rustc_trait_selection::traits::specialize::specialization_graph_provider
  61: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::specialization_graph_of>::compute
  62: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  63: rustc_data_structures::stack::ensure_sufficient_stack
  64: rustc_query_system::query::plumbing::get_query_impl
  65: rustc_query_system::query::plumbing::ensure_query_impl
  66: rustc_typeck::coherence::coherent_trait
  67: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::coherent_trait>::compute
  68: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  69: rustc_data_structures::stack::ensure_sufficient_stack
  70: rustc_query_system::query::plumbing::get_query_impl
  71: rustc_query_system::query::plumbing::ensure_query_impl
  72: rustc_typeck::coherence::check_coherence
  73: rustc_typeck::check_crate
  74: rustc_interface::passes::analysis
  75: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  76: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  77: rustc_query_system::query::plumbing::get_query_impl
  78: rustc_middle::ty::context::tls::enter_global
  79: rustc_interface::interface::run_compiler_in_existing_thread_pool
  80: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.45.0-nightly (74e804683 2020-05-30) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<<T as Type>::AT as Depth>::C`
#1 [const_eval_raw] const-evaluating `<T as Spec2>::{{constant}}#0`
#2 [const_eval_validated] const-evaluating + checking `<T as Spec2>::{{constant}}#0`
#3 [specializes] computing whether impls specialize one another
#4 [specialization_graph_of] building specialization graph of trait `Foo`
#5 [coherent_trait] coherence checking all impls of trait `Foo`
#6 [analysis] running analysis passes on this crate
end of query stack

@Sydre Sydre 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 Jun 1, 2020
@lcnr lcnr added A-const-generics Area: const generics (parameters and arguments) F-const_generics `#![feature(const_generics)]` F-specialization `#![feature(specialization)]` labels Jun 1, 2020
@JohnTitor JohnTitor added the requires-nightly This issue requires a nightly compiler in some way. label Jun 1, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jun 2, 2020
@matthiaskrgr
Copy link
Member

This ICEs since 1.45
@rustbot modify labels: +regression-from-stable-to-stable

@rustbot rustbot added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Dec 20, 2020
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 8, 2021
…e, r=oli-obk

Allow for failure of subst_normalize_erasing_regions in const_eval

Fixes rust-lang#72845

Using associated types that cannot be normalized previously resulted in an ICE. We now allow for normalization failure and return a "TooGeneric" error in that case.

r? `@RalfJung` maybe?
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 8, 2021
…e, r=oli-obk

Allow for failure of subst_normalize_erasing_regions in const_eval

Fixes rust-lang#72845

Using associated types that cannot be normalized previously resulted in an ICE. We now allow for normalization failure and return a "TooGeneric" error in that case.

r? ``@RalfJung`` maybe?
@bors bors closed this as completed in 317f750 Dec 8, 2021
@matthiaskrgr
Copy link
Member

Well, this still crashes if I add a main function or check with --crate-type lib

warning: trait method `Bar` should have a snake case name
  --> ./72845.rs:36:8
   |
36 |     fn Bar();
   |        ^^^ help: convert the identifier to snake case: `bar`
   |
   = note: `#[warn(non_snake_case)]` on by default

warning: 1 warning emitted

error: internal compiler error: failed to normalize <<T as Type>::AT as Depth>::C
  |
  = note: delayed at compiler/rustc_const_eval/src/interpret/eval_context.rs:527:31

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1189:13
stack backtrace:
   0:     0x7f17cb4cc35c - std::backtrace_rs::backtrace::libunwind::trace::hf7449935ead7573e
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f17cb4cc35c - std::backtrace_rs::backtrace::trace_unsynchronized::h221aa2d88d72372a
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f17cb4cc35c - std::sys_common::backtrace::_print_fmt::h1c77e8983e1df895
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f17cb4cc35c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4ec41a9a6b0d22c
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f17cb52937c - core::fmt::write::h72801a82c94e6ff1
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/core/src/fmt/mod.rs:1149:17
   5:     0x7f17cb4bca65 - std::io::Write::write_fmt::haf74340a8cbeaa88
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/io/mod.rs:1660:15
   6:     0x7f17cb4cf520 - std::sys_common::backtrace::_print::h2d15cd157796a64a
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f17cb4cf520 - std::sys_common::backtrace::print::h52d286d22e2398eb
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f17cb4cf520 - std::panicking::default_hook::{{closure}}::h6da08fba6306daf2
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/panicking.rs:211:50
   9:     0x7f17cb4cf0cb - std::panicking::default_hook::h266f67a22e76b11a
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/panicking.rs:228:9
  10:     0x7f17cbff3291 - rustc_driver[feb513e6adc957d8]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f17cb4cfd39 - std::panicking::rust_panic_with_hook::he55698a957f4fb6d
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/panicking.rs:610:17
  12:     0x7f17cb4cf7f0 - std::panicking::begin_panic_handler::{{closure}}::h01f453c3ac181895
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/panicking.rs:502:13
  13:     0x7f17cb4cc804 - std::sys_common::backtrace::__rust_end_short_backtrace::h675d77c6e5a3926d
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/sys_common/backtrace.rs:139:18
  14:     0x7f17cb4cf759 - rust_begin_unwind
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/panicking.rs:498:5
  15:     0x7f17cb493c21 - core::panicking::panic_fmt::h7b8580d81fcbbacd
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/core/src/panicking.rs:107:14
  16:     0x7f17cd12fe9c - core[cc79c391059f8e46]::panicking::panic_display::<&str>
  17:     0x7f17ce7c4e7a - <rustc_errors[248f3f311c690252]::HandlerInner>::flush_delayed
  18:     0x7f17ce7c35fd - <rustc_errors[248f3f311c690252]::HandlerInner as core[cc79c391059f8e46]::ops::drop::Drop>::drop
  19:     0x7f17cdea73b6 - core[cc79c391059f8e46]::ptr::drop_in_place::<rustc_session[2680299e10ec9d86]::parse::ParseSess>
  20:     0x7f17cdea9a9a - <alloc[1954047e53701c4d]::rc::Rc<rustc_session[2680299e10ec9d86]::session::Session> as core[cc79c391059f8e46]::ops::drop::Drop>::drop
  21:     0x7f17cde8496d - core[cc79c391059f8e46]::ptr::drop_in_place::<rustc_interface[4c4b5644b43577f1]::interface::Compiler>
  22:     0x7f17cde84332 - rustc_span[dda57b1885b40b9a]::with_source_map::<core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>, rustc_interface[4c4b5644b43577f1]::interface::create_compiler_and_run<core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>, rustc_driver[feb513e6adc957d8]::run_compiler::{closure#1}>::{closure#1}>
  23:     0x7f17cde887ef - <scoped_tls[3fea4c3dcac147b1]::ScopedKey<rustc_span[dda57b1885b40b9a]::SessionGlobals>>::set::<rustc_interface[4c4b5644b43577f1]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[4c4b5644b43577f1]::interface::run_compiler<core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>, rustc_driver[feb513e6adc957d8]::run_compiler::{closure#1}>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>>::{closure#0}::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>>
  24:     0x7f17cde86995 - std[f24903a91e569aa2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4c4b5644b43577f1]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[4c4b5644b43577f1]::interface::run_compiler<core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>, rustc_driver[feb513e6adc957d8]::run_compiler::{closure#1}>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>>
  25:     0x7f17cdea6ffa - <<std[f24903a91e569aa2]::thread::Builder>::spawn_unchecked<rustc_interface[4c4b5644b43577f1]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[4c4b5644b43577f1]::interface::run_compiler<core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>, rustc_driver[feb513e6adc957d8]::run_compiler::{closure#1}>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[248f3f311c690252]::ErrorReported>>::{closure#1} as core[cc79c391059f8e46]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7f17cb4dae23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4beb69a85f7fb16c
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/alloc/src/boxed.rs:1811:9
  27:     0x7f17cb4dae23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hef865a799f44aaf2
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/alloc/src/boxed.rs:1811:9
  28:     0x7f17cb4dae23 - std::sys::unix::thread::Thread::new::thread_start::hee0b2d4e2414fa96
                               at /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/library/std/src/sys/unix/thread.rs:108:17
  29:     0x7f17cb3e8259 - start_thread
  30:     0x7f17cb2fd5e3 - __GI___clone
  31:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

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.59.0-nightly (0b42deacc 2021-12-09) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
end of query stack

@Alexendoo
Copy link
Member

Good catch, the test case is slightly different to the one in glacier

--- glacier.rs 2021-12-09 22:59:25.365148200 +0000
+++ test.rs 2021-12-09 23:02:06.135999800 +0000
@@ -26,9 +26,10 @@

 impl<T: Type> Spec1 for T where Predicate<{T::AT::C > 0}>: Satisfied {}

-trait Spec2: Spec1 {}
+trait Spec2 {}

-impl<T: Type + Spec1> Spec2 for T where Predicate<{T::AT::C > 1}>: Satisfied {}
+//impl<T: Type > Spec2 for T where Predicate<{T::AT::C > 1}>: Satisfied {}
+impl<T: Type > Spec2 for T where Predicate<true>: Satisfied {}

 //--------------------------------------------------

@Alexendoo Alexendoo reopened this Dec 9, 2021
Alexendoo added a commit to Alexendoo/glacier that referenced this issue Dec 13, 2021
@apiraino apiraino removed the requires-nightly This issue requires a nightly compiler in some way. label Feb 3, 2022
@BoxyUwU BoxyUwU added F-generic_const_exprs `#![feature(generic_const_exprs)]` and removed F-const_generics `#![feature(const_generics)]` labels Jun 28, 2022
@lcnr
Copy link
Contributor

lcnr commented Jun 28, 2022

const generics triage.

This still causes an ICE with the following code.

#![feature(generic_const_exprs)]
#![feature(specialization)]
#![allow(incomplete_features)]

//--------------------------------------------------

trait Depth {
    const C: usize;
}

trait Type {
    type At: Depth;
}

//--------------------------------------------------

enum Predicate<const B: bool> {}

trait Satisfied {}

impl Satisfied for Predicate<true> {}

//--------------------------------------------------

trait Spec1 {}

impl<T: Type> Spec1 for T where Predicate<{ T::At::C > 0 }>: Satisfied {}

trait Spec2: Spec1 {}

impl<T: Type + Spec1> Spec2 for T where Predicate<{ T::At::C > 1 }>: Satisfied {}

//--------------------------------------------------

trait Foo {
    fn Bar();
}

impl<T: Spec1> Foo for T {
    default fn Bar() {}
}

impl<T: Spec2> Foo for T {
    fn Bar() {}
}

seems interesting, probably caused by rust-lang/project-const-generics#37

@Alexendoo
Copy link
Member

No longer ICEs since #108821, I would presume due to #108803

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 8, 2023
@matthiaskrgr
Copy link
Member

Test was added as const-generics/issues/issue-72845.rs , closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-test Call 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)]` F-specialization `#![feature(specialization)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

9 participants