Skip to content

ICE with "failed to resolve instance for <... as IntoFuture>::into_future: Ok(None)" (regression between 1.73 and 1.74) #119095

Open
@42triangles

Description

@42triangles

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%2C+I-ICE%2C+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:     0x7fe635594485 - 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%2C+I-ICE%2C+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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-asyncWorking group: Async & awaitregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions