rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.35k stars 12.59k forks source link

ICE: could not fully normalize (wrap + foundationdb) #84491

Open Speedy37 opened 3 years ago

Speedy37 commented 3 years ago

Code

use futures::prelude::*;
use std::pin::Pin;
use warp::{Filter, Reply};

struct Database;

pub trait DatabaseTransact {
    type Item;
}

pub struct FnMutBoxed<F> {
    pub f: F,
}
impl<F> DatabaseTransact for FnMutBoxed<F>
where
    F: FnMut() -> Pin<Box<dyn Future<Output = ()> + Send>>,
{
    type Item = ();
}

impl Database {
    pub fn transact_boxed<F>(f: F) -> impl Future<Output = ()> + Send + 'static
    where
        F: FnMut() -> Pin<Box<dyn Future<Output = ()> + Send>>,
        F: Send + 'static,
    {
        Self::transact(FnMutBoxed { f })
    }

    pub async fn transact<F>(_f: F) -> F::Item
    where
        F: DatabaseTransact,
    {
        todo!()
    }
}
pub async fn test1() -> std::result::Result<impl Reply, warp::Rejection> {
    Database::transact_boxed(|| futures::future::ready(()).boxed()).await;
    Ok(warp::reply::json(&"test 1"))
}

fn main() {
    futures::executor::block_on(
        warp::serve(warp::get().and_then(test1)).run(([127, 0, 0, 1], 8010)),
    );
}

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (7f4afdf02 2021-04-22)
binary: rustc
commit-hash: 7f4afdf0255600306bf67432da722c7b5d2cbf82
commit-date: 2021-04-22
host: x86_64-pc-windows-msvc
release: 1.53.0-nightly
LLVM version: 12.0.0

Same with stable (rustc 1.51.0 (2fd73fabe 2021-03-23) running on x86_64-pc-windows-msvc)

Error output

error: internal compiler error: compiler\rustc_traits\src\normalize_erasing_regions.rs:54:32: could not fully normalize `fn([closure@warp::Server<warp::filter::and_then::AndThen<warp::filter::FilterFn<[closure@warp::filters::method::method_is<[closure@warp::get::{closure#0}]>::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#0}], <warp::hyper::Server<warp::hyper::server::conn::AddrIncoming, warp::hyper::service::make::MakeServiceFn<[closure@warp::Server<warp::filter::and_then::AndThen<warp::filter::FilterFn<[closure@warp::filters::method::method_is<[closure@warp::get::{closure#0}]>::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#1}::{closure#0}]>> as futures::Future>::Output) -> <[closure@warp::Server<warp::filter::and_then::AndThen<warp::filter::FilterFn<[closure@warp::filters::method::method_is<[closure@warp::get::{closure#0}]>::{closure#0}]>, 
fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#0}] as futures_util::fns::FnOnce1<<warp::hyper::Server<warp::hyper::server::conn::AddrIncoming, warp::hyper::service::make::MakeServiceFn<[closure@warp::Server<warp::filter::and_then::AndThen<warp::filter::FilterFn<[closure@warp::filters::method::method_is<[closure@warp::get::{closure#0}]>::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#1}::{closure#0}]>> as futures::Future>::Output>>::Output {<[closure@warp::Server<warp::filter::and_then::AndThen<warp::filter::FilterFn<[closure@warp::filters::method::method_is<[closure@warp::get::{closure#0}]>::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#0}] as futures_util::fns::FnOnce1<<warp::hyper::Server<warp::hyper::server::conn::AddrIncoming, warp::hyper::service::make::MakeServiceFn<[closure@warp::Server<warp::filter::and_then::AndThen<warp::filter::FilterFn<[closure@warp::filters::method::method_is<[closure@warp::get::{closure#0}]>::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#1}::{closure#0}]>> as futures::Future>::Output>>::call_once}`
Backtrace

