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

Confirming built-in higher-ranked Future (and other coroutine) goals ICEs #121653

Closed
compiler-errors opened this issue Feb 26, 2024 · 3 comments
Closed
Labels
C-bug Category: This is a bug. F-unboxed_closures `#![feature(unboxed_closures)]` 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

@compiler-errors
Copy link
Member

Related to #108834, but for coroutine-based built-in goals.

Code

//@ edition:2021
//@ build-pass

#![feature(unboxed_closures)]
use std::future::Future;

trait Dispatch {
    fn dispatch(self);
}

impl<T: for<'a> Fn<(&'a (),)>> Dispatch for T
where
    for<'a> <T as FnOnce<(&'a (),)>>::Output: Future,
{
    fn dispatch(self) {
        (self)(&());
    }
}

fn main() {
    async fn foo(_: &()) {}
    foo.dispatch();
}
Backtrace

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/select/confirmation.rs:798:50:
future has no bound vars
stack backtrace:
   0:     0x7fb0c3375a06 - std::backtrace_rs::backtrace::libunwind::trace::hccc68910ff13f958
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fb0c3375a06 - std::backtrace_rs::backtrace::trace_unsynchronized::hdd46fbd3506eaa92
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb0c3375a06 - std::sys_common::backtrace::_print_fmt::h9ad5ddd930964dc6
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb0c3375a06 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb776b6ec91daeedd
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb0c33c698c - core::fmt::rt::Argument::fmt::h2572fa2911ad0fb3
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb0c33c698c - core::fmt::write::hff271b7e044cedf7
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fb0c336a3cf - std::io::Write::write_fmt::h912c793bec133142
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/io/mod.rs:1846:15
   7:     0x7fb0c33757b4 - std::sys_common::backtrace::_print::hea0a6eee0651d2b8
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb0c33757b4 - std::sys_common::backtrace::print::h18c37b9b3c9e91a8
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb0c33784fb - std::panicking::default_hook::{{closure}}::h0be5e0bb06f8054c
  10:     0x7fb0c3378249 - std::panicking::default_hook::h4893d748ed70c8dd
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/panicking.rs:292:9
  11:     0x7fb0c628983c - std[d552d81111d10822]::panicking::update_hook::<alloc[c9232cf8044bd381]::boxed::Box<rustc_driver_impl[8fe79628258f8a06]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fb0c3378c60 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h148c64496bcc724c
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/alloc/src/boxed.rs:2030:9
  13:     0x7fb0c3378c60 - std::panicking::rust_panic_with_hook::h18f7fbcd19143e05
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/panicking.rs:783:13
  14:     0x7fb0c33789a2 - std::panicking::begin_panic_handler::{{closure}}::h9b1e5e4a583f1a9f
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/panicking.rs:657:13
  15:     0x7fb0c3375ee6 - std::sys_common::backtrace::__rust_end_short_backtrace::h5a04e37630d644c0
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fb0c33786d4 - rust_begin_unwind
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/panicking.rs:645:5
  17:     0x7fb0c33c2ea5 - core::panicking::panic_fmt::h6be3da941e46ae73
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/core/src/panicking.rs:72:14
  18:     0x7fb0c33c3071 - core::panicking::panic_display::h3ad5b2b29c481c4c
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/core/src/panicking.rs:196:5
  19:     0x7fb0c33c2c5b - core::panicking::panic_str::h561624d791373b57
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/core/src/panicking.rs:171:5
  20:     0x7fb0c33c2c5b - core::option::expect_failed::h9ada6c11f8955522
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/core/src/option.rs:1995:5
  21:     0x7fb0c7b39e8c - <rustc_trait_selection[25f074878e7bf035]::traits::select::SelectionContext>::confirm_candidate
  22:     0x7fb0c47b2628 - <rustc_trait_selection[25f074878e7bf035]::traits::select::SelectionContext>::evaluate_candidate
  23:     0x7fb0c7fc928d - <rustc_trait_selection[25f074878e7bf035]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  24:     0x7fb0c79bf827 - <rustc_infer[a0d53b2b7edc1d02]::infer::InferCtxt>::probe::<core[bd769e7ba7008c3]::result::Result<rustc_middle[1814a9f6084ff241]::traits::select::EvaluationResult, rustc_middle[1814a9f6084ff241]::traits::select::OverflowError>, <rustc_trait_selection[25f074878e7bf035]::traits::select::SelectionContext>::evaluation_probe<<rustc_trait_selection[25f074878e7bf035]::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>::{closure#0}>
  25:     0x7fb0c781cbbd - rustc_traits[b4bf3681c2e68dbf]::evaluate_obligation::evaluate_obligation
  26:     0x7fb0c781c520 - rustc_query_impl[611d372e12178e2d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[611d372e12178e2d]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1814a9f6084ff241]::query::erase::Erased<[u8; 2usize]>>
  27:     0x7fb0c781ba89 - rustc_query_system[b4e5ffea0bf03311]::query::plumbing::try_execute_query::<rustc_query_impl[611d372e12178e2d]::DynamicConfig<rustc_query_system[b4e5ffea0bf03311]::query::caches::DefaultCache<rustc_type_ir[92caf9615d6b0945]::canonical::Canonical<rustc_middle[1814a9f6084ff241]::ty::context::TyCtxt, rustc_middle[1814a9f6084ff241]::ty::ParamEnvAnd<rustc_middle[1814a9f6084ff241]::ty::predicate::Predicate>>, rustc_middle[1814a9f6084ff241]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[611d372e12178e2d]::plumbing::QueryCtxt, false>
  28:     0x7fb0c781b711 - rustc_query_impl[611d372e12178e2d]::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fb0c46acbf1 - <rustc_infer[a0d53b2b7edc1d02]::infer::InferCtxt as rustc_trait_selection[25f074878e7bf035]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  30:     0x7fb0c4673cc8 - <rustc_trait_selection[25f074878e7bf035]::traits::fulfill::FulfillProcessor as rustc_data_structures[db24da0ef5036823]::obligation_forest::ObligationProcessor>::process_obligation
  31:     0x7fb0c7604c20 - <rustc_data_structures[db24da0ef5036823]::obligation_forest::ObligationForest<rustc_trait_selection[25f074878e7bf035]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[25f074878e7bf035]::traits::fulfill::FulfillProcessor>
  32:     0x7fb0c7760512 - rustc_traits[b4bf3681c2e68dbf]::codegen::codegen_select_candidate
  33:     0x7fb0c775fc6f - rustc_query_impl[611d372e12178e2d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[611d372e12178e2d]::query_impl::codegen_select_candidate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1814a9f6084ff241]::query::erase::Erased<[u8; 16usize]>>
  34:     0x7fb0c775f1b6 - rustc_query_system[b4e5ffea0bf03311]::query::plumbing::try_execute_query::<rustc_query_impl[611d372e12178e2d]::DynamicConfig<rustc_query_system[b4e5ffea0bf03311]::query::caches::DefaultCache<(rustc_middle[1814a9f6084ff241]::ty::ParamEnv, rustc_middle[1814a9f6084ff241]::ty::predicate::TraitRef), rustc_middle[1814a9f6084ff241]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[611d372e12178e2d]::plumbing::QueryCtxt, false>
  35:     0x7fb0c775ee6f - rustc_query_impl[611d372e12178e2d]::query_impl::codegen_select_candidate::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7fb0c4f860e0 - rustc_ty_utils[1c7772d4fa6bfd4e]::instance::resolve_instance
  37:     0x7fb0c7810569 - rustc_query_impl[611d372e12178e2d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[611d372e12178e2d]::query_impl::resolve_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1814a9f6084ff241]::query::erase::Erased<[u8; 32usize]>>
  38:     0x7fb0c78108ad - rustc_query_system[b4e5ffea0bf03311]::query::plumbing::try_execute_query::<rustc_query_impl[611d372e12178e2d]::DynamicConfig<rustc_query_system[b4e5ffea0bf03311]::query::caches::DefaultCache<rustc_middle[1814a9f6084ff241]::ty::ParamEnvAnd<(rustc_span[40015a5eff005e8e]::def_id::DefId, &rustc_middle[1814a9f6084ff241]::ty::list::List<rustc_middle[1814a9f6084ff241]::ty::generic_args::GenericArg>)>, rustc_middle[1814a9f6084ff241]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[611d372e12178e2d]::plumbing::QueryCtxt, false>
  39:     0x7fb0c78104f7 - rustc_query_impl[611d372e12178e2d]::query_impl::resolve_instance::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7fb0c780d1bb - <rustc_middle[1814a9f6084ff241]::ty::instance::Instance>::expect_resolve
  41:     0x7fb0c5376903 - rustc_monomorphize[4b46f6540ac4d91f]::collector::collect_items_rec::{closure#0}
  42:     0x7fb0c7f00f22 - rustc_monomorphize[4b46f6540ac4d91f]::collector::collect_items_rec
  43:     0x7fb0c7efc2b6 - rustc_monomorphize[4b46f6540ac4d91f]::partitioning::collect_and_partition_mono_items
  44:     0x7fb0c7efb930 - rustc_query_impl[611d372e12178e2d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[611d372e12178e2d]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1814a9f6084ff241]::query::erase::Erased<[u8; 24usize]>>
  45:     0x7fb0c7efb915 - <rustc_query_impl[611d372e12178e2d]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[bd769e7ba7008c3]::ops::function::FnOnce<(rustc_middle[1814a9f6084ff241]::ty::context::TyCtxt, ())>>::call_once
  46:     0x7fb0c85bfb4e - rustc_query_system[b4e5ffea0bf03311]::query::plumbing::try_execute_query::<rustc_query_impl[611d372e12178e2d]::DynamicConfig<rustc_query_system[b4e5ffea0bf03311]::query::caches::SingleCache<rustc_middle[1814a9f6084ff241]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[611d372e12178e2d]::plumbing::QueryCtxt, false>
  47:     0x7fb0c85bf845 - rustc_query_impl[611d372e12178e2d]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7fb0c81b6f96 - rustc_codegen_ssa[821d4a8fcfbf855]::base::codegen_crate::<rustc_codegen_llvm[4691753c7a3dcaa9]::LlvmCodegenBackend>
  49:     0x7fb0c81b6c4d - <rustc_codegen_llvm[4691753c7a3dcaa9]::LlvmCodegenBackend as rustc_codegen_ssa[821d4a8fcfbf855]::traits::backend::CodegenBackend>::codegen_crate
  50:     0x7fb0c85ef885 - rustc_interface[ecc06025874be1b3]::passes::start_codegen
  51:     0x7fb0c85ef055 - <rustc_interface[ecc06025874be1b3]::queries::Queries>::codegen_and_build_linker
  52:     0x7fb0c832f4aa - rustc_interface[ecc06025874be1b3]::interface::run_compiler::<core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>, rustc_driver_impl[8fe79628258f8a06]::run_compiler::{closure#0}>::{closure#0}
  53:     0x7fb0c85d4585 - std[d552d81111d10822]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ecc06025874be1b3]::util::run_in_thread_with_globals<rustc_interface[ecc06025874be1b3]::util::run_in_thread_pool_with_globals<rustc_interface[ecc06025874be1b3]::interface::run_compiler<core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>, rustc_driver_impl[8fe79628258f8a06]::run_compiler::{closure#0}>::{closure#0}, core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>>::{closure#0}, core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>>
  54:     0x7fb0c85d43b2 - <<std[d552d81111d10822]::thread::Builder>::spawn_unchecked_<rustc_interface[ecc06025874be1b3]::util::run_in_thread_with_globals<rustc_interface[ecc06025874be1b3]::util::run_in_thread_pool_with_globals<rustc_interface[ecc06025874be1b3]::interface::run_compiler<core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>, rustc_driver_impl[8fe79628258f8a06]::run_compiler::{closure#0}>::{closure#0}, core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>>::{closure#0}, core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bd769e7ba7008c3]::result::Result<(), rustc_span[40015a5eff005e8e]::ErrorGuaranteed>>::{closure#1} as core[bd769e7ba7008c3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  55:     0x7fb0c3382635 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h053e707adfcde341
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/alloc/src/boxed.rs:2016:9
  56:     0x7fb0c3382635 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::heb1de7d6bd583e37
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/alloc/src/boxed.rs:2016:9
  57:     0x7fb0c3382635 - std::sys::pal::unix::thread::Thread::new::thread_start::h0482c8914ef7aba2
                               at /rustc/0ecbd0605770f45c9151715e66ba2b3cae367fcb/library/std/src/sys/pal/unix/thread.rs:108:17
  58:     0x7fb0c3292609 - start_thread
  59:     0x7fb0c31b5353 - clone
  60:                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: please attach the file at `/playground/rustc-ice-2024-02-26T23_15_08-19.txt` to your bug report

note: compiler flags: --crate-type bin -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 [evaluate_obligation] evaluating trait selection obligation `for<'a> {async fn body@src/main.rs:21:26: 21:28}: core::future::future::Future`
#1 [codegen_select_candidate] computing candidate for `<main::foo as Dispatch>`
#2 [resolve_instance] resolving instance `<main::foo as Dispatch>::dispatch`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

@compiler-errors compiler-errors added 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. C-bug Category: This is a bug. labels Feb 26, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 26, 2024
@matthiaskrgr
Copy link
Member

duplicate of #112347 maybe?

@compiler-errors
Copy link
Member Author

compiler-errors commented Feb 27, 2024

We can hit this for all kinds of built-in coroutine/closure-based goals 💀

//@ edition:2024
//@ compile-flags: -Zunstable-options
//@ build-fail

#![feature(unboxed_closures, gen_blocks)]

use std::future::Future;

trait Dispatch {
    fn dispatch(self);
}

struct Fut<T>(T);
impl<T: for<'a> Fn<(&'a (),)>> Dispatch for Fut<T>
where
    for<'a> <T as FnOnce<(&'a (),)>>::Output: Future,
{
    fn dispatch(self) {
        (self.0)(&());
    }
}

struct Gen<T>(T);
impl<T: for<'a> Fn<(&'a (),)>> Dispatch for Gen<T>
where
    for<'a> <T as FnOnce<(&'a (),)>>::Output: Iterator,
{
    fn dispatch(self) {
        (self.0)(&());
    }
}

