Skip to content

ICE during async closure experiments #127331

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

Open
chadaustin opened this issue Jul 4, 2024 · 8 comments
Open

ICE during async closure experiments #127331

chadaustin opened this issue Jul 4, 2024 · 8 comments
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

@chadaustin
Copy link

rustc-ice-2024-07-04T18_10_25-10188.txt

Code

Minimizing the code is nontrivial. Let me know if it is required to make a branch that reproduces the issue.

Meta

nightly-x86_64-pc-windows-msvc unchanged - rustc 1.81.0-nightly (aa1d4f682 2024-07-03)

Error output

See attached rust-ice.

@chadaustin chadaustin 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 Jul 4, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 4, 2024
@chadaustin
Copy link
Author

Oh, here's the error message:

error: internal compiler error: compiler\rustc_middle\src\ty\mod.rs:1588:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: TypeNs("ChannelSender"), disambiguator: 0 }, DisambiguatedDefPathData { data: TypeNs(""
), disambiguator: 0 }], krate: crate0 }

@compiler-errors
Copy link
Member

Minimizing the code is nontrivial. Let me know if it is required to make a branch that reproduces the issue.

Yep, I can't fix this with no code. It's not clear what the issue is from the ICE backtrace alone.

@matthiaskrgr
Copy link
Member

you could probably fix #125099 and it would fix this one as well?

@chadaustin
Copy link
Author

Clone the batch-channel project and check out the async-closure-autobatch:

git clone https://github.com/chadaustin/batch-channel.git
cd batch-channel
git checkout async-closure-autobatch

Then cargo check the throughput benchmark:

cargo +nightly check --bench throughput

@saethlin saethlin added A-async-closures `async || {}` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 5, 2024
@theemathas
Copy link
Contributor

Self-contained reproduction (probably can be minimized further):

use std::future::Future;

trait AsyncCallback<A>: FnOnce(A) -> Self::Fut {
    type Fut: Future<Output = ()>;
}

impl<A, Out: Future<Output = ()>, F: FnOnce(A) -> Out> AsyncCallback<A> for F {
    type Fut = Out;
}

struct BatchSender<T>(T);

trait ChannelSender<T>: Clone + Send {
    type BatchSender;

    fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
    where
        F: for<'a> AsyncCallback<&'a mut Self::BatchSender>;
}

struct Sender<T>(T);

impl<T: Send> ChannelSender<T> for Sender<T> {
    type BatchSender = BatchSender<T>;

    fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
    where
        F: for<'a> AsyncCallback<&'a mut Self::BatchSender>,
    {
        async {}
    }
}
Error output
    Checking batch-channel v0.0.0 (/Users/timch/Documents/batch-channel)
error[E0277]: expected a `FnOnce(&'a mut BatchSender<T>)` closure, found `F`
  --> src/lib.rs:26:5
   |
26 | /     fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
27 | |     where
28 | |         F: for<'a> AsyncCallback<&'a mut Self::BatchSender>,
   | |____________________________________________________________^ expected an `FnOnce(&'a mut BatchSender<T>)` closure, found `F`
   |
   = note: expected a closure with arguments `(&mut <Sender<T> as ChannelSender<T>>::BatchSender,)`
              found a closure with arguments `(&'a mut BatchSender<T>,)`
note: required for `F` to implement `for<'a> AsyncCallback<&'a mut BatchSender<T>>`
  --> src/lib.rs:7:56
   |