``` thread 'rustc' panicked at 'Box', /rustc/7f4afdf0255600306bf67432da722c7b5d2cbf82\library\std\src\panic.rs:59:5 stack backtrace: 0: 0x7ff89f3c5b8e - ::fmt::h65f771762210e3e5 1: 0x7ff89f3eedac - core::fmt::write::h3d73561f801c6731 2: 0x7ff89f3b9c28 - ::fmt::hd8fe844d61210e6f 3: 0x7ff89f3c9c82 - std::panicking::take_hook::ha49dee799706a2d8 4: 0x7ff89f3c9774 - std::panicking::take_hook::ha49dee799706a2d8 5: 0x7ff8903fb2a7 - rustc_driver::report_ice::hab89c69e12b6dd11 6: 0x7ff89f3ca465 - std::panicking::rust_panic_with_hook::h9e7cc259d68b1de2 7: 0x7ff894529de0 - ::flush::h8891f669af2106fb 8: 0x7ff894529389 - ::flush::h8891f669af2106fb 9: 0x7ff8947b4b51 - rustc_query_system::query::job::report_cycle::hf9b212d4fcbb24d3 10: 0x7ff8944f1070 - ::fmt::hd792e56b30cee48c 11: 0x7ff8944f7ab5 - rustc_errors::HandlerInner::err_count::h19c4a44295f74637 12: 0x7ff8944f55c2 - rustc_errors::Handler::bug::ha6863da4b058abe7 13: 0x7ff8943af3e8 - as rustc_middle::ty::ToPredicate>::to_predicate::h33b1b2f898ff3cca 14: 0x7ff8943a3b70 - rustc_middle::ty::query::on_disk_cache:: for &[rustc_middle::mir::abstract_const::Node]>::decode::h05252040febd0b50 15: 0x7ff8943a3ab9 - rustc_middle::ty::query::on_disk_cache:: for &[rustc_middle::mir::abstract_const::Node]>::decode::h05252040febd0b50 16: 0x7ff8943af319 - as rustc_middle::ty::ToPredicate>::to_predicate::h33b1b2f898ff3cca 17: 0x7ff8947ad4b7 - rustc_middle::util::bug::bug_fmt::he9e2e7924f44d34c 18: 0x7ff89272c629 - rustc_traits::provide::hd4707f2be3930568 19: 0x7ff8927f6a43 - >>>::lower_into::he129e20208932df5 20: 0x7ff8931d9752 - ::try_print_query_stack::h3c4346cc01dbde58 21: 0x7ff893169335 - rustc_query_impl:: for rustc_query_impl::queries::resolve_instance>::hash_result::hc7ba1ed25ba761ff 22: 0x7ff892fe0b2c - ::visit_foreign_item::hbd68f25166d1e477 23: 0x7ff892f4ecc5 - ::visit_foreign_item::hbd68f25166d1e477 24: 0x7ff892ecb088 - ::visit_foreign_item::hbd68f25166d1e477 25: 0x7ff8931c87ae - ::try_print_query_stack::h3c4346cc01dbde58 26: 0x7ff8943538fa - ::fold_ty::had7cf8d64e8d7d3e 27: 0x7ff8934ca183 - ::visit_terminator::h1b9fec5ded037d3c 28: 0x7ff8934cd690 - ::visit_impl_item::hfb7712f4efbd0644 29: 0x7ff8934c61dd - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 30: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 31: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 32: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 33: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 34: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 35: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 36: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 37: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 38: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 39: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 40: 0x7ff8934c5ad2 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 41: 0x7ff8937dcb5c - ::fmt::ha1d73c9f560ce7e8 42: 0x7ff8934c4351 - rustc_mir::monomorphize::collector::collect_crate_mono_items::hbeb6d2045a60cd71 43: 0x7ff89382455d - rustc_mir::monomorphize::partitioning::partition::h4e4f3b68f0632de5 44: 0x7ff892fbc7ef - ::visit_foreign_item::hbd68f25166d1e477 45: 0x7ff8931d6e61 - ::try_print_query_stack::h3c4346cc01dbde58 46: 0x7ff8931786f5 - rustc_query_impl:: for rustc_query_impl::queries::resolve_instance>::hash_result::hc7ba1ed25ba761ff 47: 0x7ff8930067ab - ::visit_foreign_item::hbd68f25166d1e477 48: 0x7ff892f1679b - ::visit_foreign_item::hbd68f25166d1e477 49: 0x7ff892ea297b - ::visit_foreign_item::hbd68f25166d1e477 50: 0x7ff8931c8118 - ::try_print_query_stack::h3c4346cc01dbde58 51: 0x7ff89066d687 - ::link::h47437b1deee45a0d 52: 0x7ff89066a199 - ::codegen_crate::h3f7a7161df43cead 53: 0x7ff8905327f2 - rustc_interface::passes::BoxedResolver::to_resolver_outputs::h51cffbb6bc3edf8f 54: 0x7ff890549ff6 - rustc_interface::queries::Queries::ongoing_codegen::h30f27fdc61a86ed6 55: 0x7ff890405a77 - rustc_driver::pretty::print_after_hir_lowering::h018530f73994254f 56: 0x7ff8903fd9dc - ::fmt::h4409e290eea8174b 57: 0x7ff890406d56 - rustc_driver::pretty::print_after_hir_lowering::h018530f73994254f 58: 0x7ff89042d0e4 - ::fmt::ha51d28018e278c75 59: 0x7ff89042f7ff - ::fmt::ha51d28018e278c75 60: 0x7ff890439ddd - ::fmt::ha51d28018e278c75 61: 0x7ff89f3d851a - std::sys::windows::thread::Thread::new::h35832c8baf769397 62: 0x7ff912a97034 - BaseThreadInitThunk 63: 0x7ff914882651 - RtlUserThreadStart note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.53.0-nightly (7f4afdf02 2021-04-22) running on x86_64-pc-windows-msvc note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [normalize_generic_arg_after_erasing_regions] normalizing `fn([closure@warp::Server::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#0}], ::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#1}::{closure#0}]>> as futures::Future>::Output) -> <[closure@warp::Server::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#0}] as futures_util::fns::FnOnce1<::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#1}::{closure#0}]>> as futures::Future>::Output>>::Output {<[closure@warp::Server::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#0}] as futures_util::fns::FnOnce1<::{closure#0}]>, fn() -> impl futures::Future {test1}>>::bind_ephemeral<([u8; 4], u16)>::{closure#1}::{closure#0}]>> as futures::Future>::Output>>::call_once}` #1 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack ```

Enselic commented 6 months ago

Triage: Can this still be reproduced? If yes, please also include your Cargo.toml and Cargo.lock.