impl trait: rustc stack overflow · Issue #35706 · rust-lang/rust (original) (raw)

@dwrensha

I get the error thread 'rustc' has overflowed its stack when I try to compile the following program:

[package] name = "test-futures" version = "0.1.0" authors = ["David Renshaw"]

[dependencies] futures = { git = "https://github.com/alexcrichton/futures-rs", rev="b7b728c00ef98d35e0d124abec6b84e3d8f9f3b3"} futures-io = { git = "https://github.com/alexcrichton/futures-rs", rev="b7b728c00ef98d35e0d124abec6b84e3d8f9f3b3"} futures-mio = { git = "https://github.com/alexcrichton/futures-rs", rev="b7b728c00ef98d35e0d124abec6b84e3d8f9f3b3"}

[[bin]] name = "main" path = "src/main.rs"

#![feature(conservative_impl_trait)]

extern crate futures; extern crate futures_io; extern crate futures_mio;

use futures::Future; use futures::stream::Stream; use futures_io::{IoStream}; use futures_mio::{TcpStream};

fn incoming_loop(incoming: IoStream<(TcpStream, ::std:🥅:SocketAddr)>) -> impl Future<Item=(), Error=::std::io::Error> { incoming.into_future().then(|r| { match r { Ok((stream, rest)) => { incoming_loop(rest) } Err() => { unimplemented!() } } }) }

pub fn main() { let mut l = futures_mio::Loop::new().unwrap(); let srv = l.handle().tcp_listen(&"127.0.0.1:5000".parse().unwrap());

let future = srv.and_then(move |server| {
    incoming_loop(server.incoming())
});

let _ = l.run(future);

}

$ rustc --version
rustc 1.12.0-nightly (1deb02ea6 2016-08-12)
$ cargo build
   Compiling test-futures v0.1.0 (file:///Users/dwrensha/Desktop/test-futures)

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: Could not compile `test-futures`.