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]: #![feature(const_closures)] inter crate ICE #106913

Closed
1 of 4 tasks
onestacked opened this issue Jan 15, 2023 · 0 comments · Fixed by #106917
Closed
1 of 4 tasks

[ICE]: #![feature(const_closures)] inter crate ICE #106913

onestacked opened this issue Jan 15, 2023 · 0 comments · Fixed by #106917
Assignees
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

@onestacked
Copy link
Contributor

onestacked commented Jan 15, 2023

Code

#![feature(const_closures)]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

/// This won't work since doc tests are in a different crate
/// ```rust
/// const _:() = playground::test();
/// ```
pub const fn test() {
    let cl = const || {};
    cl();
}
const _: () = {
    // Works in this crate
    test();
};

playground link need to use test, since the error happens in the doc-test.

Affected release channels

  • Previous Stable
  • Current Stable
  • Current Beta
  • Current Nightly

Rust Version

$ rustc --version --verbose 
rustc 1.68.0-nightly (afaf3e07a 2023-01-14)
binary: rustc
commit-hash: afaf3e07aaa7ca9873bdb439caec53faffa4230c
commit-date: 2023-01-14
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6

Current error output

No response

Backtrace

$ RUST_BACKTRACE=full cargo build
    Compiling consumer v0.1.0 (/home/chrisi/Documents/code/rust/const_cl_issue/consumer)