struct Closure<T>(T);
impl<T: for<'a> Fn<(&'a (),)>> Dispatch for Closure<T>
where
    for<'a> <T as FnOnce<(&'a (),)>>::Output: Fn<(&'a (),)>,
{
    fn dispatch(self) {
        (self.0)(&())(&());
    }
}

fn main() {
    async fn foo(_: &()) {}
    Fut(foo).dispatch();

    gen fn bar(_: &()) {}
    Gen(bar).dispatch();

    fn uwu<'a>(x: &'a ()) -> impl Fn(&'a ()) { |_| {} }
    Closure(uwu).dispatch();
}

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Feb 29, 2024
…f, r=oli-obk

Fix `async Fn` confirmation for `FnDef`/`FnPtr`/`Closure` types

Fixes three issues:
1. The code in `extract_tupled_inputs_and_output_from_async_callable` was accidentally getting the *future* type and the *output* type (returned by the future) messed up for fnptr/fndef/closure types. :/
2. We have a (class of) bug(s) in the old solver where we don't really support higher ranked built-in `Future` goals for generators. This is not possible to hit on stable code, but [can be hit with `unboxed_closures`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e935de7181e37e13515ad01720bcb899) (rust-lang#121653).
    * I'm opting not to fix that in this PR. Instead, I just instantiate placeholders when confirming `async Fn` goals.
4. Fixed a bug when generating `FnPtr` shims for `async Fn` trait goals.

r? oli-obk
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 29, 2024
Rollup merge of rust-lang#121654 - compiler-errors:async-fn-for-fn-def, r=oli-obk

Fix `async Fn` confirmation for `FnDef`/`FnPtr`/`Closure` types

Fixes three issues:
1. The code in `extract_tupled_inputs_and_output_from_async_callable` was accidentally getting the *future* type and the *output* type (returned by the future) messed up for fnptr/fndef/closure types. :/
2. We have a (class of) bug(s) in the old solver where we don't really support higher ranked built-in `Future` goals for generators. This is not possible to hit on stable code, but [can be hit with `unboxed_closures`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e935de7181e37e13515ad01720bcb899) (rust-lang#121653).
    * I'm opting not to fix that in this PR. Instead, I just instantiate placeholders when confirming `async Fn` goals.
4. Fixed a bug when generating `FnPtr` shims for `async Fn` trait goals.

r? oli-obk
@fmease fmease added F-unboxed_closures `#![feature(unboxed_closures)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 1, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 18, 2024
…r=<try>

Eagerly instantiate closure/coroutine-like bounds with placeholders to deal with binders correctly

A follow-up to rust-lang#119849, however it aims to fix a different set of issues. Currently, we have trouble confirming goals where built-in closure/fnptr/coroutine signatures are compared against higher-ranked goals.

Currently, we don't support goals like `for<'a> fn(&'a ()): Fn(&'a ())` because we don't expect the self type of goal to reference any bound regions from the goal, because we don't really know how to deal with the double binder of predicate + self type. However, this definitely can be reached (rust-lang#121653) -- and in fact, it results in post-mono errors in the case of rust-lang#112347 where the builtin type (e.g. a coroutine) is hidden behind a TAIT.

The proper fix here is to instantiate the goal before trying to extract the signature from the self type. See final two commits.

r? lcnr
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 2, 2024
…r=lcnr

Eagerly instantiate closure/coroutine-like bounds with placeholders to deal with binders correctly

A follow-up to rust-lang#119849, however it aims to fix a different set of issues. Currently, we have trouble confirming goals where built-in closure/fnptr/coroutine signatures are compared against higher-ranked goals.

Currently, we don't support goals like `for<'a> fn(&'a ()): Fn(&'a ())` because we don't expect the self type of goal to reference any bound regions from the goal, because we don't really know how to deal with the double binder of predicate + self type. However, this definitely can be reached (rust-lang#121653) -- and in fact, it results in post-mono errors in the case of rust-lang#112347 where the builtin type (e.g. a coroutine) is hidden behind a TAIT.

The proper fix here is to instantiate the goal before trying to extract the signature from the self type. See final two commits.

r? lcnr
@compiler-errors
Copy link
Member Author

this was fixed

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-unboxed_closures `#![feature(unboxed_closures)]` 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