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 with "failed to resolve instance for <... as IntoFuture>::into_future: Ok(None)" (regression between 1.73 and 1.74) #119095

Open
42triangles opened this issue Dec 18, 2023 · 6 comments
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-async Working group: Async & await

Comments

@42triangles
Copy link

Code

use std::{net::SocketAddr, future::Future, sync::Arc};

use warp::{reply::Reply, Filter};

use sqlx::postgres::Postgres;

fn login<'a>(
    db: impl sqlx::Acquire<'a, Database = sqlx::Postgres>   Send   'a,
) -> impl Future<Output = ()>   Send   'a {
    async move {
        sqlx::query_scalar::<Postgres, i64>("")
        .fetch_one(&mut *db.acquire().await.unwrap())
        .await
        .unwrap();
    }
}

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let db = Arc::new(sqlx::postgres::PgPool::connect("").await.unwrap());

    let app = warp::path!()
        .then(move || {
            let db = db.clone();
            async move {
                login(&mut db.begin().await.unwrap()).await;
                "".into_response()
            }
        });

    warp::serve(app).run(SocketAddr::new([0, 0, 0, 0].into(), 8080)).await;
}

with the dependencies

sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres" ] }
tokio = { version = "1", features = [ "rt", "macros" ] }
warp = "0.3"

Meta

rustc --version --verbose:

It doesn't work on nightly, beta or stable (from 17.74 onward):

rustc 1.76.0-nightly (6a6287132 2023-12-17)
binary: rustc
commit-hash: 6a62871320e262661bb1a0ea7f8aec9d3abeddf2
commit-date: 2023-12-17
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.6
Beta, stable, 1.74

rustc 1.75.0-beta.7 (b216e7b0e 2023-12-16)
binary: rustc
commit-hash: b216e7b0e7a2bdf11300a21a614dac6be3e99c5b
commit-date: 2023-12-16
host: x86_64-unknown-linux-gnu
release: 1.75.0-beta.7
LLVM version: 17.0.6
rustc 1.76.0-nightly (6a6287132 2023-12-17)
binary: rustc
commit-hash: 6a62871320e262661bb1a0ea7f8aec9d3abeddf2
commit-date: 2023-12-17
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.6
rustc 1.74.1 (a28077b28 2023-12-04)
binary: rustc
commit-hash: a28077b28a02b92985b3a3faecf92813155f1ea1
commit-date: 2023-12-04
host: x86_64-unknown-linux-gnu
release: 1.74.1
LLVM version: 17.0.4

Notably, the code does compiles with 1.73:

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.73.0
LLVM version: 17.0.2

Error output

1.74 & stable:

