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

Compiler Crash due to generic_const_exprs Feature in Rust Code #117657

Closed
iamanonymouscs opened this issue Nov 7, 2023 · 1 comment
Closed

Compiler Crash due to generic_const_exprs Feature in Rust Code #117657

iamanonymouscs opened this issue Nov 7, 2023 · 1 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.

Comments

@iamanonymouscs
Copy link

Code

cat code.rs

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

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

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (189d6c71f 2023-11-06)
binary: rustc
commit-hash: 189d6c71f3bb6c52113b5639a80839791974fd22
commit-date: 2023-11-06
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.4

The same problem is reproduced on the stable version(1.73.0 cc66ad468 2023-10-03)

Error output

rustc code.rs

error: expected one of `(`, `.`, `;`, `?`, `}`, or an operator, found `::`
 --> code.rs:7:11
  |
7 |        A.A::B;
  |           ^^ expected one of `(`, `.`, `;`, `?`, `}`, or an operator

error[E0658]: associated const equality is incomplete
 --> code.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
 --> code.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
 --> code.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
 --> code.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`
 --> code.rs:3:3
  |
3 |   const A: TraitWAssocConst<A=0>;
  |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: ...which requires computing type of `TraitWAssocConst::A::{constant#0}`...
 --> code.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}`
 --> code.rs:6:31
  |
6 | fn main<A: TraitWAssocConst<A=32>>() {
  |                               ^^
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect/type_of.rs:83:22:
const parameter types cannot be generic
Backtrace

stack backtrace:
   0:     0x7f5bb99b8cfc - std::backtrace_rs::backtrace::libunwind::trace::hff25dccdeaecf15b
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f5bb99b8cfc - std::backtrace_rs::backtrace::trace_unsynchronized::ha0dc8dbc3408b60f
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5bb99b8cfc - std::sys_common::backtrace::_print_fmt::h67df50d94423ed2e
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f5bb99b8cfc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h79eed31df48d8984
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f5bb9a1af20 - core::fmt::rt::Argument::fmt::h99f50ac8e36e39f5
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/core/src/fmt/rt.rs:142:9
   5:     0x7f5bb9a1af20 - core::fmt::write::hb2ea303798b8ccb6
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/core/src/fmt/mod.rs:1117:17
   6:     0x7f5bb99acc1f - std::io::Write::write_fmt::he6c1d015443731fc
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/io/mod.rs:1763:15
   7:     0x7f5bb99b8ae4 - std::sys_common::backtrace::_print::h33ea8a0908bf5a83
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f5bb99b8ae4 - std::sys_common::backtrace::print::hb67f3e4f66b9e164
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f5bb99bb777 - std::panicking::default_hook::{{closure}}::h76dfdce76c22c872
  10:     0x7f5bb99bb4df - std::panicking::default_hook::hca996d901ebbad0a
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/panicking.rs:292:9
  11:     0x7f5bbc6f7080 - std[892e5142f41c14f3]::panicking::update_hook::<alloc[1d1cadd2b6a1e028]::boxed::Box<rustc_driver_impl[6b462800c963f7c4]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f5bb99bbeb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hdc5d28b909c48685
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/alloc/src/boxed.rs:2021:9
  13:     0x7f5bb99bbeb8 - std::panicking::rust_panic_with_hook::hf4c81c25ab4c6282
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/panicking.rs:783:13
  14:     0x7f5bb99bbc0e - std::panicking::begin_panic_handler::{{closure}}::h434d33c2a86a1a30
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/panicking.rs:657:13
  15:     0x7f5bb99b91c6 - std::sys_common::backtrace::__rust_end_short_backtrace::h960ab23f2fb70479
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7f5bb99bb972 - rust_begin_unwind
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/panicking.rs:645:5
  17:     0x7f5bb9a17645 - core::panicking::panic_fmt::h5f1a6fd39197ad62
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/core/src/panicking.rs:72:14
  18:     0x7f5bb9a173f3 - core::panicking::panic_display::h7c73698e4b0cd283
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/core/src/panicking.rs:178:5
  19:     0x7f5bb9a173f3 - core::panicking::panic_str::h3272a59bd2b54271
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/core/src/panicking.rs:152:5
  20:     0x7f5bb9a173f3 - core::option::expect_failed::h851fe49db086a7b3
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/core/src/option.rs:1985:5
  21:     0x7f5bbbbf7a57 - rustc_hir_analysis[8fdc5c642381ab7f]::collect::type_of::type_of
  22:     0x7f5bbd8d3376 - rustc_query_impl[ef19888a93dc8bb2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ef19888a93dc8bb2]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7f5bbd8d2218 - rustc_query_system[5665b56d10d6a1cd]::query::plumbing::try_execute_query::<rustc_query_impl[ef19888a93dc8bb2]::DynamicConfig<rustc_query_system[5665b56d10d6a1cd]::query::caches::DefaultCache<rustc_span[468fcca478faa92d]::def_id::DefId, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ef19888a93dc8bb2]::plumbing::QueryCtxt, false>
  24:     0x7f5bbd8d1deb - rustc_query_impl[ef19888a93dc8bb2]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f5bbd9f1905 - rustc_middle[636ce057eec11b97]::query::plumbing::query_get_at::<rustc_query_system[5665b56d10d6a1cd]::query::caches::DefaultCache<rustc_span[468fcca478faa92d]::def_id::DefId, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 8usize]>>>
  26:     0x7f5bbd9f2270 - <rustc_middle[636ce057eec11b97]::ty::consts::Const>::from_anon_const
  27:     0x7f5bbdc63eab - <dyn rustc_hir_analysis[8fdc5c642381ab7f]::astconv::AstConv>::instantiate_poly_trait_ref_inner
  28:     0x7f5bbdc5dbb6 - <dyn rustc_hir_analysis[8fdc5c642381ab7f]::astconv::AstConv>::instantiate_poly_trait_ref
  29:     0x7f5bbdc5ac70 - rustc_hir_analysis[8fdc5c642381ab7f]::collect::predicates_of::gather_explicit_predicates_of
  30:     0x7f5bbdc5827c - rustc_query_impl[ef19888a93dc8bb2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ef19888a93dc8bb2]::query_impl::explicit_predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 24usize]>>
  31:     0x7f5bbdc56cfe - rustc_query_system[5665b56d10d6a1cd]::query::plumbing::try_execute_query::<rustc_query_impl[ef19888a93dc8bb2]::DynamicConfig<rustc_query_system[5665b56d10d6a1cd]::query::caches::DefaultCache<rustc_span[468fcca478faa92d]::def_id::DefId, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[ef19888a93dc8bb2]::plumbing::QueryCtxt, false>
  32:     0x7f5bbdc569a0 - rustc_query_impl[ef19888a93dc8bb2]::query_impl::explicit_predicates_of::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7f5bbdc57858 - rustc_hir_analysis[8fdc5c642381ab7f]::collect::predicates_defined_on
  34:     0x7f5bbdc57715 - rustc_query_impl[ef19888a93dc8bb2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ef19888a93dc8bb2]::query_impl::predicates_defined_on::dynamic_query::{closure#2}::{closure#0}, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 24usize]>>
  35:     0x7f5bbdc56cd3 - rustc_query_system[5665b56d10d6a1cd]::query::plumbing::try_execute_query::<rustc_query_impl[ef19888a93dc8bb2]::DynamicConfig<rustc_query_system[5665b56d10d6a1cd]::query::caches::DefaultCache<rustc_span[468fcca478faa92d]::def_id::DefId, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[ef19888a93dc8bb2]::plumbing::QueryCtxt, false>
  36:     0x7f5bbdc567e0 - rustc_query_impl[ef19888a93dc8bb2]::query_impl::predicates_defined_on::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f5bbdc5575d - rustc_hir_analysis[8fdc5c642381ab7f]::collect::predicates_of::predicates_of
  38:     0x7f5bbdc55613 - rustc_query_impl[ef19888a93dc8bb2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ef19888a93dc8bb2]::query_impl::predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 24usize]>>
  39:     0x7f5bbdc56ca6 - rustc_query_system[5665b56d10d6a1cd]::query::plumbing::try_execute_query::<rustc_query_impl[ef19888a93dc8bb2]::DynamicConfig<rustc_query_system[5665b56d10d6a1cd]::query::caches::DefaultCache<rustc_span[468fcca478faa92d]::def_id::DefId, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[ef19888a93dc8bb2]::plumbing::QueryCtxt, false>
  40:     0x7f5bbdc568be - rustc_query_impl[ef19888a93dc8bb2]::query_impl::predicates_of::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f5bbdcfd1e0 - <rustc_hir_analysis[8fdc5c642381ab7f]::collect::CollectItemTypesVisitor as rustc_hir[18a94961780ac4d0]::intravisit::Visitor>::visit_item
  42:     0x7f5bbdcfb2a8 - rustc_hir_analysis[8fdc5c642381ab7f]::collect::collect_mod_item_types
  43:     0x7f5bbdcfb22b - rustc_query_impl[ef19888a93dc8bb2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ef19888a93dc8bb2]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 0usize]>>
  44:     0x7f5bbe0e16bb - rustc_query_system[5665b56d10d6a1cd]::query::plumbing::try_execute_query::<rustc_query_impl[ef19888a93dc8bb2]::DynamicConfig<rustc_query_system[5665b56d10d6a1cd]::query::caches::DefaultCache<rustc_span[468fcca478faa92d]::def_id::LocalModDefId, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ef19888a93dc8bb2]::plumbing::QueryCtxt, false>
  45:     0x7f5bbe0e11d7 - rustc_query_impl[ef19888a93dc8bb2]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  46:     0x7f5bbde6db5c - rustc_hir_analysis[8fdc5c642381ab7f]::check_crate
  47:     0x7f5bbdae5ed5 - rustc_interface[8114b1518d4bcee7]::passes::analysis
  48:     0x7f5bbdae5b37 - rustc_query_impl[ef19888a93dc8bb2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ef19888a93dc8bb2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 1usize]>>
  49:     0x7f5bbe514a80 - rustc_query_system[5665b56d10d6a1cd]::query::plumbing::try_execute_query::<rustc_query_impl[ef19888a93dc8bb2]::DynamicConfig<rustc_query_system[5665b56d10d6a1cd]::query::caches::SingleCache<rustc_middle[636ce057eec11b97]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ef19888a93dc8bb2]::plumbing::QueryCtxt, false>
  50:     0x7f5bbe514887 - rustc_query_impl[ef19888a93dc8bb2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  51:     0x7f5bbe80e9f3 - rustc_interface[8114b1518d4bcee7]::interface::run_compiler::<core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>, rustc_driver_impl[6b462800c963f7c4]::run_compiler::{closure#1}>::{closure#0}
  52:     0x7f5bbe83c20a - std[892e5142f41c14f3]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8114b1518d4bcee7]::util::run_in_thread_with_globals<rustc_interface[8114b1518d4bcee7]::util::run_in_thread_pool_with_globals<rustc_interface[8114b1518d4bcee7]::interface::run_compiler<core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>, rustc_driver_impl[6b462800c963f7c4]::run_compiler::{closure#1}>::{closure#0}, core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>>::{closure#0}, core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>>
  53:     0x7f5bbe83c033 - <<std[892e5142f41c14f3]::thread::Builder>::spawn_unchecked_<rustc_interface[8114b1518d4bcee7]::util::run_in_thread_with_globals<rustc_interface[8114b1518d4bcee7]::util::run_in_thread_pool_with_globals<rustc_interface[8114b1518d4bcee7]::interface::run_compiler<core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>, rustc_driver_impl[6b462800c963f7c4]::run_compiler::{closure#1}>::{closure#0}, core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>>::{closure#0}, core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[87cb3e20dc27822]::result::Result<(), rustc_span[468fcca478faa92d]::ErrorGuaranteed>>::{closure#1} as core[87cb3e20dc27822]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  54:     0x7f5bb99c6c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc46dd07e9684ac8f
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/alloc/src/boxed.rs:2007:9
  55:     0x7f5bb99c6c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5b941b8dbca1d60
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/alloc/src/boxed.rs:2007:9
  56:     0x7f5bb99c6c25 - std::sys::unix::thread::Thread::new::thread_start::h7b00b728bb6836be
                               at /rustc/189d6c71f3bb6c52113b5639a80839791974fd22/library/std/src/sys/unix/thread.rs:108:17
  57:     0x7f5bb98b6609 - start_thread
  58:     0x7f5bb97d9133 - clone
  59:                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: please attach the file at `/home/rustc-ice-2023-11-07T06_47_55-17512.txt` to your bug report

query stack during panic:
#0 [type_of] computing type of `main::{constant#0}`
#1 [explicit_predicates_of] computing explicit predicates of `main`
#2 [predicates_defined_on] computing predicates of `main`
#3 [predicates_of] computing predicates of `main`
#4 [collect_mod_item_types] collecting item types in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack

@iamanonymouscs iamanonymouscs 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 Nov 7, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 7, 2023
@matthiaskrgr
Copy link
Member

This is another duplicate of #108165

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 9, 2023
@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Nov 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

No branches or pull requests

4 participants