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: "fn pointer should not capture bound vars from predicate" using HRTB on fn and FnMut #108832

Closed
Stock84-dev opened this issue Mar 6, 2023 · 5 comments
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Stock84-dev
Copy link

Code

fn ice()
where
    for<'w> fn(&'w ()): FnMut(&'w ()),
{
}

fn main() {
    ice();
}

Meta

Exists on stable, beta and nightly.

rustc --version --verbose:

rustc 1.67.1 (d5a82bbd2 2023-02-07)
binary: rustc
commit-hash: d5a82bbd26e1ad8b7401f6a718a9c57c96905483
commit-date: 2023-02-07
host: x86_64-unknown-linux-gnu
release: 1.67.1
LLVM version: 15.0.6

Error output

thread 'rustc' panicked at 'fn pointer should not capture bound vars from predicate', compiler/rustc_trait_selection/src/traits/select/confirmation.rs:605:23
Backtrace

stack backtrace:
   0:     0x7f5f29f656fa - std::backtrace_rs::backtrace::libunwind::trace::h79937bc171ada62c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f5f29f656fa - std::backtrace_rs::backtrace::trace_unsynchronized::h2292bca8571cb919
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5f29f656fa - std::sys_common::backtrace::_print_fmt::h9c461f248e4ae90d
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f5f29f656fa - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he9fe6bf1a39182e1
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f5f29fc825e - core::fmt::write::h032658c119c720d7
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f5f29f55a85 - std::io::Write::write_fmt::h299fc90dfae41c0d
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/io/mod.rs:1682:15
   6:     0x7f5f29f654c5 - std::sys_common::backtrace::_print::heb70d25df9937e3f
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f5f29f654c5 - std::sys_common::backtrace::print::had745c0a76b8b521
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f5f29f6820f - std::panicking::default_hook::{{closure}}::h1ea782cdfa2fd097
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:267:22
   9:     0x7f5f29f67f4b - std::panicking::default_hook::h1cc3af63455a163c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:286:9
  10:     0x7f5f2d260ab1 - <rustc_driver[5c3b90d1fb3964ba]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[e6a29f2585b3d454]::ops::function::FnOnce<(&core[e6a29f2585b3d454]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f5f29f68a4d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6e4950ba7c0fd82a
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2032:9
  12:     0x7f5f29f68a4d - std::panicking::rust_panic_with_hook::h5cafdc4b3bfd5528
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:692:13
  13:     0x7f5f29f687c9 - std::panicking::begin_panic_handler::{{closure}}::hf31c60f40775892c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:579:13
  14:     0x7f5f29f65bac - std::sys_common::backtrace::__rust_end_short_backtrace::h28a5c7be595826cd
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f5f29f684d2 - rust_begin_unwind
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
  16:     0x7f5f29fc4c43 - core::panicking::panic_fmt::h8fa27a0b37dd98b7
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
  17:     0x7f5f29fc4d91 - core::panicking::panic_display::hf704d87f83545eb6
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:135:5
  18:     0x7f5f29fc4d3b - core::panicking::panic_str::hdc01f81137c4de19
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:119:5
  19:     0x7f5f29fc49c6 - core::option::expect_failed::hc5e8507006410982
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:1879:5
  20:     0x7f5f2b4dc733 - <rustc_trait_selection[945b70100f8dd3ec]::traits::select::SelectionContext>::confirm_candidate
  21:     0x7f5f2bb4f39a - <rustc_trait_selection[945b70100f8dd3ec]::traits::select::SelectionContext>::evaluate_stack
  22:     0x7f5f2bcfd8c5 - <rustc_trait_selection[945b70100f8dd3ec]::traits::select::SelectionContext>::evaluate_predicate_recursively
  23:     0x7f5f2ba518cd - rustc_traits[6faae80c4e587721]::evaluate_obligation::evaluate_obligation
  24:     0x7f5f2ba4f25a - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::get_query::<rustc_query_impl[e214cefb6de2a99d]::queries::evaluate_obligation, rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt>
  25:     0x7f5f2b51313f - <rustc_infer[ce51c2dc4d9f2303]::infer::InferCtxt as rustc_trait_selection[945b70100f8dd3ec]::traits::query::evaluate_obligation::InferCtxtExt>::predicate_must_hold_considering_regions
  26:     0x7f5f2b4b55b4 - <rustc_trait_selection[945b70100f8dd3ec]::traits::fulfill::FulfillProcessor as rustc_data_structures[1026114362f98086]::obligation_forest::ObligationProcessor>::process_obligation
  27:     0x7f5f2b4a77a2 - <rustc_data_structures[1026114362f98086]::obligation_forest::ObligationForest<rustc_trait_selection[945b70100f8dd3ec]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[945b70100f8dd3ec]::traits::fulfill::FulfillProcessor>
  28:     0x7f5f2b489a11 - <rustc_hir_typeck[1edef3791817899d]::fn_ctxt::FnCtxt>::check_argument_types
  29:     0x7f5f2b68e0f6 - <rustc_hir_typeck[1edef3791817899d]::fn_ctxt::FnCtxt>::check_call
  30:     0x7f5f2b5e6645 - <rustc_hir_typeck[1edef3791817899d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31:     0x7f5f2b63930a - <rustc_hir_typeck[1edef3791817899d]::fn_ctxt::FnCtxt>::check_block_with_expected
  32:     0x7f5f2b5e6a49 - <rustc_hir_typeck[1edef3791817899d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:     0x7f5f2b5d23d3 - <rustc_hir_typeck[1edef3791817899d]::fn_ctxt::FnCtxt>::check_return_expr
  34:     0x7f5f2b5c9b3b - rustc_hir_typeck[1edef3791817899d]::check::check_fn
  35:     0x7f5f2b5b4d80 - <rustc_hir_typeck[1edef3791817899d]::inherited::InheritedBuilder>::enter::<rustc_hir_typeck[1edef3791817899d]::typeck_with_fallback<rustc_hir_typeck[1edef3791817899d]::typeck::{closure#0}>::{closure#0}::{closure#1}, &rustc_middle[83f907612b22699d]::ty::context::TypeckResults>
  36:     0x7f5f2b5a76c1 - rustc_hir_typeck[1edef3791817899d]::typeck
  37:     0x7f5f2b5b1b3c - <rustc_query_system[7dbbccfee5a2d054]::dep_graph::graph::DepGraph<rustc_middle[83f907612b22699d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[83f907612b22699d]::ty::context::TyCtxt, rustc_span[41a321a6411ba4fa]::def_id::LocalDefId, &rustc_middle[83f907612b22699d]::ty::context::TypeckResults>
  38:     0x7f5f2b5a5e31 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::try_execute_query::<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, rustc_query_system[7dbbccfee5a2d054]::query::caches::VecCache<rustc_span[41a321a6411ba4fa]::def_id::LocalDefId, &rustc_middle[83f907612b22699d]::ty::context::TypeckResults>>
  39:     0x7f5f2c9b0085 - rustc_data_structures[1026114362f98086]::sync::par_for_each_in::<&[rustc_span[41a321a6411ba4fa]::def_id::LocalDefId], <rustc_middle[83f907612b22699d]::hir::map::Map>::par_body_owners<rustc_hir_typeck[1edef3791817899d]::typeck_item_bodies::{closure#0}>::{closure#0}>
  40:     0x7f5f2c9afdc3 - rustc_hir_typeck[1edef3791817899d]::typeck_item_bodies
  41:     0x7f5f2c8a5c7a - <rustc_query_system[7dbbccfee5a2d054]::dep_graph::graph::DepGraph<rustc_middle[83f907612b22699d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[83f907612b22699d]::ty::context::TyCtxt, (), ()>
  42:     0x7f5f2c8a49f0 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::try_execute_query::<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, rustc_query_system[7dbbccfee5a2d054]::query::caches::DefaultCache<(), ()>>
  43:     0x7f5f2c8a4370 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::get_query::<rustc_query_impl[e214cefb6de2a99d]::queries::typeck_item_bodies, rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt>
  44:     0x7f5f2b75bfb2 - <rustc_session[b89b9f24749004e7]::session::Session>::time::<(), rustc_hir_analysis[44326659f1d3f01d]::check_crate::{closure#7}>
  45:     0x7f5f2b75ad6c - rustc_hir_analysis[44326659f1d3f01d]::check_crate
  46:     0x7f5f2b75a98b - rustc_interface[65dcc5dffb099e04]::passes::analysis
  47:     0x7f5f2ca1291f - <rustc_query_system[7dbbccfee5a2d054]::dep_graph::graph::DepGraph<rustc_middle[83f907612b22699d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[83f907612b22699d]::ty::context::TyCtxt, (), core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  48:     0x7f5f2ca11a17 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::try_execute_query::<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, rustc_query_system[7dbbccfee5a2d054]::query::caches::DefaultCache<(), core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>>
  49:     0x7f5f2ca11470 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::get_query::<rustc_query_impl[e214cefb6de2a99d]::queries::analysis, rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt>
  50:     0x7f5f2c4241b3 - <rustc_interface[65dcc5dffb099e04]::passes::QueryContext>::enter::<rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  51:     0x7f5f2c420733 - <rustc_interface[65dcc5dffb099e04]::interface::Compiler>::enter::<rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}::{closure#2}, core[e6a29f2585b3d454]::result::Result<core[e6a29f2585b3d454]::option::Option<rustc_interface[65dcc5dffb099e04]::queries::Linker>, rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  52:     0x7f5f2c41b788 - rustc_span[41a321a6411ba4fa]::with_source_map::<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  53:     0x7f5f2c41b275 - <scoped_tls[393dd8f8fd825c8d]::ScopedKey<rustc_span[41a321a6411ba4fa]::SessionGlobals>>::set::<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  54:     0x7f5f2c41a862 - std[359ab902947f5f0b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[65dcc5dffb099e04]::util::run_in_thread_pool_with_globals<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  55:     0x7f5f2cb13b7a - <<std[359ab902947f5f0b]::thread::Builder>::spawn_unchecked_<rustc_interface[65dcc5dffb099e04]::util::run_in_thread_pool_with_globals<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#1} as core[e6a29f2585b3d454]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  56:     0x7f5f29f72803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb77d8d72ebcf79c4
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2000:9
  57:     0x7f5f29f72803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc08c3353e1568487
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2000:9
  58:     0x7f5f29f72803 - std::sys::unix::thread::Thread::new::thread_start::h7168e596cd5e5ce6
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys/unix/thread.rs:108:17
  59:     0x7f5f29d058fd - <unknown>
  60:     0x7f5f29d87a60 - <unknown>
  61:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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.67.1 (d5a82bbd2 2023-02-07) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C link-arg=-fuse-ld=lld

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

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `for<'w> fn(&'w ()): core::ops::function::FnMut<(&'w (),)>`
#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

@Stock84-dev Stock84-dev 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 Mar 6, 2023
@compiler-errors
Copy link
Member

I tried to fix this in #104929.

I'll probably at least put up a PR that turns this into an error from an ICE.

@JohnTitor
Copy link
Member

Triage: #108834 removes an ICE (but it doesn't fix the issue itself, see #108834 (comment)), dropping the I-ICE label.

@Enselic
Copy link
Member

Enselic commented Jun 12, 2024

Triage: #108834 adds a regression test that passes in the new solver. Also making it work in the old solver is probably a waste of time? Let's close this as "sufficiently fixed".

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2024
@compiler-errors
Copy link
Member

@Enselic: Do not close anything that is fixed by the new solver. The new solver is far from stable.

@compiler-errors
Copy link
Member

This was, however, fixed in the old solver in #122267.

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. 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