Closed
Description
Attempting to shim futures-preview Stream to a tokio futures 0.1 Stream results in ICE when done this way. Most minimal example I can give
#![feature(async_await)]
use std::io;
use futures::StreamExt;
use futures::executor;
use hyper::{Body, Request, Response};
use hyper::service::service_fn_ok;
use romio::TcpListener;
use futures::compat::Compat;
fn req_res(_: Request<Body>) -> Response<Body> {
Response::new(Body::from(""))
}
async fn listen() -> io::Result<()> {
let mut listener = TcpListener::bind(&"127.0.0.1:8080".parse().unwrap())?;
let mut streams = listener.incoming();
let http = hyper::server::conn::Http::new();
while let Some(stream) = streams.next().await {
let stream = stream?;
let mut compat_stream = Compat::new(stream);
// Comment out = No ICE
http.serve_connection(compat_stream, service_fn_ok(req_res));
}
Ok(())
}
fn main() {
// Comment out = No ICE
executor::block_on(listen());
}
[dependencies]
romio = { git = "https://github.com/withoutboats/romio.git" }
futures-preview = { version = "0.3.0-alpha.16", features = ["compat", "io-compat"] }
hyper = "0.12.30"
futures01 = { package = "futures", version = "0.1", optional = true }
error: internal compiler error: src/librustc_mir/transform/generator.rs:715: Broken MIR: generator contains type hyper::server::conn::Connection<futures_util::compat::compat03as01::Compat<romio::tcp::stream::TcpStream>, hyper::service::service::ServiceFnOk<fn(http::request::Request<hyper::body::body::Body>) -> http::response::Response<hyper::body::body::Body> {req_res}, hyper::body::body::Body>> in MIR, but typeck only knows about for<'r, 's, 't0> {romio::tcp::listener::TcpListener, romio::tcp::listener::Incoming<'r>, hyper::server::conn::Http, futures_util::stream::next::Next<'s, romio::tcp::listener::Incoming<'t0>>, ()}
--> src/main.rs:14:37
|
14 | async fn listen() -> io::Result<()> {
| _____________________________________^
15 | | let mut listener = TcpListener::bind(&"127.0.0.1:8080".parse().unwrap())?;
16 | | let mut streams = listener.incoming();
17 | |
... |
28 | | Ok(())
29 | | }
| |_^
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:578:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.37.0-nightly (04a3dd8a8 2019-06-18) running on x86_64-apple-darwin
note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `myproject`.
Caused by:
process didn't exit successfully: `rustc --edition=2018 --crate-name websocket_rs src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=e69ebbb05677b9bb -C extra-filename=-e69ebbb05677b9bb --out-dir /Users/seph/projects/concepts/ICE/target/debug/deps -C incremental=/Users/seph/projects/concepts/ICE/target/debug/incremental -L dependency=/Users/seph/projects/concepts/ICE/target/debug/deps --extern futures=/Users/seph/projects/concepts/ICE/target/debug/deps/libfutures-29c76c5a0da920d2.rlib --extern hyper=/Users/seph/projects/concepts/ICE/target/debug/deps/libhyper-5f049508aea1fff3.rlib --extern romio=/Users/seph/projects/concepts/ICE/target/debug/deps/libromio-11cb8940271f8e7a.rlib --extern tokio_io=/Users/seph/projects/concepts/ICE/target/debug/deps/libtokio_io-90f842baf63df0eb.rlib` (exit code: 101)