error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:415:25: failed to resolve instance for <tracing::instrument::Instrumented<futures_util::future::future::Map<warp::hyper::Server<AddrIncoming, warp::hyper::service::make::MakeServiceFn<{closure@warp::Server<warp::filter::then::Then<warp::filter::FilterFn<{closure@end::{closure#0}}>, {closure@src/main.rs:23:15: 23:22}>>::bind_ephemeral<std::net::SocketAddr>::{closure#1}::{closure#0}}>>, {closure@warp::Server<warp::filter::then::Then<warp::filter::FilterFn<{closure@end::{closure#0}}>, {closure@src/main.rs:23:15: 23:22}>>::bind_ephemeral<std::net::SocketAddr>::{closure#0}}>> as IntoFuture>::into_future: Ok(
                                    None,
                                )

beta and nightly:

error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:414:25: failed to resolve instance for <tracing::instrument::Instrumented<futures_util::future::future::Map<warp::hyper::Server<AddrIncoming, warp::hyper::service::make::MakeServiceFn<{closure@warp::Server<warp::filter::then::Then<warp::filter::FilterFn<{closure@end::{closure#0}}>, {closure@src/main.rs:23:15: 23:22}>>::bind_ephemeral<std::net::SocketAddr>::{closure#1}::{closure#0}}>>, {closure@warp::Server<warp::filter::then::Then<warp::filter::FilterFn<{closure@end::{closure#0}}>, {closure@src/main.rs:23:15: 23:22}>>::bind_ephemeral<std::net::SocketAddr>::{closure#0}}>> as IntoFuture>::into_future: Ok(
                                    None,
                                )
Backtrace (`RUST_BACKTRACE=1`)

thread 'rustc' panicked at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/compiler/rustc_errors/src/lib.rs:1119:75:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic_builder::Bug as rustc_errors::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
   2: <rustc_errors::Handler>::bug::<alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_middle::ty::instance::Instance>::expect_resolve
   8: rustc_monomorphize::collector::collect_items_rec::{closure#0}
   9: rustc_monomorphize::collector::collect_items_rec
  10: rustc_monomorphize::collector::collect_items_rec
  11: rustc_monomorphize::collector::collect_items_rec
  12: rustc_monomorphize::collector::collect_items_rec
  13: rustc_monomorphize::collector::collect_items_rec
  14: rustc_monomorphize::collector::collect_items_rec
  15: rustc_monomorphize::collector::collect_items_rec
  16: rustc_monomorphize::collector::collect_items_rec
  17: rustc_monomorphize::collector::collect_items_rec
  18: rustc_monomorphize::collector::collect_items_rec
  19: rustc_monomorphize::collector::collect_items_rec
  20: rustc_monomorphize::collector::collect_items_rec
  21: rustc_monomorphize::collector::collect_items_rec
  22: rustc_monomorphize::collector::collect_items_rec
  23: rustc_monomorphize::collector::collect_items_rec
  24: rustc_monomorphize::collector::collect_items_rec
  25: rustc_monomorphize::collector::collect_items_rec
  26: rustc_monomorphize::collector::collect_items_rec
  27: rustc_monomorphize::collector::collect_items_rec
  28: rustc_monomorphize::collector::collect_items_rec
  29: rustc_monomorphize::collector::collect_items_rec
  30: rustc_monomorphize::collector::collect_items_rec
  31: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 2 frames ...]
  32: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  33: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  34: rustc_interface::passes::start_codegen
  35: <rustc_interface::queries::Queries>::codegen_and_build_linker
  36: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug, I-ICE, T-compiler&template=ice.md

note: please attach the file at `/home/dodo/jedi.3/jedi/rustc-ice-2023-12-18T20_58_19-1254458.txt` to your bug report

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 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

Backtrace (`RUST_BACKTRACE=full`)

thread 'rustc' panicked at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/compiler/rustc_errors/src/lib.rs:1119:75:
Box<dyn Any>
stack backtrace:
   0:     0x7fe63058aedc - std::backtrace_rs::backtrace::libunwind::trace::hbd96f5b5ca760e25
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fe63058aedc - std::backtrace_rs::backtrace::trace_unsynchronized::h64131a6af1873394
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe63058aedc - std::sys_common::backtrace::_print_fmt::h172fc171fb8edd0e
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fe63058aedc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2fb904bfdf593293
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fe6305de040 - core::fmt::rt::Argument::fmt::h04c813bb3f4f9dfb
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/core/src/fmt/rt.rs:142:9
   5:     0x7fe6305de040 - core::fmt::write::hf0b14553553e6ae7
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fe63057ee7f - std::io::Write::write_fmt::h67b55b820fce9842
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/io/mod.rs:1810:15
   7:     0x7fe63058acc4 - std::sys_common::backtrace::_print::h0afe0dc870608b31
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fe63058acc4 - std::sys_common::backtrace::print::h9c7e632153240ab4
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fe63058d987 - std::panicking::default_hook::{{closure}}::h03700dce8c7b3295
  10:     0x7fe63058d6ef - std::panicking::default_hook::h7f9a2c2d59169cb4
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/panicking.rs:292:9
  11:     0x7fe6333689a0 - std[7ee343ea645c6a12]::panicking::update_hook::<alloc[af19cace5d9bbce9]::boxed::Box<rustc_driver_impl[3492dc2caf138e1f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fe63058e0a6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2a91d8c21992f1a0
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2029:9
  13:     0x7fe63058e0a6 - std::panicking::rust_panic_with_hook::hda97263b2307fce0
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/panicking.rs:783:13
  14:     0x7fe6333a06b4 - std[7ee343ea645c6a12]::panicking::begin_panic::<rustc_errors[eacfff4a863e622a]::ExplicitBug>::{closure#0}
  15:     0x7fe63339cc06 - std[7ee343ea645c6a12]::sys_common::backtrace::__rust_end_short_backtrace::<std[7ee343ea645c6a12]::panicking::begin_panic<rustc_errors[eacfff4a863e622a]::ExplicitBug>::{closure#0}, !>
  16:     0x7fe6333980d6 - std[7ee343ea645c6a12]::panicking::begin_panic::<rustc_errors[eacfff4a863e622a]::ExplicitBug>
  17:     0x7fe6333ab818 - <rustc_errors[eacfff4a863e622a]::diagnostic_builder::Bug as rustc_errors[eacfff4a863e622a]::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
  18:     0x7fe63378cfe5 - <rustc_errors[eacfff4a863e622a]::Handler>::bug::<alloc[af19cace5d9bbce9]::string::String>
  19:     0x7fe633826f1b - rustc_middle[e69f904d46cbb93a]::util::bug::opt_span_bug_fmt::<rustc_span[50b75e0f982c177c]::span_encoding::Span>::{closure#0}
  20:     0x7fe633810caa - rustc_middle[e69f904d46cbb93a]::ty::context::tls::with_opt::<rustc_middle[e69f904d46cbb93a]::util::bug::opt_span_bug_fmt<rustc_span[50b75e0f982c177c]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fe633810b28 - rustc_middle[e69f904d46cbb93a]::ty::context::tls::with_context_opt::<rustc_middle[e69f904d46cbb93a]::ty::context::tls::with_opt<rustc_middle[e69f904d46cbb93a]::util::bug::opt_span_bug_fmt<rustc_span[50b75e0f982c177c]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fe6316eb850 - rustc_middle[e69f904d46cbb93a]::util::bug::bug_fmt
  23:     0x7fe634b6cde9 - <rustc_middle[e69f904d46cbb93a]::ty::instance::Instance>::expect_resolve
  24:     0x7fe632490bfc - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec::{closure#0}
  25:     0x7fe635590959 - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  26:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  27:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  28:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  29:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  30:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  31:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  32:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  33:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  34:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  35:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  36:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  37:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  38:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  39:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  40:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  41:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  42:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  43:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  44:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  45:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  46:     0x7fe635590e4f - rustc_monomorphize[abe366ca73eb90ba]::collector::collect_items_rec
  47:     0x7fe63558c46e - rustc_monomorphize[abe366ca73eb90ba]::partitioning::collect_and_partition_mono_items
  48:     0x7fe63558b9e6 - rustc_query_impl[cebd3a41b0a13376]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cebd3a41b0a13376]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 24usize]>>
  49:     0x7fe63558b9cb - <rustc_query_impl[cebd3a41b0a13376]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[88eeaa8f9cd7aee6]::ops::function::FnOnce<(rustc_middle[e69f904d46cbb93a]::ty::context::TyCtxt, ())>>::call_once
  50:     0x7fe63558a207 - rustc_query_system[a286237d0122231d]::query::plumbing::try_execute_query::<rustc_query_impl[cebd3a41b0a13376]::DynamicConfig<rustc_query_system[a286237d0122231d]::query::caches::SingleCache<rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[cebd3a41b0a13376]::plumbing::QueryCtxt, true>
  51:     0x7fe6356b1f8f - rustc_query_impl[cebd3a41b0a13376]::query_impl::collect_and_partition_mono_items::get_query_incr::__rust_end_short_backtrace
  52:     0x7fe6355964be - rustc_codegen_ssa[5cb6e1891548d157]::base::codegen_crate::<rustc_codegen_llvm[796d9bc74f1e6614]::LlvmCodegenBackend>
  53:     0x7fe6355962ba - <rustc_codegen_llvm[796d9bc74f1e6614]::LlvmCodegenBackend as rustc_codegen_ssa[5cb6e1891548d157]::traits::backend::CodegenBackend>::codegen_crate
  54:     0x7fe635863485 - rustc_interface[10542add6e558f68]::passes::start_codegen
  55:     0x7fe635593bf8 - <rustc_interface[10542add6e558f68]::queries::Queries>::codegen_and_build_linker
  56:     0x7fe635654507 - rustc_interface[10542add6e558f68]::interface::run_compiler::<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}
  57:     0x7fe6355ccb46 - std[7ee343ea645c6a12]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[10542add6e558f68]::util::run_in_thread_with_globals<rustc_interface[10542add6e558f68]::util::run_in_thread_pool_with_globals<rustc_interface[10542add6e558f68]::interface::run_compiler<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>
  58:     0x7fe6355cc973 - <<std[7ee343ea645c6a12]::thread::Builder>::spawn_unchecked_<rustc_interface[10542add6e558f68]::util::run_in_thread_with_globals<rustc_interface[10542add6e558f68]::util::run_in_thread_pool_with_globals<rustc_interface[10542add6e558f68]::interface::run_compiler<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#1} as core[88eeaa8f9cd7aee6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  59:     0x7fe630597ef5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc2c3cc39d6b77a09
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2015:9
  60:     0x7fe630597ef5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf074611a704c4f76
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2015:9
  61:     0x7fe630597ef5 - std::sys::unix::thread::Thread::new::thread_start::h1479436da4eb4142
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys/unix/thread.rs:108:17
  62:     0x7fe6303849eb - <unknown>
  63:     0x7fe6304087cc - <unknown>
  64:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug, I-ICE, T-compiler&template=ice.md

note: please attach the file at `/home/dodo/jedi.3/jedi/rustc-ice-2023-12-18T20_58_39-1255764.txt` to your bug report

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 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

@42triangles 42triangles 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 Dec 18, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 18, 2023
@fmease fmease added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Dec 18, 2023
@compiler-errors compiler-errors added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Dec 18, 2023
@42triangles
Copy link
Author

I remembered that when I first saw this (and didn't have enough time to minimize it to the degree I have here), it had a different error message.

use std::{net::SocketAddr, future::Future, sync::Arc};

use warp::{reply::Reply, Filter};

use sqlx::postgres::Postgres;

fn login<'a>(
    db: impl sqlx::Acquire<'a, Database = sqlx::Postgres>   Send   'a,
) -> impl Future<Output = ()>   Send   'a {
    async move {
        sqlx::query_scalar::<Postgres, i64>("")
        .fetch_one(&mut *db.acquire().await.unwrap())
        .await
        .unwrap();
    }
}

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let db = Arc::new(sqlx::postgres::PgPool::connect("").await.unwrap());

    let app = warp::path!()
        .then(move || {
            let db = db.clone();
            async move {
                login(&mut *db.begin().await.unwrap()).await;
                "".into_response()
            }
        })
        .recover(move |_| async {
            Ok::<String, warp::Rejection>(panic!("not yet implemented"))
        })
        .boxed();

    warp::serve(app).run(SocketAddr::new([0, 0, 0, 0].into(), 8080)).await;
}

Results in an ICE, which is likely related, with this error message ("unexpected unsized tail"):

error: internal compiler error: /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/compiler/rustc_codegen_ssa/src/traits/type_.rs:87:18: unexpected unsized tail: warp::filter::recover::State<warp::filter::then::Then<warp::filter::FilterFn<Closure(DefId(20:1247 ~ warp[f529]::filters::path::end::{closure#0}), [i8, Binder(extern "RustCall" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut warp::route::Route,)) -> futures_util::future::ready::Ready<std::result::Result<(), warp::Rejection>>, [Region(BrAnon)]), ()])>, Closure(DefId(0:16 ~ jedi[788c]::main::{closure#0}::{closure#0}), [i8, Binder(extern "RustCall" fn(()) -> Coroutine(DefId(0:17 ~ jedi[788c]::main::{closure#0}::{closure#0}::{closure#0}), [std::future::ResumeTy, (), warp::http::Response<warp::hyper::Body>, CoroutineWitness(DefId(0:17 ~ jedi[788c]::main::{closure#0}::{closure#0}::{closure#0}), []), (std::sync::Arc<sqlx::Pool<sqlx::Postgres>, std::alloc::Global>,)], Static), []), (std::sync::Arc<sqlx::Pool<sqlx::Postgres>, std::alloc::Global>,)])>, Closure(DefId(0:18 ~ jedi[788c]::main::{closure#0}::{closure#1}), [i8, Binder(extern "RustCall" fn((warp::Rejection,)) -> Coroutine(DefId(0:19 ~ jedi[788c]::main::{closure#0}::{closure#1}::{closure#0}), [std::future::ResumeTy, (), std::result::Result<std::string::String, warp::Rejection>, CoroutineWitness(DefId(0:19 ~ jedi[788c]::main::{closure#0}::{closure#1}::{closure#0}), []), ()], Static), []), ()])>
Backtrace (with `RUST_BACKTRACE=full`, same stable version)

thread 'rustc' panicked at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/compiler/rustc_errors/src/lib.rs:1119:75:
Box<dyn Any>
stack backtrace:
   0:     0x7f1c0b1d0edc - std::backtrace_rs::backtrace::libunwind::trace::hbd96f5b5ca760e25
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f1c0b1d0edc - std::backtrace_rs::backtrace::trace_unsynchronized::h64131a6af1873394
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1c0b1d0edc - std::sys_common::backtrace::_print_fmt::h172fc171fb8edd0e
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f1c0b1d0edc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2fb904bfdf593293
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f1c0b224040 - core::fmt::rt::Argument::fmt::h04c813bb3f4f9dfb
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/core/src/fmt/rt.rs:142:9
   5:     0x7f1c0b224040 - core::fmt::write::hf0b14553553e6ae7
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f1c0b1c4e7f - std::io::Write::write_fmt::h67b55b820fce9842
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/io/mod.rs:1810:15
   7:     0x7f1c0b1d0cc4 - std::sys_common::backtrace::_print::h0afe0dc870608b31
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f1c0b1d0cc4 - std::sys_common::backtrace::print::h9c7e632153240ab4
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f1c0b1d3987 - std::panicking::default_hook::{{closure}}::h03700dce8c7b3295
  10:     0x7f1c0b1d36ef - std::panicking::default_hook::h7f9a2c2d59169cb4
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/panicking.rs:292:9
  11:     0x7f1c07f689a0 - std[7ee343ea645c6a12]::panicking::update_hook::<alloc[af19cace5d9bbce9]::boxed::Box<rustc_driver_impl[3492dc2caf138e1f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f1c0b1d40a6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2a91d8c21992f1a0
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2029:9
  13:     0x7f1c0b1d40a6 - std::panicking::rust_panic_with_hook::hda97263b2307fce0
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/panicking.rs:783:13
  14:     0x7f1c07fa06b4 - std[7ee343ea645c6a12]::panicking::begin_panic::<rustc_errors[eacfff4a863e622a]::ExplicitBug>::{closure#0}
  15:     0x7f1c07f9cc06 - std[7ee343ea645c6a12]::sys_common::backtrace::__rust_end_short_backtrace::<std[7ee343ea645c6a12]::panicking::begin_panic<rustc_errors[eacfff4a863e622a]::ExplicitBug>::{closure#0}, !>
  16:     0x7f1c07f980d6 - std[7ee343ea645c6a12]::panicking::begin_panic::<rustc_errors[eacfff4a863e622a]::ExplicitBug>
  17:     0x7f1c07fab818 - <rustc_errors[eacfff4a863e622a]::diagnostic_builder::Bug as rustc_errors[eacfff4a863e622a]::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
  18:     0x7f1c0838cfe5 - <rustc_errors[eacfff4a863e622a]::Handler>::bug::<alloc[af19cace5d9bbce9]::string::String>
  19:     0x7f1c08426f1b - rustc_middle[e69f904d46cbb93a]::util::bug::opt_span_bug_fmt::<rustc_span[50b75e0f982c177c]::span_encoding::Span>::{closure#0}
  20:     0x7f1c08410caa - rustc_middle[e69f904d46cbb93a]::ty::context::tls::with_opt::<rustc_middle[e69f904d46cbb93a]::util::bug::opt_span_bug_fmt<rustc_span[50b75e0f982c177c]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f1c08410b28 - rustc_middle[e69f904d46cbb93a]::ty::context::tls::with_context_opt::<rustc_middle[e69f904d46cbb93a]::ty::context::tls::with_opt<rustc_middle[e69f904d46cbb93a]::util::bug::opt_span_bug_fmt<rustc_span[50b75e0f982c177c]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f1c062eb850 - rustc_middle[e69f904d46cbb93a]::util::bug::bug_fmt
  23:     0x7f1c093a71df - <rustc_codegen_ssa[5cb6e1891548d157]::mir::place::PlaceRef<&rustc_codegen_llvm[796d9bc74f1e6614]::llvm_::ffi::Value>>::project_field::<rustc_codegen_llvm[796d9bc74f1e6614]::builder::Builder>
  24:     0x7f1c093a4773 - <rustc_codegen_ssa[5cb6e1891548d157]::mir::FunctionCx<rustc_codegen_llvm[796d9bc74f1e6614]::builder::Builder>>::codegen_place
  25:     0x7f1c09a0359d - <rustc_codegen_ssa[5cb6e1891548d157]::mir::FunctionCx<rustc_codegen_llvm[796d9bc74f1e6614]::builder::Builder>>::codegen_block
  26:     0x7f1c09f70df3 - rustc_codegen_ssa[5cb6e1891548d157]::mir::codegen_mir::<rustc_codegen_llvm[796d9bc74f1e6614]::builder::Builder>
  27:     0x7f1c09b681c8 - rustc_codegen_llvm[796d9bc74f1e6614]::base::compile_codegen_unit::module_codegen
  28:     0x7f1c0a186d09 - <rustc_codegen_llvm[796d9bc74f1e6614]::LlvmCodegenBackend as rustc_codegen_ssa[5cb6e1891548d157]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  29:     0x7f1c0a196a40 - rustc_codegen_ssa[5cb6e1891548d157]::base::codegen_crate::<rustc_codegen_llvm[796d9bc74f1e6614]::LlvmCodegenBackend>
  30:     0x7f1c0a1962ba - <rustc_codegen_llvm[796d9bc74f1e6614]::LlvmCodegenBackend as rustc_codegen_ssa[5cb6e1891548d157]::traits::backend::CodegenBackend>::codegen_crate
  31:     0x7f1c0a194485 - rustc_interface[10542add6e558f68]::passes::start_codegen
  32:     0x7f1c0a193bf8 - <rustc_interface[10542add6e558f68]::queries::Queries>::codegen_and_build_linker
  33:     0x7f1c0a254507 - rustc_interface[10542add6e558f68]::interface::run_compiler::<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}
  34:     0x7f1c0a1ccb46 - std[7ee343ea645c6a12]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[10542add6e558f68]::util::run_in_thread_with_globals<rustc_interface[10542add6e558f68]::util::run_in_thread_pool_with_globals<rustc_interface[10542add6e558f68]::interface::run_compiler<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>
  35:     0x7f1c0a1cc973 - <<std[7ee343ea645c6a12]::thread::Builder>::spawn_unchecked_<rustc_interface[10542add6e558f68]::util::run_in_thread_with_globals<rustc_interface[10542add6e558f68]::util::run_in_thread_pool_with_globals<rustc_interface[10542add6e558f68]::interface::run_compiler<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#1} as core[88eeaa8f9cd7aee6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7f1c0b1ddef5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc2c3cc39d6b77a09
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2015:9
  37:     0x7f1c0b1ddef5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf074611a704c4f76
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2015:9
  38:     0x7f1c0b1ddef5 - std::sys::unix::thread::Thread::new::thread_start::h1479436da4eb4142
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys/unix/thread.rs:108:17
  39:     0x7f1c050a09eb - <unknown>
  40:     0x7f1c051247cc - <unknown>
  41:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug, I-ICE, T-compiler&template=ice.md

note: please attach the file at `/home/dodo/jedi.3/jedi/rustc-ice-2023-12-18T22_18_19-1349873.txt` to your bug report

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:
end of query stack

@Jules-Bertholet
Copy link
Contributor

@rustbot label regression-from-stable-to-stable A-async-await

@rustbot rustbot added A-async-await Area: Async & Await regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 18, 2023
@lqd
Copy link
Member

lqd commented Dec 18, 2023

🤔 #107421 cc @cjgillot

@rustbot label -E-needs-bisection

@rustbot rustbot removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Dec 18, 2023
@lqd
Copy link
Member

lqd commented Dec 19, 2023

It's easy to remove sqlx from the reproduction, but warp is a bit more involved. Sorry, I ran out of time before fully minimizing this, but in the meantime here is the reduction to 250 lines or so.

This is the unexpected unsized tail ICE, but you can get others easily by changing the enum State to a struct, e.g. error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:1043:21: fn_abi_of_instance, in addition to the one in the OP.

The code
use std::future::{self, Future};
use std::marker::PhantomData;
use std::pin::Pin;
use std::sync::Arc;
use std::task::Context;
use std::task::Poll;

trait Acquire<'c> {
    type Connection;
    fn acquire(self) -> Pin<Box<dyn Future<Output = Result<Self::Connection, ()>>   Send   'c>>;
}
struct PgConnection;
impl<'c> Acquire<'c> for &'c mut PgConnection {
    type Connection = ();
    fn acquire(self) -> Pin<Box<dyn Future<Output = Result<Self::Connection, ()>>   Send   'c>> {
        unimplemented!()
    }
}
fn login<'a>(db: impl Acquire<'a>   Send   'a) -> impl Future<Output = ()>   Send   'a {
    async move {
        let _ = db.acquire().await;
    }
}
fn main() {
    path()
        .then(|| async {
            let mut conn = PgConnection;
            login(&mut conn).await;
        })
        .then(|_| async { unimplemented!() })
        .boxed();
}

fn path() -> impl Filter<Extract = (), Error = ()> {
    filter_fn(move || future::ready(Err(())))
}

struct Then<T, F> {
    _marker: PhantomData<(T, F)>,
}
impl<T, F> FilterBase for Then<T, F>
where
    T: Filter,
    F: Func<T::Extract>   Clone   Send,
    F::Output: Future   Send,
{
    type Extract = (<F::Output as Future>::Output,);
    type Error = T::Error;
    type Future = ThenFuture<T, F>;
}
struct ThenFuture<T, F>
where
    T: Filter,
    F: Func<T::Extract>,
    F::Output: Future   Send,
{
    _state: State<T::Future, F>,
}
enum State<T, F>
where
    T: TryFuture,
    F: Func<T::Ok>,
    F::Output: Future   Send,
{
    Second(F::Output),
}
impl<T, F> Future for ThenFuture<T, F>
where
    T: Filter,
    F: Func<T::Extract>,
    F::Output: Future   Send,
{
    type Output = Result<(<F::Output as Future>::Output,), T::Error>;
    fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
        unimplemented!()
    }
}
struct MapErr<T, F> {
    _filter: T,
    _callback: F,
}
impl<T, F, E> FilterBase for MapErr<T, F>
where
    T: Filter,
    F: Fn(T::Error) -> E   Clone   Send,
{
    type Extract = T::Extract;
    type Error = E;
    type Future = MapErrFuture<T, F>;
}
struct MapErrFuture<T: Filter, F> {
    _extract: T::Future,
    _callback: F,
}
impl<T, F, E> Future for MapErrFuture<T, F>
where
    T: Filter,
    F: Fn(T::Error) -> E,
{
    type Output = Result<T::Extract, E>;
    fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
        unimplemented!()
    }
}

struct BoxedFilter<T> {
    _filter: Arc<
        dyn Filter<
                Extract = T,
                Error = (),
                Future = Pin<Box<dyn Future<Output = Result<T, ()>>   Send>>,
            >   Send
              Sync,
    >,
}
impl<T: Send> BoxedFilter<T> {
    fn new<F>(filter: F) -> BoxedFilter<T>
    where
        F: Filter<Extract = T>   Send   Sync   'static,
        F::Error: Into<()>,
    {
        let filter = Arc::new(BoxingFilter {
            filter: filter.map_err(Internal, Into::into),
        });
        BoxedFilter { _filter: filter }
    }
}
struct BoxingFilter<F> {
    filter: F,
}
impl<F> FilterBase for BoxingFilter<F>
where
    F: Filter,
    F::Future: Send   'static,
{
    type Extract = F::Extract;
    type Error = F::Error;
    type Future = Pin<Box<dyn Future<Output = Result<Self::Extract, Self::Error>>   Send>>;
    fn filter(&self, _: Internal) -> Self::Future {
        Box::pin(self.filter.filter(Internal).into_future())
    }
}
trait FilterBase {
    type Extract;
    type Error;
    type Future: Future<Output = Result<Self::Extract, Self::Error>>   Send;
    fn filter(&self, _internal: Internal) -> Self::Future {
        unimplemented!()
    }
    fn map_err<F, E>(self, _internal: Internal, _fun: F) -> MapErr<Self, F>
    where
        Self: Sized,
        F: Fn(Self::Error) -> E   Clone,
        E: Send,
    {
        unimplemented!()
    }
}
struct Internal;
trait Filter: FilterBase {
    fn then<F>(self, _fun: F) -> Then<Self, F>
    where
        Self: Sized,
        F: Func<Self::Extract>   Clone,
        F::Output: Future   Send,
    {
        unimplemented!()
    }
    fn boxed(self) -> BoxedFilter<Self::Extract>
    where
        Self: Sized   Send   Sync   'static,
        Self::Extract: Send,
        Self::Error: Into<()>,
    {
        BoxedFilter::new(self)
    }
}
impl<T: FilterBase> Filter for T {}
fn filter_fn<F, U>(_func: F) -> FilterFn<F>
where
    F: Fn() -> U,
    U: TryFuture,
{
    unimplemented!()
}
struct FilterFn<F> {
    _func: F,
}
impl<F, U> FilterBase for FilterFn<F>
where
    F: Fn() -> U,
    U: TryFuture   Send   'static,
{
    type Extract = U::Ok;
    type Error = U::Error;
    type Future = IntoFuture<U>;
}

trait Func<Args> {
    type Output;
}
impl<F, R> Func<()> for F
where
    F: Fn() -> R,
{
    type Output = R;
}
impl<F, R, T2> Func<(T2,)> for F
where
    F: Fn(T2) -> R,
{
    type Output = R;
}
trait TryFuture: Future {
    type Ok;
    type Error;
    fn into_future(self) -> IntoFuture<Self>
    where
        Self: Sized,
    {
        unimplemented!()
    }
}
impl<F, T, E> TryFuture for F
where
    F: ?Sized   Future<Output = Result<T, E>>,
{
    type Ok = T;
    type Error = E;
}
struct IntoFuture<Fut> {
    _future: Fut,
}
impl<Fut: TryFuture> Future for IntoFuture<Fut> {
    type Output = Result<Fut::Ok, Fut::Error>;
    fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
        unimplemented!()
    }
}

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 19, 2023
@traviscross
Copy link
Contributor

@rustbot labels AsyncAwait-Triaged WG-async

We reviewed this today in WG-async triage. It sounds like a bug.

@rustbot rustbot added AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. WG-async Working group: Async & await labels Feb 26, 2024
@cyrgani
Copy link
Contributor

cyrgani commented Aug 7, 2024

The reproduction by lqd above no longer ICEs now, but the original example still does, so here is a new reduced version that ICEs with failed to resolve instance for <Server<{async block@src/main.rs:50:38: 50:43}> as Future>::poll on all release channels:

use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

fn any<T>() -> T {
    todo!()
}

#[allow(clippy::manual_async_fn)]
fn login<'a>(db: impl Acquire<'a>   Send   'a) -> impl Future   Send   'a {
    async {
        db.acquire().await;
    }
}

type BoxFuture<T> = Pin<Box<dyn Future<Output = T>   Send>>;

trait Acquire<'c> {
    type Connection;

    fn acquire(self) -> BoxFuture<Self::Connection>;
}

impl<'c> Acquire<'c> for &'c () {
    type Connection = ();

    fn acquire(self) -> BoxFuture<Self::Connection> {
        todo!()
    }
}

struct Then<F>(F);

impl<F> Future for Then<F>
where
    F: Send,
{
    type Output = ();
    fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<()> {
        todo!()
    }
}

fn main() {
    let app = Then(async {
        login(any::<&'static ()>()).await;
    });

    #[allow(clippy::async_yields_async)]
    let mut future = Box::pin(Server(async { app }));
    let _ = future.as_mut().poll(any::<&mut Context>());
}

trait ConnStreamExec<F> {}

impl<F> ConnStreamExec<F> for () where F: Future {}

struct Server<S>(S);

impl<S> Future for Server<S>
where
    S: Future,
    (): ConnStreamExec<S::Output>,
{
    type Output = ();
    fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<()> {
        todo!()
    }
}

trait NeverImplemented {}
impl<E, F> ConnStreamExec<F> for E where E: NeverImplemented {}
Error

error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:510:25: failed to resolve instance for <Server<{async block@ice/src/main.rs:50:38: 50:51}> as Future>::poll: Ok(
                                    None,
                                )

thread 'rustc' panicked at compiler/rustc_middle/src/ty/instance.rs:510:25:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: <rustc_middle::ty::instance::Instance>::expect_resolve
   7: rustc_monomorphize::collector::collect_items_rec::{closure#0}
   8: rustc_monomorphize::collector::collect_items_rec
   9: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 2 frames ...]
  10: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  11: rustc_interface::passes::start_codegen
  12: <rustc_interface::queries::Queries>::codegen_and_build_linker
  13: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug, I-ICE, T-compiler&template=ice.md

note: rustc 1.80.0 (051478957 2024-07-21) 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 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `ice` (bin "ice")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-async Working group: Async & await
Projects
None yet
Development

No branches or pull requests

9 participants