error: internal compiler error: compiler/rustc_const_eval/src/const_eval/machine.rs:390:21: trying to call extern function `test_fn::{closure#0}` at compile-time

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/compiler/rustc_errors/src/lib.rs:1609:9
stack backtrace:
   0:     0x7f0a0611061a - std::backtrace_rs::backtrace::libunwind::trace::h512c3d4bd0b3a708
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f0a0611061a - std::backtrace_rs::backtrace::trace_unsynchronized::hc58f6705328449a6
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0a0611061a - std::sys_common::backtrace::_print_fmt::hf8534206357dc715
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f0a0611061a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9ef691964aca459c
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f0a061738fe - core::fmt::write::h251b0a546065b34e
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/core/src/fmt/mod.rs:1213:17
   5:     0x7f0a06100af5 - std::io::Write::write_fmt::h08e6d5def8fea0af
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/io/mod.rs:1682:15
   6:     0x7f0a061103e5 - std::sys_common::backtrace::_print::h9a33e0b3ebce7bc7
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f0a061103e5 - std::sys_common::backtrace::print::hdece45cc6662dd34
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f0a061131af - std::panicking::default_hook::{{closure}}::ha9e20da088770535
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/panicking.rs:267:22
   9:     0x7f0a06112eeb - std::panicking::default_hook::hb2daa88547715b30
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/panicking.rs:286:9
  10:     0x7f0a04eb4ce4 - rustc_driver[71f72b4b3e1e11ff]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f0a061139ed - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h36ace50e589d0416
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/alloc/src/boxed.rs:2002:9
  12:     0x7f0a061139ed - std::panicking::rust_panic_with_hook::h75369ab7cb2d9b4d
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/panicking.rs:692:13
  13:     0x7f0a0541c3b1 - std[66e97b1d17fb0e75]::panicking::begin_panic::<rustc_errors[cf02776e207fbd3f]::ExplicitBug>::{closure#0}
  14:     0x7f0a054162e6 - std[66e97b1d17fb0e75]::sys_common::backtrace::__rust_end_short_backtrace::<std[66e97b1d17fb0e75]::panicking::begin_panic<rustc_errors[cf02776e207fbd3f]::ExplicitBug>::{closure#0}, !>
  15:     0x7f0a0547c2c6 - std[66e97b1d17fb0e75]::panicking::begin_panic::<rustc_errors[cf02776e207fbd3f]::ExplicitBug>
  16:     0x7f0a054162d6 - std[66e97b1d17fb0e75]::panic::panic_any::<rustc_errors[cf02776e207fbd3f]::ExplicitBug>
  17:     0x7f0a05412a36 - <rustc_errors[cf02776e207fbd3f]::HandlerInner>::bug::<&alloc[f4dba013d20c809a]::string::String>
  18:     0x7f0a05412680 - <rustc_errors[cf02776e207fbd3f]::Handler>::bug::<&alloc[f4dba013d20c809a]::string::String>
  19:     0x7f0a0544d2eb - rustc_middle[79283db49f8d0427]::util::bug::opt_span_bug_fmt::<rustc_span[9ef8f4f647bbaee9]::span_encoding::Span>::{closure#0}
  20:     0x7f0a0544acea - rustc_middle[79283db49f8d0427]::ty::context::tls::with_opt::<rustc_middle[79283db49f8d0427]::util::bug::opt_span_bug_fmt<rustc_span[9ef8f4f647bbaee9]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f0a0544acba - rustc_middle[79283db49f8d0427]::ty::context::tls::with_context_opt::<rustc_middle[79283db49f8d0427]::ty::context::tls::with_opt<rustc_middle[79283db49f8d0427]::util::bug::opt_span_bug_fmt<rustc_span[9ef8f4f647bbaee9]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f0a0544d236 - rustc_middle[79283db49f8d0427]::util::bug::opt_span_bug_fmt::<rustc_span[9ef8f4f647bbaee9]::span_encoding::Span>
  23:     0x7f0a03043083 - rustc_middle[79283db49f8d0427]::util::bug::bug_fmt
  24:     0x7f0a034cc151 - <rustc_const_eval[774bc52dbb2f1b86]::const_eval::machine::CompileTimeInterpreter as rustc_const_eval[774bc52dbb2f1b86]::interpret::machine::Machine>::find_mir_or_eval_fn
  25:     0x7f0a034c41e2 - <rustc_const_eval[774bc52dbb2f1b86]::interpret::eval_context::InterpCx<rustc_const_eval[774bc52dbb2f1b86]::const_eval::machine::CompileTimeInterpreter>>::eval_fn_call
  26:     0x7f0a034b8a22 - <rustc_const_eval[774bc52dbb2f1b86]::interpret::eval_context::InterpCx<rustc_const_eval[774bc52dbb2f1b86]::const_eval::machine::CompileTimeInterpreter>>::terminator
  27:     0x7f0a033fbbd5 - rustc_const_eval[774bc52dbb2f1b86]::const_eval::eval_queries::eval_to_allocation_raw_provider
  28:     0x7f0a04289d26 - <rustc_query_system[8bbb8596efba34ee]::dep_graph::graph::DepGraph<rustc_middle[79283db49f8d0427]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[79283db49f8d0427]::ty::context::TyCtxt, rustc_middle[79283db49f8d0427]::ty::ParamEnvAnd<rustc_middle[79283db49f8d0427]::mir::interpret::GlobalId>, core[4626b71cbccee52c]::result::Result<rustc_middle[79283db49f8d0427]::mir::interpret::value::ConstAlloc, rustc_middle[79283db49f8d0427]::mir::interpret::error::ErrorHandled>>
  29:     0x7f0a04288d23 - rustc_query_system[8bbb8596efba34ee]::query::plumbing::try_execute_query::<rustc_query_impl[a507f0846b381d35]::queries::eval_to_allocation_raw, rustc_query_impl[a507f0846b381d35]::plumbing::QueryCtxt>
  30:     0x7f0a0489f670 - <rustc_query_impl[a507f0846b381d35]::Queries as rustc_middle[79283db49f8d0427]::ty::query::QueryEngine>::eval_to_allocation_raw
  31:     0x7f0a033faf2c - rustc_const_eval[774bc52dbb2f1b86]::const_eval::eval_queries::eval_to_allocation_raw_provider
  32:     0x7f0a04289d26 - <rustc_query_system[8bbb8596efba34ee]::dep_graph::graph::DepGraph<rustc_middle[79283db49f8d0427]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[79283db49f8d0427]::ty::context::TyCtxt, rustc_middle[79283db49f8d0427]::ty::ParamEnvAnd<rustc_middle[79283db49f8d0427]::mir::interpret::GlobalId>, core[4626b71cbccee52c]::result::Result<rustc_middle[79283db49f8d0427]::mir::interpret::value::ConstAlloc, rustc_middle[79283db49f8d0427]::mir::interpret::error::ErrorHandled>>
  33:     0x7f0a04288d23 - rustc_query_system[8bbb8596efba34ee]::query::plumbing::try_execute_query::<rustc_query_impl[a507f0846b381d35]::queries::eval_to_allocation_raw, rustc_query_impl[a507f0846b381d35]::plumbing::QueryCtxt>
  34:     0x7f0a0489f670 - <rustc_query_impl[a507f0846b381d35]::Queries as rustc_middle[79283db49f8d0427]::ty::query::QueryEngine>::eval_to_allocation_raw
  35:     0x7f0a03d5ff6c - <rustc_const_eval[774bc52dbb2f1b86]::interpret::eval_context::InterpCx<rustc_mir_transform[db8c52948a9fa609]::const_prop::ConstPropMachine>>::eval_mir_constant
  36:     0x7f0a03cdd131 - <rustc_const_eval[774bc52dbb2f1b86]::interpret::eval_context::InterpCx<rustc_mir_transform[db8c52948a9fa609]::const_prop::ConstPropMachine>>::eval_rvalue_into_place
  37:     0x7f0a03d5c272 - <rustc_mir_transform[db8c52948a9fa609]::const_prop_lint::ConstPropagator as rustc_middle[79283db49f8d0427]::mir::visit::Visitor>::visit_body
  38:     0x7f0a03d52943 - <rustc_mir_transform[db8c52948a9fa609]::const_prop_lint::ConstProp as rustc_mir_transform[db8c52948a9fa609]::pass_manager::MirLint>::run_lint
  39:     0x7f0a04269c1d - rustc_mir_transform[db8c52948a9fa609]::run_analysis_to_runtime_passes
  40:     0x7f0a04268406 - rustc_mir_transform[db8c52948a9fa609]::mir_drops_elaborated_and_const_checked
  41:     0x7f0a03d4e6fb - <rustc_query_system[8bbb8596efba34ee]::dep_graph::graph::DepGraph<rustc_middle[79283db49f8d0427]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[79283db49f8d0427]::ty::context::TyCtxt, rustc_middle[79283db49f8d0427]::ty::WithOptConstParam<rustc_span[9ef8f4f647bbaee9]::def_id::LocalDefId>, &rustc_data_structures[402a9ad1e9c84e53]::steal::Steal<rustc_middle[79283db49f8d0427]::mir::Body>>
  42:     0x7f0a04267258 - rustc_query_system[8bbb8596efba34ee]::query::plumbing::try_execute_query::<rustc_query_impl[a507f0846b381d35]::queries::mir_drops_elaborated_and_const_checked, rustc_query_impl[a507f0846b381d35]::plumbing::QueryCtxt>
  43:     0x7f0a0375146c - rustc_mir_transform[db8c52948a9fa609]::optimized_mir
  44:     0x7f0a0374775d - <rustc_query_system[8bbb8596efba34ee]::dep_graph::graph::DepGraph<rustc_middle[79283db49f8d0427]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[79283db49f8d0427]::ty::context::TyCtxt, rustc_span[9ef8f4f647bbaee9]::def_id::DefId, &rustc_middle[79283db49f8d0427]::mir::Body>
  45:     0x7f0a036dcb66 - rustc_query_system[8bbb8596efba34ee]::query::plumbing::try_execute_query::<rustc_query_impl[a507f0846b381d35]::queries::optimized_mir, rustc_query_impl[a507f0846b381d35]::plumbing::QueryCtxt>
  46:     0x7f0a03ea4d7d - rustc_monomorphize[13e2005bf235e5f5]::collector::collect_neighbours
  47:     0x7f0a03ea0ca8 - rustc_monomorphize[13e2005bf235e5f5]::collector::collect_items_rec
  48:     0x7f0a0430a8bc - <rustc_session[7f238e9ee75769b4]::session::Session>::time::<(), rustc_monomorphize[13e2005bf235e5f5]::collector::collect_crate_mono_items::{closure#1}>
  49:     0x7f0a0430a3f4 - rustc_monomorphize[13e2005bf235e5f5]::collector::collect_crate_mono_items
  50:     0x7f0a04308803 - rustc_monomorphize[13e2005bf235e5f5]::partitioning::collect_and_partition_mono_items
  51:     0x7f0a04665309 - <rustc_query_system[8bbb8596efba34ee]::dep_graph::graph::DepGraph<rustc_middle[79283db49f8d0427]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[79283db49f8d0427]::ty::context::TyCtxt, (), (&std[66e97b1d17fb0e75]::collections::hash::set::HashSet<rustc_span[9ef8f4f647bbaee9]::def_id::DefId, core[4626b71cbccee52c]::hash::BuildHasherDefault<rustc_hash[6f43d7456684e806]::FxHasher>>, &[rustc_middle[79283db49f8d0427]::mir::mono::CodegenUnit])>
  52:     0x7f0a0466474e - rustc_query_system[8bbb8596efba34ee]::query::plumbing::try_execute_query::<rustc_query_impl[a507f0846b381d35]::queries::collect_and_partition_mono_items, rustc_query_impl[a507f0846b381d35]::plumbing::QueryCtxt>
  53:     0x7f0a048a6802 - <rustc_query_impl[a507f0846b381d35]::Queries as rustc_middle[79283db49f8d0427]::ty::query::QueryEngine>::collect_and_partition_mono_items
  54:     0x7f0a0437b83b - rustc_codegen_ssa[f6691ac6a032f9a0]::base::codegen_crate::<rustc_codegen_llvm[6c136c92f7b9054c]::LlvmCodegenBackend>
  55:     0x7f0a0437b5de - <rustc_codegen_llvm[6c136c92f7b9054c]::LlvmCodegenBackend as rustc_codegen_ssa[f6691ac6a032f9a0]::traits::backend::CodegenBackend>::codegen_crate
  56:     0x7f0a04120b21 - <rustc_session[7f238e9ee75769b4]::session::Session>::time::<alloc[f4dba013d20c809a]::boxed::Box<dyn core[4626b71cbccee52c]::any::Any>, rustc_interface[6094113d29eb86e9]::passes::start_codegen::{closure#0}>
  57:     0x7f0a04120649 - rustc_interface[6094113d29eb86e9]::passes::start_codegen
  58:     0x7f0a0411e712 - <rustc_interface[6094113d29eb86e9]::passes::QueryContext>::enter::<<rustc_interface[6094113d29eb86e9]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[4626b71cbccee52c]::result::Result<alloc[f4dba013d20c809a]::boxed::Box<dyn core[4626b71cbccee52c]::any::Any>, rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>>
  59:     0x7f0a0411b69d - <rustc_interface[6094113d29eb86e9]::queries::Queries>::ongoing_codegen
  60:     0x7f0a0411ac9c - <rustc_interface[6094113d29eb86e9]::interface::Compiler>::enter::<rustc_driver[71f72b4b3e1e11ff]::run_compiler::{closure#1}::{closure#2}, core[4626b71cbccee52c]::result::Result<core[4626b71cbccee52c]::option::Option<rustc_interface[6094113d29eb86e9]::queries::Linker>, rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>>
  61:     0x7f0a04118ad8 - rustc_span[9ef8f4f647bbaee9]::with_source_map::<core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>, rustc_interface[6094113d29eb86e9]::interface::run_compiler<core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>, rustc_driver[71f72b4b3e1e11ff]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  62:     0x7f0a041185b1 - <scoped_tls[ee0e75462fb264d1]::ScopedKey<rustc_span[9ef8f4f647bbaee9]::SessionGlobals>>::set::<rustc_interface[6094113d29eb86e9]::interface::run_compiler<core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>, rustc_driver[71f72b4b3e1e11ff]::run_compiler::{closure#1}>::{closure#0}, core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>>
  63:     0x7f0a04117b82 - std[66e97b1d17fb0e75]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6094113d29eb86e9]::util::run_in_thread_pool_with_globals<rustc_interface[6094113d29eb86e9]::interface::run_compiler<core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>, rustc_driver[71f72b4b3e1e11ff]::run_compiler::{closure#1}>::{closure#0}, core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>>
  64:     0x7f0a0411792c - <<std[66e97b1d17fb0e75]::thread::Builder>::spawn_unchecked_<rustc_interface[6094113d29eb86e9]::util::run_in_thread_pool_with_globals<rustc_interface[6094113d29eb86e9]::interface::run_compiler<core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>, rustc_driver[71f72b4b3e1e11ff]::run_compiler::{closure#1}>::{closure#0}, core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4626b71cbccee52c]::result::Result<(), rustc_errors[cf02776e207fbd3f]::ErrorGuaranteed>>::{closure#1} as core[4626b71cbccee52c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  65:     0x7f0a0611de23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h91fb73deba780d71
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/alloc/src/boxed.rs:1988:9
  66:     0x7f0a0611de23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h185b9ab8f9b92912
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/alloc/src/boxed.rs:1988:9
  67:     0x7f0a0611de23 - std::sys::unix::thread::Thread::new::thread_start::heddafa74acd4c9d3
                               at /rustc/afaf3e07aaa7ca9873bdb439caec53faffa4230c/library/std/src/sys/unix/thread.rs:108:17
  68:     0x7f0a01aae12d - start_thread
  69:     0x7f0a01b2fbc0 - clone3
  70:                0x0 - <unknown>

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.68.0-nightly (afaf3e07a 2023-01-14) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `main::{constant#0}`
#1 [eval_to_allocation_raw] const-evaluating + checking `main::{constant#0}`
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#3 [optimized_mir] optimizing MIR for `main`
#4 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `consumer`

Anything else?

This occures if you call a function that uses const_closures from another crate.

cc @fee1-dead

@onestacked onestacked 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 Jan 15, 2023
@compiler-errors compiler-errors self-assigned this Jan 15, 2023
@bors bors closed this as completed in a637e2a Jan 19, 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

Successfully merging a pull request may close this issue.

2 participants