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 fn in const trait #117478

Closed
beepster4096 opened this issue Nov 1, 2023 · 1 comment
Closed

ICE: const fn in const trait #117478

beepster4096 opened this issue Nov 1, 2023 · 1 comment
Labels
C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` F-effects `#![feature(effects)]` 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

@beepster4096
Copy link
Contributor

Code

#![feature(const_trait_impl, effects)]

#[const_trait]
trait X {
    const fn x();
}

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (9d83ac217 2023-10-31)

Error output

error[E0379]: functions in traits cannot be declared const
 --> src/lib.rs:5:5
  |
5 |     const fn x();
  |     ^^^^^ functions in traits cannot be const

error: internal compiler error: compiler/rustc_hir_analysis/src/collect/generics_of.rs:320:21: parent also has host effect param? index: 1, def: DefId(0:4 ~ playground[de24]::X::x)

thread 'rustc' panicked at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/compiler/rustc_errors/src/lib.rs:1661:9:
Box<dyn Any>

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 `/playground/rustc-ice-2023-11-01T04_35_53-19.txt` to your bug report

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:
#0 [generics_of] computing generics of `X::x`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0379`.
error: could not compile `playground` (lib) due to previous error
Backtrace

stack backtrace:
   0:     0x7f38294ebcfc - std::backtrace_rs::backtrace::libunwind::trace::h1c0d6c1feff90834
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f38294ebcfc - std::backtrace_rs::backtrace::trace_unsynchronized::he4dc4a997c5ae9a3
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f38294ebcfc - std::sys_common::backtrace::_print_fmt::h5a4f8cab839a8801
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f38294ebcfc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h633d15e63f261bac
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f382954df50 - core::fmt::rt::Argument::fmt::h7bd3372d26ac29ee
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/core/src/fmt/rt.rs:142:9
   5:     0x7f382954df50 - core::fmt::write::h81c224801dea0c8c
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/core/src/fmt/mod.rs:1117:17
   6:     0x7f38294dfc1f - std::io::Write::write_fmt::h5d5fd4c0f9d7aaa2
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/io/mod.rs:1763:15
   7:     0x7f38294ebae4 - std::sys_common::backtrace::_print::hae2beb76b35b9dac
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f38294ebae4 - std::sys_common::backtrace::print::hbc2e16b509b271b5
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f38294ee777 - std::panicking::default_hook::{{closure}}::hdd572dcbcaa64ada
  10:     0x7f38294ee4df - std::panicking::default_hook::h3f7cc4d3b39ae3db
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/panicking.rs:292:9
  11:     0x7f382c0644f0 - std[75c6166aa02c8cf6]::panicking::update_hook::<alloc[89c5f4ce44f84c28]::boxed::Box<rustc_driver_impl[8683beda356c97ae]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f38294eeeb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9679028235a1e1c1
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/alloc/src/boxed.rs:2021:9
  13:     0x7f38294eeeb8 - std::panicking::rust_panic_with_hook::hd2051524a5282492
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/panicking.rs:783:13
  14:     0x7f382c42e1f4 - std[75c6166aa02c8cf6]::panicking::begin_panic::<rustc_errors[4bb6c1fe0d8fa385]::ExplicitBug>::{closure#0}
  15:     0x7f382c420476 - std[75c6166aa02c8cf6]::sys_common::backtrace::__rust_end_short_backtrace::<std[75c6166aa02c8cf6]::panicking::begin_panic<rustc_errors[4bb6c1fe0d8fa385]::ExplicitBug>::{closure#0}, !>
  16:     0x7f382c410496 - std[75c6166aa02c8cf6]::panicking::begin_panic::<rustc_errors[4bb6c1fe0d8fa385]::ExplicitBug>
  17:     0x7f382c407c24 - <rustc_errors[4bb6c1fe0d8fa385]::HandlerInner>::bug::<alloc[89c5f4ce44f84c28]::string::String>
  18:     0x7f382c4079e4 - <rustc_errors[4bb6c1fe0d8fa385]::Handler>::bug::<alloc[89c5f4ce44f84c28]::string::String>
  19:     0x7f382c4a7d5d - rustc_middle[8603c91d0eb8a1dd]::util::bug::opt_span_bug_fmt::<rustc_span[83a6b6e41b66ef87]::span_encoding::Span>::{closure#0}
  20:     0x7f382c48fd3a - rustc_middle[8603c91d0eb8a1dd]::ty::context::tls::with_opt::<rustc_middle[8603c91d0eb8a1dd]::util::bug::opt_span_bug_fmt<rustc_span[83a6b6e41b66ef87]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f382c48fbd8 - rustc_middle[8603c91d0eb8a1dd]::ty::context::tls::with_context_opt::<rustc_middle[8603c91d0eb8a1dd]::ty::context::tls::with_opt<rustc_middle[8603c91d0eb8a1dd]::util::bug::opt_span_bug_fmt<rustc_span[83a6b6e41b66ef87]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f382a555060 - rustc_middle[8603c91d0eb8a1dd]::util::bug::bug_fmt
  23:     0x7f382b67f685 - rustc_hir_analysis[65b9152c651c7c9f]::collect::generics_of::generics_of
  24:     0x7f382d3c342c - rustc_query_impl[5e0ea37d46400eed]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5e0ea37d46400eed]::query_impl::generics_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8603c91d0eb8a1dd]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7f382d1e1245 - rustc_query_system[ef1bfe6a15550406]::query::plumbing::try_execute_query::<rustc_query_impl[5e0ea37d46400eed]::DynamicConfig<rustc_query_system[ef1bfe6a15550406]::query::caches::DefaultCache<rustc_span[83a6b6e41b66ef87]::def_id::DefId, rustc_middle[8603c91d0eb8a1dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5e0ea37d46400eed]::plumbing::QueryCtxt, false>
  26:     0x7f382d1823f5 - rustc_query_impl[5e0ea37d46400eed]::query_impl::generics_of::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7f382d4b1bc6 - <rustc_hir_analysis[65b9152c651c7c9f]::collect::CollectItemTypesVisitor as rustc_hir[a2a7d298548eea75]::intravisit::Visitor>::visit_trait_item
  28:     0x7f382d5d8fad - rustc_hir_analysis[65b9152c651c7c9f]::collect::collect_mod_item_types
  29:     0x7f382d5d8e7d - rustc_query_impl[5e0ea37d46400eed]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5e0ea37d46400eed]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8603c91d0eb8a1dd]::query::erase::Erased<[u8; 0usize]>>
  30:     0x7f382d9dbab4 - rustc_query_system[ef1bfe6a15550406]::query::plumbing::try_execute_query::<rustc_query_impl[5e0ea37d46400eed]::DynamicConfig<rustc_query_system[ef1bfe6a15550406]::query::caches::DefaultCache<rustc_span[83a6b6e41b66ef87]::def_id::LocalModDefId, rustc_middle[8603c91d0eb8a1dd]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[5e0ea37d46400eed]::plumbing::QueryCtxt, false>
  31:     0x7f382d9db583 - rustc_query_impl[5e0ea37d46400eed]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f382d66a626 - rustc_hir_analysis[65b9152c651c7c9f]::check_crate
  33:     0x7f382d9ca796 - rustc_interface[3a72e031d92d94c4]::passes::analysis
  34:     0x7f382d9ca1b5 - rustc_query_impl[5e0ea37d46400eed]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5e0ea37d46400eed]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8603c91d0eb8a1dd]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7f382dca6da6 - rustc_query_system[ef1bfe6a15550406]::query::plumbing::try_execute_query::<rustc_query_impl[5e0ea37d46400eed]::DynamicConfig<rustc_query_system[ef1bfe6a15550406]::query::caches::SingleCache<rustc_middle[8603c91d0eb8a1dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5e0ea37d46400eed]::plumbing::QueryCtxt, false>
  36:     0x7f382dca6bd5 - rustc_query_impl[5e0ea37d46400eed]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f382ded5ac3 - std[75c6166aa02c8cf6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3a72e031d92d94c4]::util::run_in_thread_with_globals<rustc_interface[3a72e031d92d94c4]::interface::run_compiler<core[b9f207e078deabe9]::result::Result<(), rustc_span[83a6b6e41b66ef87]::ErrorGuaranteed>, rustc_driver_impl[8683beda356c97ae]::run_compiler::{closure#1}>::{closure#0}, core[b9f207e078deabe9]::result::Result<(), rustc_span[83a6b6e41b66ef87]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b9f207e078deabe9]::result::Result<(), rustc_span[83a6b6e41b66ef87]::ErrorGuaranteed>>
  38:     0x7f382ded4d89 - <<std[75c6166aa02c8cf6]::thread::Builder>::spawn_unchecked_<rustc_interface[3a72e031d92d94c4]::util::run_in_thread_with_globals<rustc_interface[3a72e031d92d94c4]::interface::run_compiler<core[b9f207e078deabe9]::result::Result<(), rustc_span[83a6b6e41b66ef87]::ErrorGuaranteed>, rustc_driver_impl[8683beda356c97ae]::run_compiler::{closure#1}>::{closure#0}, core[b9f207e078deabe9]::result::Result<(), rustc_span[83a6b6e41b66ef87]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b9f207e078deabe9]::result::Result<(), rustc_span[83a6b6e41b66ef87]::ErrorGuaranteed>>::{closure#1} as core[b9f207e078deabe9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f38294f9c85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbb07097450ba441f
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/alloc/src/boxed.rs:2007:9
  40:     0x7f38294f9c85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1e066a6f7b5acdb1
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/alloc/src/boxed.rs:2007:9
  41:     0x7f38294f9c85 - std::sys::unix::thread::Thread::new::thread_start::h35349caae5713e8a
                               at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/library/std/src/sys/unix/thread.rs:108:17
  42:     0x7f38293ea609 - start_thread
  43:     0x7f382930d133 - clone
  44:                0x0 - <unknown>

@rustbot label F-const_trait_impl F-effects

@beepster4096 beepster4096 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 1, 2023
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-const_trait_impl `#![feature(const_trait_impl)]` F-effects `#![feature(effects)]` labels Nov 1, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 1, 2023
@fmease
Copy link
Member

fmease commented Jan 3, 2024

Closing as duplicate of #113378.
#119505 will fix this btw.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2024
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. F-const_trait_impl `#![feature(const_trait_impl)]` F-effects `#![feature(effects)]` 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