7  | impl<A, Out: Future<Output = ()>, F: FnOnce(A) -> Out> AsyncCallback<A> for F {
   |                                      ----------------  ^^^^^^^^^^^^^^^^     ^
   |                                      |
   |                                      unsatisfied trait bound introduced here

error[E0277]: expected a `FnOnce(&'a mut BatchSender<T>)` closure, found `F`
  --> src/lib.rs:26:36
   |
26 |     fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&'a mut BatchSender<T>)` closure, found `F`
   |
   = note: expected a closure with arguments `(&mut <Sender<T> as ChannelSender<T>>::BatchSender,)`
              found a closure with arguments `(&'a mut BatchSender<T>,)`
note: required for `F` to implement `for<'a> AsyncCallback<&'a mut BatchSender<T>>`
  --> src/lib.rs:7:56
   |
7  | impl<A, Out: Future<Output = ()>, F: FnOnce(A) -> Out> AsyncCallback<A> for F {
   |                                      ----------------  ^^^^^^^^^^^^^^^^     ^
   |                                      |
   |                                      unsatisfied trait bound introduced here
note: required by a bound in `<Sender<T> as ChannelSender<T>>::autobatch`
  --> src/lib.rs:28:12
   |
26 |     fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
   |        --------- required by a bound in this associated function
27 |     where
28 |         F: for<'a> AsyncCallback<&'a mut Self::BatchSender>,
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<Sender<T> as ChannelSender<T>>::autobatch`

error[E0277]: the trait bound `Sender<T>: Clone` is not satisfied
  --> src/lib.rs:23:36
   |
23 | impl<T: Send> ChannelSender<T> for Sender<T> {
   |                                    ^^^^^^^^^ the trait `Clone` is not implemented for `Sender<T>`
   |
note: required by a bound in `ChannelSender`
  --> src/lib.rs:13:25
   |
13 | trait ChannelSender<T>: Clone + Send {
   |                         ^^^^^ required by this bound in `ChannelSender`

error[E0277]: the trait bound `for<'a> F: AsyncCallback<&'a mut BatchSender<T>>` is not satisfied
  --> src/lib.rs:28:12
   |
28 |         F: for<'a> AsyncCallback<&'a mut Self::BatchSender>,
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> FnOnce(&'a mut BatchSender<T>)` is not implemented for `F`, which is required by `for<'a> F: AsyncCallback<&'a mut BatchSender<T>>`
   |
   = note: expected a closure with arguments `(&mut <Sender<T> as ChannelSender<T>>::BatchSender,)`
              found a closure with arguments `(&'a mut BatchSender<T>,)`
note: required for `F` to implement `for<'a> AsyncCallback<&'a mut BatchSender<T>>`
  --> src/lib.rs:7:56
   |
7  | impl<A, Out: Future<Output = ()>, F: FnOnce(A) -> Out> AsyncCallback<A> for F {
   |                                      ----------------  ^^^^^^^^^^^^^^^^     ^
   |                                      |
   |                                      unsatisfied trait bound introduced here
note: the requirement `for<'a> F: AsyncCallback<&'a mut BatchSender<T>>` appears on the `impl`'s method `autobatch` but not on the corresponding trait's method
  --> src/lib.rs:16:8
   |
13 | trait ChannelSender<T>: Clone + Send {
   |       ------------- in this trait
...
16 |     fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
   |        ^^^^^^^^^ this trait's method doesn't have the requirement `for<'a> F: AsyncCallback<&'a mut BatchSender<T>>`

error[E0277]: the trait bound `for<'a> F: AsyncCallback<&'a mut BatchSender<T>>` is not satisfied
  --> src/lib.rs:26:5
   |
26 | /     fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
27 | |     where
28 | |         F: for<'a> AsyncCallback<&'a mut Self::BatchSender>,
   | |____________________________________________________________^ the trait `for<'a> FnOnce(&'a mut BatchSender<T>)` is not implemented for `F`, which is required by `for<'a> F: AsyncCallback<&'a mut BatchSender<T>>`
   |
   = note: expected a closure with arguments `(&mut <Sender<T> as ChannelSender<T>>::BatchSender,)`
              found a closure with arguments `(&'a mut BatchSender<T>,)`
note: required for `F` to implement `for<'a> AsyncCallback<&'a mut BatchSender<T>>`
  --> src/lib.rs:7:56
   |
7  | impl<A, Out: Future<Output = ()>, F: FnOnce(A) -> Out> AsyncCallback<A> for F {
   |                                      ----------------  ^^^^^^^^^^^^^^^^     ^
   |                                      |
   |                                      unsatisfied trait bound introduced here
note: required by a bound in `ChannelSender::{synthetic#0}`
  --> src/lib.rs:18:12
   |
18 |         F: for<'a> AsyncCallback<&'a mut Self::BatchSender>;
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ChannelSender::{synthetic#0}`

error[E0277]: expected a `FnOnce(&'a mut BatchSender<T>)` closure, found `F`
  --> src/lib.rs:26:36
   |
26 |     fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&'a mut BatchSender<T>)` closure, found `F`
   |
   = note: expected a closure with arguments `(&mut <Sender<T> as ChannelSender<T>>::BatchSender,)`
              found a closure with arguments `(&'a mut BatchSender<T>,)`
note: required for `F` to implement `for<'a> AsyncCallback<&'a mut BatchSender<T>>`
  --> src/lib.rs:7:56
   |
7  | impl<A, Out: Future<Output = ()>, F: FnOnce(A) -> Out> AsyncCallback<A> for F {
   |                                      ----------------  ^^^^^^^^^^^^^^^^     ^
   |                                      |
   |                                      unsatisfied trait bound introduced here

error: internal compiler error: compiler/rustc_middle/src/ty/mod.rs:1588:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: TypeNs("ChannelSender"), disambiguator: 0 }, DisambiguatedDefPathData { data: TypeNs(""), disambiguator: 0 }], krate: crate0 }

thread 'rustc' panicked at compiler/rustc_middle/src/ty/mod.rs:1588:13:
Box<dyn Any>
stack backtrace:
   0:        0x1052b6e30 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he7fc263c3ae60281
   1:        0x1052fa124 - core::fmt::write::he0bb149810b76b94
   2:        0x1052acf10 - std::io::Write::write_fmt::h961f49b732a1ce21
   3:        0x1052b6c88 - std::sys::backtrace::print::h805bc4620f3151a6
   4:        0x1052b9298 - std::panicking::default_hook::{{closure}}::h1847e4937d8814b8
   5:        0x1052b8f64 - std::panicking::default_hook::hd04f2dc85931a3af
   6:        0x10f15bb04 - <alloc[59dcbdbca7e8a995]::boxed::Box<rustc_driver_impl[c003af3b489365f2]::install_ice_hook::{closure#0}> as core[4a89e3a3d2972735]::ops::function::Fn<(&dyn for<'a, 'b> core[4a89e3a3d2972735]::ops::function::Fn<(&'a std[791662d3d9623b74]::panic::PanicHookInfo<'b>,), Output = ()> + core[4a89e3a3d2972735]::marker::Sync + core[4a89e3a3d2972735]::marker::Send, &std[791662d3d9623b74]::panic::PanicHookInfo)>>::call
   7:        0x1052b9e28 - std::panicking::rust_panic_with_hook::hfb7f8fd8d6ca280d
   8:        0x10f1e7dd0 - std[791662d3d9623b74]::panicking::begin_panic::<rustc_errors[924265ee8801bfcb]::ExplicitBug>::{closure#0}
   9:        0x10f1e46f0 - std[791662d3d9623b74]::sys::backtrace::__rust_end_short_backtrace::<std[791662d3d9623b74]::panicking::begin_panic<rustc_errors[924265ee8801bfcb]::ExplicitBug>::{closure#0}, !>
  10:        0x11355b278 - std[791662d3d9623b74]::panicking::begin_panic::<rustc_errors[924265ee8801bfcb]::ExplicitBug>
  11:        0x10f1c40cc - <rustc_errors[924265ee8801bfcb]::diagnostic::BugAbort as rustc_errors[924265ee8801bfcb]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x10fe69648 - rustc_middle[8bc529f0e8dcc906]::util::bug::opt_span_bug_fmt::<rustc_span[68cecb55101cab86]::span_encoding::Span>::{closure#0}
  13:        0x10fe69588 - rustc_middle[8bc529f0e8dcc906]::ty::context::tls::with_opt::<rustc_middle[8bc529f0e8dcc906]::util::bug::opt_span_bug_fmt<rustc_span[68cecb55101cab86]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x10fe69554 - rustc_middle[8bc529f0e8dcc906]::ty::context::tls::with_context_opt::<rustc_middle[8bc529f0e8dcc906]::ty::context::tls::with_opt<rustc_middle[8bc529f0e8dcc906]::util::bug::opt_span_bug_fmt<rustc_span[68cecb55101cab86]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x1135f9e00 - rustc_middle[8bc529f0e8dcc906]::util::bug::bug_fmt
  16:        0x10fd0cfec - <rustc_middle[8bc529f0e8dcc906]::ty::context::TyCtxt>::item_name
  17:        0x110bec424 - <rustc_infer[170c1ed4a1849e00]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33aed0349f5813fa]::traits::error_reporting::suggestions::TypeErrCtxtExt>::note_obligation_cause_code::<rustc_span[68cecb55101cab86]::ErrorGuaranteed, rustc_type_ir[a61c6928091218fd]::binder::Binder<rustc_middle[8bc529f0e8dcc906]::ty::context::TyCtxt, rustc_type_ir[a61c6928091218fd]::predicate::TraitPredicate<rustc_middle[8bc529f0e8dcc906]::ty::context::TyCtxt>>>
  18:        0x110bf3a9c - <rustc_infer[170c1ed4a1849e00]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33aed0349f5813fa]::traits::error_reporting::suggestions::TypeErrCtxtExt>::note_obligation_cause_code::<rustc_span[68cecb55101cab86]::ErrorGuaranteed, rustc_type_ir[a61c6928091218fd]::binder::Binder<rustc_middle[8bc529f0e8dcc906]::ty::context::TyCtxt, rustc_type_ir[a61c6928091218fd]::predicate::TraitPredicate<rustc_middle[8bc529f0e8dcc906]::ty::context::TyCtxt>>>::{closure#6}
  19:        0x110bf1b38 - <rustc_infer[170c1ed4a1849e00]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33aed0349f5813fa]::traits::error_reporting::suggestions::TypeErrCtxtExt>::note_obligation_cause_code::<rustc_span[68cecb55101cab86]::ErrorGuaranteed, rustc_middle[8bc529f0e8dcc906]::ty::predicate::Predicate>
  20:        0x110c04f60 - <rustc_infer[170c1ed4a1849e00]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33aed0349f5813fa]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::note_obligation_cause
  21:        0x110bfce1c - <rustc_infer[170c1ed4a1849e00]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33aed0349f5813fa]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  22:        0x110c0abfc - <rustc_infer[170c1ed4a1849e00]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33aed0349f5813fa]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  23:        0x110bfb85c - <rustc_infer[170c1ed4a1849e00]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33aed0349f5813fa]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  24:        0x10f54ae9c - rustc_hir_analysis[dbec75d63dfe474d]::check::check::check_impl_items_against_trait
  25:        0x10f54339c - rustc_hir_analysis[dbec75d63dfe474d]::check::check::check_item_type
  26:        0x10f521c64 - rustc_hir_analysis[dbec75d63dfe474d]::check::wfcheck::check_well_formed
  27:        0x1106225cc - rustc_query_impl[f1d8f2bcea61389e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f1d8f2bcea61389e]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8bc529f0e8dcc906]::query::erase::Erased<[u8; 1usize]>>
  28:        0x1107016ac - <rustc_query_impl[f1d8f2bcea61389e]::query_impl::check_well_formed::dynamic_query::{closure#2} as core[4a89e3a3d2972735]::ops::function::FnOnce<(rustc_middle[8bc529f0e8dcc906]::ty::context::TyCtxt, rustc_hir[7a2e70a68ac31600]::hir_id::OwnerId)>>::call_once
  29:        0x1105d8268 - rustc_query_system[8ffd5b92dfc530c8]::query::plumbing::try_execute_query::<rustc_query_impl[f1d8f2bcea61389e]::DynamicConfig<rustc_query_system[8ffd5b92dfc530c8]::query::caches::VecCache<rustc_hir[7a2e70a68ac31600]::hir_id::OwnerId, rustc_middle[8bc529f0e8dcc906]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f1d8f2bcea61389e]::plumbing::QueryCtxt, true>
  30:        0x1107c0f34 - rustc_query_impl[f1d8f2bcea61389e]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
  31:        0x10f50ba4c - rustc_middle[8bc529f0e8dcc906]::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system[8ffd5b92dfc530c8]::query::caches::VecCache<rustc_hir[7a2e70a68ac31600]::hir_id::OwnerId, rustc_middle[8bc529f0e8dcc906]::query::erase::Erased<[u8; 1usize]>>, ()>
  32:        0x10f4ff304 - <rustc_data_structures[288cf1eb93b81d30]::sync::parallel::ParallelGuard>::run::<core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>, rustc_data_structures[288cf1eb93b81d30]::sync::parallel::enabled::try_par_for_each_in<&[rustc_hir[7a2e70a68ac31600]::hir::ImplItemId], rustc_span[68cecb55101cab86]::ErrorGuaranteed, <rustc_middle[8bc529f0e8dcc906]::hir::ModuleItems>::par_impl_items<rustc_hir_analysis[dbec75d63dfe474d]::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  33:        0x10f3b6fa0 - <rustc_middle[8bc529f0e8dcc906]::hir::ModuleItems>::par_items::<rustc_hir_analysis[dbec75d63dfe474d]::check::wfcheck::check_mod_type_wf::{closure#0}>
  34:        0x10f527b5c - rustc_hir_analysis[dbec75d63dfe474d]::check::wfcheck::check_mod_type_wf
  35:        0x110622580 - rustc_query_impl[f1d8f2bcea61389e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f1d8f2bcea61389e]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8bc529f0e8dcc906]::query::erase::Erased<[u8; 1usize]>>
  36:        0x110701430 - <rustc_query_impl[f1d8f2bcea61389e]::query_impl::check_mod_type_wf::dynamic_query::{closure#2} as core[4a89e3a3d2972735]::ops::function::FnOnce<(rustc_middle[8bc529f0e8dcc906]::ty::context::TyCtxt, rustc_span[68cecb55101cab86]::def_id::LocalModDefId)>>::call_once
  37:        0x11057e474 - rustc_query_system[8ffd5b92dfc530c8]::query::plumbing::try_execute_query::<rustc_query_impl[f1d8f2bcea61389e]::DynamicConfig<rustc_query_system[8ffd5b92dfc530c8]::query::caches::DefaultCache<rustc_span[68cecb55101cab86]::def_id::LocalModDefId, rustc_middle[8bc529f0e8dcc906]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f1d8f2bcea61389e]::plumbing::QueryCtxt, true>
  38:        0x1107b1f30 - rustc_query_impl[f1d8f2bcea61389e]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  39:        0x10f4ff8a8 - <rustc_data_structures[288cf1eb93b81d30]::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures[288cf1eb93b81d30]::sync::parallel::enabled::par_for_each_in<&rustc_hir[7a2e70a68ac31600]::hir_id::OwnerId, &[rustc_hir[7a2e70a68ac31600]::hir_id::OwnerId], <rustc_middle[8bc529f0e8dcc906]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[dbec75d63dfe474d]::check_crate::{closure#0}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  40:        0x10f4e2b68 - <rustc_session[eb968a6fff6375c9]::session::Session>::time::<(), rustc_hir_analysis[dbec75d63dfe474d]::check_crate::{closure#0}>
  41:        0x10f4e0e8c - rustc_hir_analysis[dbec75d63dfe474d]::check_crate
  42:        0x10fa6b85c - rustc_interface[ff3e7bd95de52456]::passes::analysis
  43:        0x1106277d4 - rustc_query_impl[f1d8f2bcea61389e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f1d8f2bcea61389e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8bc529f0e8dcc906]::query::erase::Erased<[u8; 1usize]>>
  44:        0x1106c91d0 - <rustc_query_impl[f1d8f2bcea61389e]::query_impl::analysis::dynamic_query::{closure#2} as core[4a89e3a3d2972735]::ops::function::FnOnce<(rustc_middle[8bc529f0e8dcc906]::ty::context::TyCtxt, ())>>::call_once
  45:        0x110542040 - rustc_query_system[8ffd5b92dfc530c8]::query::plumbing::try_execute_query::<rustc_query_impl[f1d8f2bcea61389e]::DynamicConfig<rustc_query_system[8ffd5b92dfc530c8]::query::caches::SingleCache<rustc_middle[8bc529f0e8dcc906]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f1d8f2bcea61389e]::plumbing::QueryCtxt, true>
  46:        0x1107a3778 - rustc_query_impl[f1d8f2bcea61389e]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  47:        0x10f0f1e80 - <rustc_middle[8bc529f0e8dcc906]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[c003af3b489365f2]::run_compiler::{closure#0}::{closure#1}::{closure#5}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>
  48:        0x10f123578 - <rustc_interface[ff3e7bd95de52456]::interface::Compiler>::enter::<rustc_driver_impl[c003af3b489365f2]::run_compiler::{closure#0}::{closure#1}, core[4a89e3a3d2972735]::result::Result<core[4a89e3a3d2972735]::option::Option<rustc_interface[ff3e7bd95de52456]::queries::Linker>, rustc_span[68cecb55101cab86]::ErrorGuaranteed>>
  49:        0x10f10f684 - rustc_span[68cecb55101cab86]::create_session_globals_then::<core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>, rustc_interface[ff3e7bd95de52456]::util::run_in_thread_with_globals<rustc_interface[ff3e7bd95de52456]::util::run_in_thread_pool_with_globals<rustc_interface[ff3e7bd95de52456]::interface::run_compiler<core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>, rustc_driver_impl[c003af3b489365f2]::run_compiler::{closure#0}>::{closure#1}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>::{closure#0}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
  50:        0x10f0f37f8 - std[791662d3d9623b74]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ff3e7bd95de52456]::util::run_in_thread_with_globals<rustc_interface[ff3e7bd95de52456]::util::run_in_thread_pool_with_globals<rustc_interface[ff3e7bd95de52456]::interface::run_compiler<core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>, rustc_driver_impl[c003af3b489365f2]::run_compiler::{closure#0}>::{closure#1}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>::{closure#0}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>
  51:        0x10f0f0c6c - <<std[791662d3d9623b74]::thread::Builder>::spawn_unchecked_<rustc_interface[ff3e7bd95de52456]::util::run_in_thread_with_globals<rustc_interface[ff3e7bd95de52456]::util::run_in_thread_pool_with_globals<rustc_interface[ff3e7bd95de52456]::interface::run_compiler<core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>, rustc_driver_impl[c003af3b489365f2]::run_compiler::{closure#0}>::{closure#1}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>::{closure#0}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4a89e3a3d2972735]::result::Result<(), rustc_span[68cecb55101cab86]::ErrorGuaranteed>>::{closure#2} as core[4a89e3a3d2972735]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  52:        0x1052c2374 - std::sys::pal::unix::thread::Thread::new::thread_start::h3cbd0bca5805ff8b
  53:        0x19a536f94 - __pthread_joiner_wake

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 make sure that you have updated to the latest nightly

note: please attach the file at `/Users/timch/Documents/batch-channel/rustc-ice-2024-07-05T17_15_43-26060.txt` to your bug report

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

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

query stack during panic:
#0 [check_well_formed] checking that `<impl at src/lib.rs:23:1: 23:45>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
end of query stack
error[E0277]: expected a `FnOnce(&'a mut BatchSender<T>)` closure, found `F`
  --> src/lib.rs:30:9
   |
30 |         async {}
   |         ^^^^^ expected an `FnOnce(&'a mut BatchSender<T>)` closure, found `F`
   |
   = note: expected a closure with arguments `(&mut <Sender<T> as ChannelSender<T>>::BatchSender,)`
              found a closure with arguments `(&'a mut BatchSender<T>,)`
note: required for `F` to implement `for<'a> AsyncCallback<&'a mut BatchSender<T>>`
  --> src/lib.rs:7:56
   |
7  | impl<A, Out: Future<Output = ()>, F: FnOnce(A) -> Out> AsyncCallback<A> for F {
   |                                      ----------------  ^^^^^^^^^^^^^^^^     ^
   |                                      |
   |                                      unsatisfied trait bound introduced here

For more information about this error, try `rustc --explain E0277`.
error: could not compile `batch-channel` (lib) due to 8 previous errors

Notably doesn't require the async_closure feature.

@rustbot label -F-async_closure

@rustbot rustbot removed the A-async-closures `async || {}` label Jul 5, 2024
@compiler-errors
Copy link
Member

Thanks!!

@compiler-errors compiler-errors self-assigned this Jul 5, 2024
@theemathas
Copy link
Contributor

theemathas commented Jul 6, 2024

Minimized (I can't get it smaller than this) and got rid of dependence on std:

trait MyFn<T> {
    type Output;
}

trait MyFnAlias<A>: MyFn<A, Output = Self::OutputAlias> {
    type OutputAlias;
}

impl<A, F: MyFn<A>> MyFnAlias<A> for F {
    type OutputAlias = F::Output;
}

struct Thing;
trait Trait {}
impl Trait for Thing {}

trait ChannelSender {
    type Arg;

    fn autobatch<F>(self) -> impl Trait
    where
        F: MyFnAlias<Self::Arg>;
}

struct Sender;

impl ChannelSender for Sender {
    type Arg = i32;

    fn autobatch<F>(self) -> impl Trait
    where
        F: MyFnAlias<Self::Arg>,
    {
        Thing
    }
}

I believe this code should compile.

@compiler-errors
Copy link
Member

Oh yeah, this has nothing to do with async closures at all.

This is a shortcoming of the old trait solver having to do with -- and pardon for my technical jargon -- not being able to normalize param envs correctly. I think there should be other issues like this, probably labeled fixed-by-next-solver...

I'll look into the ICE though, since I think we crash the compiler when trying to report the error lol.

@compiler-errors compiler-errors removed their assignment Jul 6, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 7, 2024
…lse-positive, r=oli-obk

Don't try to label `ObligationCauseCode::CompareImplItem` for an RPITIT, since it has no name

The old (current) trait solver has a limitation that when a where clause in param-env must be normalized using the same where clause, then we get spurious errors in `normalize_param_env_or_error`. I don't think there's an issue tracking it, but it's the root cause for many of the "fixed-by-next-solver" labeled issues.

Specifically, these errors may occur when checking predicate entailment of the GAT that comes out of desugaring RPITITs. Since we use `ObligationCauseCode::CompareImplItem` for these predicates, we try calling `item_name` on an RPITIT which fails, since the RPITIT has no name.

We simply suppress this logic when we're reporting a predicate entailment error for an RPITIT. RPITITs should never have predicate entailment errors, *by construction*, but they may due to this bug in the old solver.

Addresses the ICE in rust-lang#127331, though doesn't fix the underlying issue (which is fundamental to the old solver).

r? types
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

No branches or pull requests

6 participants