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 parameter types cannot be generic, generic_const_exprs #108165

Closed
matthiaskrgr opened this issue Feb 17, 2023 · 6 comments
Closed

ICE const parameter types cannot be generic, generic_const_exprs #108165

matthiaskrgr opened this issue Feb 17, 2023 · 6 comments
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Feb 17, 2023

Code

#![feature(generic_const_exprs)]
pub trait TraitWAssocConst {
  const A: TraitWAssocConst<A=0>;
}

fn main<A: TraitWAssocConst<A=32>>() {
  TraitWAssocConst<A=0>:: TraitWAssocConst<A=32> ();
}

Meta

rustc --version --verbose:

<version>

Error output

binary: rustc
commit-hash: f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3
commit-date: 2023-02-17
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7
Backtrace

error: comparison operators cannot be chained
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:7:23
  |
7 |   TraitWAssocConst<A=0>:: TraitWAssocConst<A=32> ();
  |                       ^                   ^

error[E0423]: expected value, found trait `TraitWAssocConst`
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:7:3
  |
7 |   TraitWAssocConst<A=0>:: TraitWAssocConst<A=32> ();
  |   ^^^^^^^^^^^^^^^^ not a value

error[E0423]: expected value, found type parameter `A`
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:7:20
  |
6 | fn main<A: TraitWAssocConst<A=32>>() {
  |         - found this type parameter
7 |   TraitWAssocConst<A=0>:: TraitWAssocConst<A=32> ();
  |                    ^ not a value

error[E0423]: expected value, found trait `TraitWAssocConst`
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:7:24
  |
7 |   TraitWAssocConst<A=0>:: TraitWAssocConst<A=32> ();
  |                        ^^^^^^^^^^^^^^^^^^^ not a value

error[E0423]: expected value, found type parameter `A`
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:7:44
  |
6 | fn main<A: TraitWAssocConst<A=32>>() {
  |         - found this type parameter
7 |   TraitWAssocConst<A=0>:: TraitWAssocConst<A=32> ();
  |                                            ^ not a value

error[E0658]: associated const equality is incomplete
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:3:29
  |
3 |   const A: TraitWAssocConst<A=0>;
  |                             ^^^
  |
  = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
  = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable

error[E0658]: associated const equality is incomplete
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:6:29
  |
6 | fn main<A: TraitWAssocConst<A=32>>() {
  |                             ^^^^
  |
  = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
  = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: trait objects without an explicit `dyn` are deprecated
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:3:12
  |
3 |   const A: TraitWAssocConst<A=0>;
  |            ^^^^^^^^^^^^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: use `dyn`
  |
3 |   const A: dyn TraitWAssocConst<A=0>;
  |            +++

error[E0391]: cycle detected when computing type of `TraitWAssocConst::A`
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:3:3
  |
3 |   const A: TraitWAssocConst<A=0>;
  |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: ...which requires computing type of `TraitWAssocConst::A::{constant#0}`...
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:3:31
  |
3 |   const A: TraitWAssocConst<A=0>;
  |                               ^
  = note: ...which again requires computing type of `TraitWAssocConst::A`, completing the cycle
note: cycle used when computing type of `main::{constant#0}`
 --> 692a8d4b478d8831cf921c7a69c2c613a807ed73.rs:6:31
  |
6 | fn main<A: TraitWAssocConst<A=32>>() {
  |                               ^^

thread 'rustc' panicked at 'const parameter types cannot be generic', compiler/rustc_middle/src/ty/consts.rs:79:14
stack backtrace:
   0:     0x7fed11f6aa5a - std::backtrace_rs::backtrace::libunwind::trace::hebe09041f884c65d
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fed11f6aa5a - std::backtrace_rs::backtrace::trace_unsynchronized::h546f6c63cbbce5a9
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fed11f6aa5a - std::sys_common::backtrace::_print_fmt::h2559cb0cfed7a617
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fed11f6aa5a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1fb4eaaaafa2d72a
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fed11fca9ae - core::fmt::write::hbaef4432b3c9d07b
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/core/src/fmt/mod.rs:1232:17
   5:     0x7fed11f5ae05 - std::io::Write::write_fmt::h1f8dce362441faaa
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/io/mod.rs:1684:15
   6:     0x7fed11f6a825 - std::sys_common::backtrace::_print::hc0e92ab849a4f4e1
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fed11f6a825 - std::sys_common::backtrace::print::h878cd11684ebdec3
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fed11f6d59f - std::panicking::default_hook::{{closure}}::h2ea8a6875aa6312d
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/panicking.rs:267:22
   9:     0x7fed11f6d2db - std::panicking::default_hook::h9e42277a84072188
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/panicking.rs:286:9
  10:     0x7fed1526e7b4 - <rustc_driver_impl[afa3c304d692170b]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[ebab21900c9c0a2]::ops::function::FnOnce<(&core[ebab21900c9c0a2]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7fed11f6dddd - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2c34f129ed413128
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/alloc/src/boxed.rs:2002:9
  12:     0x7fed11f6dddd - std::panicking::rust_panic_with_hook::h4c799b8c4fc0a70b
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/panicking.rs:692:13
  13:     0x7fed11f6db59 - std::panicking::begin_panic_handler::{{closure}}::h91f35d20f5c22591
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/panicking.rs:579:13
  14:     0x7fed11f6aec6 - std::sys_common::backtrace::__rust_end_short_backtrace::hcc464c7f8476de7c
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7fed11f6d862 - rust_begin_unwind
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/panicking.rs:575:5
  16:     0x7fed11fc7353 - core::panicking::panic_fmt::hea21d570c6a5058a
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/core/src/panicking.rs:64:14
  17:     0x7fed11fc74c1 - core::panicking::panic_display::h671d86309aadcfbd
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/core/src/panicking.rs:147:5
  18:     0x7fed11fc746b - core::panicking::panic_str::h4d2e9b19fe17b3b5
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/core/src/panicking.rs:131:5
  19:     0x7fed11fc70d6 - core::option::expect_failed::ha7447694ffe28900
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/core/src/option.rs:1926:5
  20:     0x7fed1433313b - <rustc_middle[6caff671bb338453]::ty::consts::Const>::from_opt_const_arg_anon_const
  21:     0x7fed145a1a9b - <core[ebab21900c9c0a2]::iter::adapters::map::Map<core[ebab21900c9c0a2]::slice::iter::Iter<rustc_hir[f4a2ff38696703b5]::hir::TypeBinding>, <dyn rustc_hir_analysis[257f64c795d1d076]::astconv::AstConv>::create_assoc_bindings_for_generic_args::{closure#0}> as core[ebab21900c9c0a2]::iter::traits::iterator::Iterator>::fold::<(), core[ebab21900c9c0a2]::iter::traits::iterator::Iterator::for_each::call<rustc_hir_analysis[257f64c795d1d076]::astconv::ConvertedBinding, <alloc[d840872249f3dc84]::vec::Vec<rustc_hir_analysis[257f64c795d1d076]::astconv::ConvertedBinding>>::extend_trusted<core[ebab21900c9c0a2]::iter::adapters::map::Map<core[ebab21900c9c0a2]::slice::iter::Iter<rustc_hir[f4a2ff38696703b5]::hir::TypeBinding>, <dyn rustc_hir_analysis[257f64c795d1d076]::astconv::AstConv>::create_assoc_bindings_for_generic_args::{closure#0}>>::{closure#0}>::{closure#0}>
  22:     0x7fed1459d627 - <dyn rustc_hir_analysis[257f64c795d1d076]::astconv::AstConv>::instantiate_poly_trait_ref_inner
  23:     0x7fed1459c017 - <dyn rustc_hir_analysis[257f64c795d1d076]::astconv::AstConv>::instantiate_poly_trait_ref
  24:     0x7fed135b98ff - rustc_hir_analysis[257f64c795d1d076]::collect::predicates_of::gather_explicit_predicates_of
  25:     0x7fed13eea8bd - rustc_query_system[5ff89444bbfc32f5]::query::plumbing::get_query::<rustc_query_impl[ef929ccf3c28623b]::queries::explicit_predicates_of, rustc_query_impl[ef929ccf3c28623b]::plumbing::QueryCtxt, rustc_middle[6caff671bb338453]::dep_graph::dep_node::DepKind>
  26:     0x7fed13db2bf0 - rustc_hir_analysis[257f64c795d1d076]::collect::predicates_of::predicates_of
  27:     0x7fed13dafc9c - rustc_query_system[5ff89444bbfc32f5]::query::plumbing::get_query::<rustc_query_impl[ef929ccf3c28623b]::queries::predicates_of, rustc_query_impl[ef929ccf3c28623b]::plumbing::QueryCtxt, rustc_middle[6caff671bb338453]::dep_graph::dep_node::DepKind>
  28:     0x7fed13daf913 - <rustc_query_impl[ef929ccf3c28623b]::Queries as rustc_middle[6caff671bb338453]::ty::query::QueryEngine>::predicates_of
  29:     0x7fed138d6135 - <rustc_hir_analysis[257f64c795d1d076]::collect::CollectItemTypesVisitor as rustc_hir[f4a2ff38696703b5]::intravisit::Visitor>::visit_item
  30:     0x7fed138d4e75 - <rustc_middle[6caff671bb338453]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis[257f64c795d1d076]::collect::CollectItemTypesVisitor>
  31:     0x7fed138d4d8c - rustc_hir_analysis[257f64c795d1d076]::collect::collect_mod_item_types
  32:     0x7fed1482f67f - rustc_query_system[5ff89444bbfc32f5]::query::plumbing::try_execute_query::<rustc_query_impl[ef929ccf3c28623b]::queries::collect_mod_item_types, rustc_query_impl[ef929ccf3c28623b]::plumbing::QueryCtxt>
  33:     0x7fed14c6e50d - <rustc_query_impl[ef929ccf3c28623b]::Queries as rustc_middle[6caff671bb338453]::ty::query::QueryEngine>::collect_mod_item_types
  34:     0x7fed137129dd - <rustc_middle[6caff671bb338453]::hir::map::Map>::for_each_module::<rustc_hir_analysis[257f64c795d1d076]::check_crate::{closure#0}::{closure#0}::{closure#0}>
  35:     0x7fed1371056c - rustc_hir_analysis[257f64c795d1d076]::check_crate
  36:     0x7fed13706062 - rustc_interface[686dab9608bc6033]::passes::analysis
  37:     0x7fed14a63d92 - rustc_query_system[5ff89444bbfc32f5]::query::plumbing::try_execute_query::<rustc_query_impl[ef929ccf3c28623b]::queries::analysis, rustc_query_impl[ef929ccf3c28623b]::plumbing::QueryCtxt>
  38:     0x7fed14c67e2a - <rustc_query_impl[ef929ccf3c28623b]::Queries as rustc_middle[6caff671bb338453]::ty::query::QueryEngine>::analysis
  39:     0x7fed14480303 - <rustc_interface[686dab9608bc6033]::queries::QueryResult<&rustc_middle[6caff671bb338453]::ty::context::GlobalCtxt>>::enter::<core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>, rustc_driver_impl[afa3c304d692170b]::run_compiler::{closure#1}::{closure#2}::{closure#3}>
  40:     0x7fed1447f4d4 - <rustc_interface[686dab9608bc6033]::interface::Compiler>::enter::<rustc_driver_impl[afa3c304d692170b]::run_compiler::{closure#1}::{closure#2}, core[ebab21900c9c0a2]::result::Result<core[ebab21900c9c0a2]::option::Option<rustc_interface[686dab9608bc6033]::queries::Linker>, rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>>
  41:     0x7fed1447a6f4 - rustc_span[1010a352e5466fad]::with_source_map::<core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>, rustc_interface[686dab9608bc6033]::interface::run_compiler<core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>, rustc_driver_impl[afa3c304d692170b]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  42:     0x7fed1447a204 - <scoped_tls[d487b98c36b0d138]::ScopedKey<rustc_span[1010a352e5466fad]::SessionGlobals>>::set::<rustc_interface[686dab9608bc6033]::interface::run_compiler<core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>, rustc_driver_impl[afa3c304d692170b]::run_compiler::{closure#1}>::{closure#0}, core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>>
  43:     0x7fed14479902 - std[dc63ca99f82ce43d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[686dab9608bc6033]::util::run_in_thread_pool_with_globals<rustc_interface[686dab9608bc6033]::interface::run_compiler<core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>, rustc_driver_impl[afa3c304d692170b]::run_compiler::{closure#1}>::{closure#0}, core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>>
  44:     0x7fed144796ac - <<std[dc63ca99f82ce43d]::thread::Builder>::spawn_unchecked_<rustc_interface[686dab9608bc6033]::util::run_in_thread_pool_with_globals<rustc_interface[686dab9608bc6033]::interface::run_compiler<core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>, rustc_driver_impl[afa3c304d692170b]::run_compiler::{closure#1}>::{closure#0}, core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ebab21900c9c0a2]::result::Result<(), rustc_errors[faa449d960b5ce55]::ErrorGuaranteed>>::{closure#1} as core[ebab21900c9c0a2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7fed11f77c63 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9fd36c4a0ba5b15d
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/alloc/src/boxed.rs:1988:9
  46:     0x7fed11f77c63 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd37d267854c7434f
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/alloc/src/boxed.rs:1988:9
  47:     0x7fed11f77c63 - std::sys::unix::thread::Thread::new::thread_start::h1ff24d5a09f2a8be
                               at /rustc/f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7fed11d07bb5 - <unknown>
  49:     0x7fed11d89d90 - <unknown>
  50:                0x0 - <unknown>

error: 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.69.0-nightly (f4f5fc3e5 2023-02-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [explicit_predicates_of] computing explicit predicates of `main`
#1 [predicates_defined_on] computing predicates of `main`
#2 [predicates_of] computing predicates of `main`
#3 [collect_mod_item_types] collecting item types in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 8 previous errors; 2 warnings emitted

Some errors have detailed explanations: E0391, E0423, E0658.
For more information about an error, try `rustc --explain E0391`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels Feb 17, 2023
@kylematsuda
Copy link
Contributor

This is from #107753, we added expect("const parameter types cannot be generic") there.

@rustbot claim

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 20, 2023

closing this in favor of #108271

@BoxyUwU
Copy link
Member

BoxyUwU commented Nov 7, 2023

@matthiaskrgr ?

@compiler-errors
Copy link
Member

Unclear why this PR was re-opened when this issue is already being tracked in #108271. Feel free to augment that issue with additional information if you find that one hard to search for when looking for pre-existing ICEs, since I really don't think we need to have two main issues for the same GCE ICE.

@compiler-errors compiler-errors closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
@matthiaskrgr
Copy link
Member Author

Sorry, why was #108271 opened after #108165 already tracked #108165 ?
It seems we do not need to willingly create duplicates?

#117657 was opened so it seems that #108271 is lacking details or discoverability?

@matthiaskrgr
Copy link
Member Author

@BoxyUwU ? any explanation?

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) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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.

4 participants