rust-lang/rust

ICE: "bad closure kind" with -Zchalk

matthiaskrgr opened this issue · 2 comments

Code

fn foo<F, G>(_: G, _: Box<F>)
    where
        F: Fn(),
        G: Fn(Box<F>),
{
}

fn main() {
    foo(|f| (*f)(), Box::new(|| {}));
}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (1f5bc176b 2020-12-19)
binary: rustc
commit-hash: 1f5bc176b0e54a8e464704adcd7e571700207fe9
commit-date: 2020-12-19
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

error: internal compiler error: compiler/rustc_traits/src/chalk/db.rs:576:18: bad closure kind

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:958:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.50.0-nightly (1f5bc176b 2020-12-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z chalk=yes

query stack during panic:
#0 [evaluate_goal] evaluating trait selection obligation `environment: [], goal: [closure@./68025.rs:11:30: 11:35]: std::ops::Fn<()>`
#1 [typeck] type-checking `main`
end of query stack
error: aborting due to previous error

Backtrace

error: internal compiler error: compiler/rustc_traits/src/chalk/db.rs:576:18: bad closure kind

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:958:9
stack backtrace:
   0:     0x7f906b15f6c7 - std::backtrace_rs::backtrace::libunwind::trace::h746c3e9529d524bc
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f906b15f6c7 - std::backtrace_rs::backtrace::trace_unsynchronized::h84373278bfb39e0c
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f906b15f6c7 - std::sys_common::backtrace::_print_fmt::h517324efde750597
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f906b15f6c7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf594ab77fac89284
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f906b1d028c - core::fmt::write::h3868db8542c90941
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f906b151592 - std::io::Write::write_fmt::h3f6656f045fa877f
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/io/mod.rs:1519:15
   6:     0x7f906b1633b5 - std::sys_common::backtrace::_print::hda7655c057c24dcc
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f906b1633b5 - std::sys_common::backtrace::print::h546a6c8431d46287
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f906b1633b5 - std::panicking::default_hook::{{closure}}::h006dd083853faf51
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/panicking.rs:208:50
   9:     0x7f906b162f0a - std::panicking::default_hook::hf0f9afb1017317fc
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/panicking.rs:225:9
  10:     0x7f906ba03ea8 - rustc_driver::report_ice::h956234bae73e460f
  11:     0x7f906b163cb6 - std::panicking::rust_panic_with_hook::hb7a19826c029b1d6
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/panicking.rs:595:17
  12:     0x7f906ebeb2ad - std::panicking::begin_panic::{{closure}}::he3ac55d11a883a10
  13:     0x7f906ebeb166 - std::sys_common::backtrace::__rust_end_short_backtrace::h4402bc3ed558879b
  14:     0x7f906ebeb24f - std::panicking::begin_panic::hd2137c659c375844
  15:     0x7f906ec26b2c - rustc_errors::HandlerInner::bug::hbfb11e3c8ba1475f
  16:     0x7f906ec25240 - rustc_errors::Handler::bug::ha00f48e1291906a1
  17:     0x7f906e4e31a4 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::h08c1bd52850a380c
  18:     0x7f906e4dd1cb - rustc_middle::ty::context::tls::with_opt::{{closure}}::h82c056b7e0ea907f
  19:     0x7f906e4dd172 - rustc_middle::ty::context::tls::with_opt::h001ea91e9a6c9bc0
  20:     0x7f906e4e30c3 - rustc_middle::util::bug::opt_span_bug_fmt::h033dd7c3ae8939b2
  21:     0x7f906e4e3035 - rustc_middle::util::bug::bug_fmt::hededfcfaf49f2715
  22:     0x7f906c220bfa - <rustc_traits::chalk::db::RustIrDatabase as chalk_solve::RustIrDatabase<rustc_middle::traits::chalk::RustInterner>>::closure_kind::he2dc82cdbdcdf8bf
  23:     0x7f906c2222b3 - chalk_solve::clauses::builtin_traits::fn_family::add_fn_trait_program_clauses::h28ca827544f4864c
  24:     0x7f906c1e6e37 - chalk_solve::clauses::builder::ClauseBuilder<I>::push_binders::hdfbf0f07f0d86844
  25:     0x7f906c19a80c - chalk_solve::clauses::builtin_traits::add_builtin_program_clauses::h4c0d9a30db59f66a
  26:     0x7f906c11f10b - chalk_solve::clauses::program_clauses_for_goal::h615fb6542c32cb7b
  27:     0x7f906c15e4a0 - chalk_engine::logic::<impl chalk_engine::forest::Forest<I>>::get_or_create_table_for_ucanonical_goal::h05999f9311e9d45e
  28:     0x7f906c15db2f - chalk_engine::logic::<impl chalk_engine::forest::Forest<I>>::get_or_create_table_for_subgoal::h8e2d78e08efe86b8
  29:     0x7f906c136a77 - chalk_engine::logic::SolveState<I>::ensure_root_answer::hff151791e705e93d
  30:     0x7f906c15d0e4 - chalk_engine::logic::<impl chalk_engine::forest::Forest<I>>::root_answer::h80a720555ce8796f
  31:     0x7f906c1563b0 - <chalk_engine::forest::ForestSolver<I> as chalk_engine::context::AnswerStream<I>>::next_answer::hd07061f74fea59d4
  32:     0x7f906c1007d1 - <chalk_engine::slg::SlgContextOps<I> as chalk_engine::slg::aggregate::AggregateOps<I>>::make_solution::hd330c485590054aa
  33:     0x7f906c210516 - rustc_traits::chalk::evaluate_goal::h3515e9f316a1d24d
  34:     0x7f906df3408d - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::evaluate_goal>::compute::hffab509853e7ade9
  35:     0x7f906df28119 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::he2591b096e0705ae
  36:     0x7f906e0d4a06 - rustc_data_structures::stack::ensure_sufficient_stack::ha9d3a74bc64064d5
  37:     0x7f906e02011b - rustc_query_system::query::plumbing::get_query_impl::h17d1ab4c0e23dbd7
  38:     0x7f906df3e11c - <rustc_trait_selection::traits::chalk_fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_where_possible::h63cd36b5725dbb7f
  39:     0x7f906c4db5c2 - rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types::h5a3e6ce214e904ff
  40:     0x7f906c4b89e5 - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::confirm_builtin_call::hac16eb2ffb22a3da
  41:     0x7f906c4b6e37 - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call::h6b43d4bf49a1c6d1
  42:     0x7f906c4c7d56 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind::h952c9183bf0a6926
  43:     0x7f906c4c70c0 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::hdb6305cef7e5d5d1
  44:     0x7f906c4dea8e - rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt::h6d70c98c4c310604
  45:     0x7f906c4df12b - rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected::h57ae167f297cad77
  46:     0x7f906c4c7d31 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind::h952c9183bf0a6926
  47:     0x7f906c4c70c0 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::hdb6305cef7e5d5d1
  48:     0x7f906c4cf4da - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr::h7e36ea2b790911a7
  49:     0x7f906c53d429 - rustc_typeck::check::check::check_fn::h56362012704dbdf9
  50:     0x7f906c73afc4 - rustc_infer::infer::InferCtxtBuilder::enter::h0f11bf20abd1f91e
  51:     0x7f906c7927d8 - rustc_typeck::check::typeck::he1f651e041999a8d
  52:     0x7f906c6ab1ae - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute::h236ed4f2969075ba
  53:     0x7f906c66e34b - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h1d0f714dc6d529cb
  54:     0x7f906c5c793b - rustc_data_structures::stack::ensure_sufficient_stack::h82018a71e7fa9f0d
  55:     0x7f906c7b3f1a - rustc_query_system::query::plumbing::get_query_impl::h18f331b7ec70e4b4
  56:     0x7f906c81f5ed - rustc_query_system::query::plumbing::ensure_query_impl::ha852f7223b1ec7d9
  57:     0x7f906c796e26 - rustc_typeck::check::typeck_item_bodies::ha4b16632095938e0
  58:     0x7f906c645dce - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute::h9342c3449d07cf76
  59:     0x7f906c677f54 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h6c2c72f45fddec21
  60:     0x7f906c5c94e6 - rustc_data_structures::stack::ensure_sufficient_stack::ha65e6ee31ff2fa0c
  61:     0x7f906c7b93a4 - rustc_query_system::query::plumbing::get_query_impl::h1b9b207a49d17777
  62:     0x7f906c6d1c21 - rustc_typeck::check_crate::h0ef907d13e9924da
  63:     0x7f906bc7f892 - rustc_interface::passes::analysis::h1277a6a22a164c98
  64:     0x7f906ba5f19b - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::he772285573dcf530
  65:     0x7f906ba4758d - rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}::haf660f8b5fc0a8b6
  66:     0x7f906b9df3d1 - rustc_query_system::query::plumbing::get_query_impl::h9637293c1f2da416
  67:     0x7f906ba6430f - rustc_interface::passes::QueryContext::enter::h33139460b088ed05
  68:     0x7f906ba71d95 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h58cc75bad344bc3b
  69:     0x7f906ba2d597 - rustc_span::with_source_map::hb087a1c2bc75d8e9
  70:     0x7f906ba72f8b - rustc_interface::interface::create_compiler_and_run::ha492945fb183c01e
  71:     0x7f906ba41530 - scoped_tls::ScopedKey<T>::set::hf41307147817b997
  72:     0x7f906ba527c7 - std::sys_common::backtrace::__rust_begin_short_backtrace::h645f3b510f7fe2fd
  73:     0x7f906b9c77ea - core::ops::function::FnOnce::call_once{{vtable.shim}}::h19b1a0a715ec4eae
  74:     0x7f906b1737ba - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hea1090dbdcecbf5a
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/alloc/src/boxed.rs:1328:9
  75:     0x7f906b1737ba - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8d5723d3912bd325
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/alloc/src/boxed.rs:1328:9
  76:     0x7f906b1737ba - std::sys::unix::thread::Thread::new::thread_start::hc17a425ca2995724
                               at /rustc/1f5bc176b0e54a8e464704adcd7e571700207fe9/library/std/src/sys/unix/thread.rs:71:17
  77:     0x7f906b0643e9 - start_thread
  78:     0x7f906af81293 - __GI___clone
  79:                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.50.0-nightly (1f5bc176b 2020-12-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z chalk=yes

query stack during panic:
#0 [evaluate_goal] evaluating trait selection obligation `environment: [], goal: [closure@./68025.rs:11:30: 11:35]: std::ops::Fn<()>`
#1 [typeck] type-checking `main`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

Closed by request of @jackh726.

Just want to leave some reasoning behind closing this: We discussed this in our wg-traits meeting today. We basically agree that right now the chalk-integration is so experimental that things not working is basically expected. Most of the test suite doesn't even pass with compare-mode=chalk. Once we get to a point that nearly all of the test suite passes with -Z chalk, it'll make more sense to keep chalk-related issues around, particularly under the case that it's something we expect to work with Chalk, but not with the rustc trait solver. If it's a test case that doesn't seem to be covered by the test suite as is, I would expect it's better to just add it as a regular test. But that's sometimes hard to know.

(I'm going to post this to all these 4 closed issues)