Skip to content

ice: ConstContext::Maybe must have host effect param #118320

Closed
@matthiaskrgr

Description

@matthiaskrgr

snippet:

#![feature(const_trait_impl, effects, const_closures)]

#[const_trait]
trait Bar {
    fn foo(&self);
}

impl Bar for () {}

const FOO: () = {
    (const || (()).foo())();
};

Version information

rustc 1.76.0-nightly (274b5249e 2023-11-26)
binary: rustc
commit-hash: 274b5249eb1014b441fd9fe45e9373111f61e413
commit-date: 2023-11-26
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: the feature `const_closures` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.ZHC68V1ZE721/rustc_testrunner_tmpdir_reporting.qR8mQeHw5hJg/mvce.rs:1:39
  |
1 | #![feature(const_trait_impl, effects, const_closures)]
  |                                       ^^^^^^^^^^^^^^
  |
  = note: see issue #106003 <https://github.com/rust-lang/rust/issues/106003> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.ZHC68V1ZE721/rustc_testrunner_tmpdir_reporting.qR8mQeHw5hJg/mvce.rs:12:3
   |
12 | };
   |   ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.ZHC68V1ZE721/rustc_testrunner_tmpdir_reporting.qR8mQeHw5hJg/mvce.rs`

error[E0046]: not all trait items implemented, missing: `foo`
 --> /tmp/icemaker_global_tempdir.ZHC68V1ZE721/rustc_testrunner_tmpdir_reporting.qR8mQeHw5hJg/mvce.rs:8:1
  |
5 |     fn foo(&self);
  |     -------------- `foo` from trait
...
8 | impl Bar for () {}
  | ^^^^^^^^^^^^^^^ missing `foo` in implementation

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/callee.rs:811:22:
ConstContext::Maybe must have host effect param
stack backtrace:
   0:     0x7fd9be78ba2c - std::backtrace_rs::backtrace::libunwind::trace::h539bf176b49ae5c0
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fd9be78ba2c - std::backtrace_rs::backtrace::trace_unsynchronized::ha87f604e4c600fb5
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fd9be78ba2c - std::sys_common::backtrace::_print_fmt::h3d91e31a40fde705
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fd9be78ba2c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h515b42f7ec091d92
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fd9be7dea70 - core::fmt::rt::Argument::fmt::h67f7e6850454b955
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/core/src/fmt/rt.rs:142:9
   5:     0x7fd9be7dea70 - core::fmt::write::hb8228e665a09880b
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fd9be77f8ef - std::io::Write::write_fmt::hf5f145ef3d12eac1
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/io/mod.rs:1766:15
   7:     0x7fd9be78b814 - std::sys_common::backtrace::_print::hc9513064d9c73570
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fd9be78b814 - std::sys_common::backtrace::print::hef54efa913309d43
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fd9be78e4a7 - std::panicking::default_hook::{{closure}}::ha043ef2d52041dbf
  10:     0x7fd9be78e20f - std::panicking::default_hook::hbc0daea43b530df9
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/panicking.rs:292:9
  11:     0x7fd9c14fc750 - std[2680136cbbb5bf0f]::panicking::update_hook::<alloc[9025ae9a72a943d7]::boxed::Box<rustc_driver_impl[f7ceb016d02b91be]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fd9be78ebe8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hee72af08d4de2a6a
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/alloc/src/boxed.rs:2021:9
  13:     0x7fd9be78ebe8 - std::panicking::rust_panic_with_hook::hf8bbe09d4a8f2d95
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/panicking.rs:783:13
  14:     0x7fd9be78e93e - std::panicking::begin_panic_handler::{{closure}}::h573d5262bfa46975
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/panicking.rs:657:13
  15:     0x7fd9be78bef6 - std::sys_common::backtrace::__rust_end_short_backtrace::h4a9cbf0bc1445cff
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fd9be78e6a2 - rust_begin_unwind
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/panicking.rs:645:5
  17:     0x7fd9be7db145 - core::panicking::panic_fmt::h346718e5e5394ab7
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/core/src/panicking.rs:72:14
  18:     0x7fd9be7daef3 - core::panicking::panic_display::hc3875928eb8ecb77
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/core/src/panicking.rs:193:5
  19:     0x7fd9be7daef3 - core::panicking::panic_str::h17d511952578074c
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/core/src/panicking.rs:168:5
  20:     0x7fd9be7daef3 - core::option::expect_failed::haecc795fadd51bbc
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/core/src/option.rs:1980:5
  21:     0x7fd9c29d8b05 - <rustc_hir_typeck[71550c55aa107b7e]::fn_ctxt::FnCtxt>::enforce_context_effects
  22:     0x7fd9c326029d - <rustc_hir_typeck[71550c55aa107b7e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:     0x7fd9c2c9e9d5 - rustc_hir_typeck[71550c55aa107b7e]::check::check_fn
  24:     0x7fd9c314bc2c - <rustc_hir_typeck[71550c55aa107b7e]::fn_ctxt::FnCtxt>::check_expr_closure
  25:     0x7fd9c32632a3 - <rustc_hir_typeck[71550c55aa107b7e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x7fd9c31e5713 - <rustc_hir_typeck[71550c55aa107b7e]::fn_ctxt::FnCtxt>::check_call
  27:     0x7fd9c325fdba - <rustc_hir_typeck[71550c55aa107b7e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7fd9c2e690f6 - <rustc_hir_typeck[71550c55aa107b7e]::fn_ctxt::FnCtxt>::check_block_with_expected
  29:     0x7fd9c3260149 - <rustc_hir_typeck[71550c55aa107b7e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x7fd9c2b146d7 - rustc_hir_typeck[71550c55aa107b7e]::typeck
  31:     0x7fd9c2b11d53 - rustc_query_impl[861d6ff9b596cf91]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[861d6ff9b596cf91]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[988d88f922ee50f3]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7fd9c2a4fb83 - rustc_query_system[b5ec17bcba2f6b95]::query::plumbing::try_execute_query::<rustc_query_impl[861d6ff9b596cf91]::DynamicConfig<rustc_query_system[b5ec17bcba2f6b95]::query::caches::VecCache<rustc_span[fff225364658b031]::def_id::LocalDefId, rustc_middle[988d88f922ee50f3]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[861d6ff9b596cf91]::plumbing::QueryCtxt, false>
  33:     0x7fd9c2a4f810 - rustc_query_impl[861d6ff9b596cf91]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7fd9c3485ef0 - rustc_hir_analysis[6e0da6c269b4a8ae]::check::check::check_mod_item_types
  35:     0x7fd9c3485939 - rustc_query_impl[861d6ff9b596cf91]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[861d6ff9b596cf91]::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[988d88f922ee50f3]::query::erase::Erased<[u8; 0usize]>>
  36:     0x7fd9c31b60fb - rustc_query_system[b5ec17bcba2f6b95]::query::plumbing::try_execute_query::<rustc_query_impl[861d6ff9b596cf91]::DynamicConfig<rustc_query_system[b5ec17bcba2f6b95]::query::caches::DefaultCache<rustc_span[fff225364658b031]::def_id::LocalModDefId, rustc_middle[988d88f922ee50f3]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[861d6ff9b596cf91]::plumbing::QueryCtxt, false>
  37:     0x7fd9c31b5ad7 - rustc_query_impl[861d6ff9b596cf91]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7fd9c2abb2a3 - rustc_hir_analysis[6e0da6c269b4a8ae]::check_crate
  39:     0x7fd9c32f6557 - rustc_interface[39842403410753fd]::passes::analysis
  40:     0x7fd9c32f61b7 - rustc_query_impl[861d6ff9b596cf91]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[861d6ff9b596cf91]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[988d88f922ee50f3]::query::erase::Erased<[u8; 1usize]>>
  41:     0x7fd9c37704c0 - rustc_query_system[b5ec17bcba2f6b95]::query::plumbing::try_execute_query::<rustc_query_impl[861d6ff9b596cf91]::DynamicConfig<rustc_query_system[b5ec17bcba2f6b95]::query::caches::SingleCache<rustc_middle[988d88f922ee50f3]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[861d6ff9b596cf91]::plumbing::QueryCtxt, false>
  42:     0x7fd9c37702c7 - rustc_query_impl[861d6ff9b596cf91]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:     0x7fd9c35d8245 - rustc_interface[39842403410753fd]::interface::run_compiler::<core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>, rustc_driver_impl[f7ceb016d02b91be]::run_compiler::{closure#0}>::{closure#0}
  44:     0x7fd9c37810d4 - std[2680136cbbb5bf0f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[39842403410753fd]::util::run_in_thread_with_globals<rustc_interface[39842403410753fd]::util::run_in_thread_pool_with_globals<rustc_interface[39842403410753fd]::interface::run_compiler<core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>, rustc_driver_impl[f7ceb016d02b91be]::run_compiler::{closure#0}>::{closure#0}, core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>>::{closure#0}, core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>>
  45:     0x7fd9c3780efd - <<std[2680136cbbb5bf0f]::thread::Builder>::spawn_unchecked_<rustc_interface[39842403410753fd]::util::run_in_thread_with_globals<rustc_interface[39842403410753fd]::util::run_in_thread_pool_with_globals<rustc_interface[39842403410753fd]::interface::run_compiler<core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>, rustc_driver_impl[f7ceb016d02b91be]::run_compiler::{closure#0}>::{closure#0}, core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>>::{closure#0}, core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8f96a9fac2f2289c]::result::Result<(), rustc_span[fff225364658b031]::ErrorGuaranteed>>::{closure#1} as core[8f96a9fac2f2289c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x7fd9be798a85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd581ca496c6c0298
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/alloc/src/boxed.rs:2007:9
  47:     0x7fd9be798a85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5516286e345b4033
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/alloc/src/boxed.rs:2007:9
  48:     0x7fd9be798a85 - std::sys::unix::thread::Thread::new::thread_start::he6cf2f99448984d8
                               at /rustc/274b5249eb1014b441fd9fe45e9373111f61e413/library/std/src/sys/unix/thread.rs:108:17
  49:     0x7fd9be5899eb - <unknown>
  50:     0x7fd9be60d7cc - <unknown>
  51:                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.76.0-nightly (274b5249e 2023-11-26) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `FOO`
#1 [check_mod_item_types] checking item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

Some errors have detailed explanations: E0046, E0601.
For more information about an error, try `rustc --explain E0046`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-const_closures`#![feature(const_closures)]`F-const_trait_impl`#![feature(const_trait_impl)]`F-effects`#![feature(effects)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions