Closed
Description
(See #36036 (comment) for shorter example)
I tried this code:
extern crate futures;
extern crate tokio_core;
extern crate tokio_proto;
use futures::BoxFuture;
use futures::stream::BoxStream;
use std::error::Error as StdError;
use std::io;
use tokio_proto::Service;
use tokio_proto::proto::pipeline;
use tokio_proto::io::{Transport, Readiness};
fn main() {
let service = ChunkedService {
_inner: tokio_proto::simple_service(|vec| -> Result<Vec<u8>, io::Error> { Ok(vec) }),
};
pipeline::Server::new(service, Stream).unwrap();
}
pub type Frame = pipeline::Frame<Vec<u8>, Error>;
#[derive(Debug)]
pub struct Error;
impl From<pipeline::Error<Error>> for Error {
fn from(_: pipeline::Error<Error>) -> Self {
unimplemented!()
}
}
pub struct ChunkedService<T> {
_inner: T,
}
impl<T> Service for ChunkedService<T>
where T: Service<Req = Vec<u8>, Resp = Vec<u8>>,
T::Error: StdError
{
type Req = Vec<u8>;
type Resp = pipeline::Message<Vec<u8>, BoxStream<(), Error>>;
type Error = Error;
type Fut = BoxFuture<Self::Resp, Self::Error>;
fn call(&self, _: Self::Req) -> Self::Fut {
unimplemented!()
}
}
struct Stream;
impl Transport for Stream {
type In = Frame;
type Out = Frame;
fn read(&mut self) -> io::Result<Option<Self::Out>> {
unimplemented!()
}
fn write(&mut self, _: Self::In) -> io::Result<Option<()>> {
unimplemented!()
}
fn flush(&mut self) -> io::Result<Option<()>> {
unimplemented!()
}
}
impl Readiness for Stream {
fn is_readable(&self) -> bool {
false
}
fn is_writable(&self) -> bool {
false
}
}
impl io::Read for Stream {
fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
unimplemented!()
}
}
impl io::Write for Stream {
fn write(&mut self, _: &[u8]) -> io::Result<usize> {
unimplemented!()
}
fn flush(&mut self) -> io::Result<()> {
unimplemented!()
}
}
with
tokio-core
at b9395808bea624e6b64bcafbf6cc05cabdaca6cc,tokio-proto
at 9b694ed5d92a9614058674032a37836300727314tokio-service
at 821739abb9a9c138d84ea1a81c90809af7530e08futures
at ecbca61c8123eff5b939933d9fe0633b522be52b
I expected to see this happen: compilation success
Instead, this happened: crashed nightly and beta compiler
error: internal compiler error: ../src/librustc_trans/type_of.rs:155: failed to get layout for `tokio_proto::proto::pipeline::pipeline::Pipeline<tokio_proto::proto::pipeline::server::Dispatch<ChunkedService<tokio_proto::SimpleService<[closure@src/main.rs:15:45: 15:92], std::vec::Vec<u8>>>>, Stream>`: the type `u8` has an unknown layout
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:643
stack backtrace:
1: 0x7fcd3eb42833 - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
2: 0x7fcd3eb5311d - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
3: 0x7fcd3eb5166d - std::panicking::default_hook::h9e30d428ee3b0c43
4: 0x7fcd3eb51d68 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
5: 0x7fcd37813387 - std::panicking::begin_panic::hd377747b5e679457
6: 0x7fcd37823a48 - rustc_errors::Handler::bug::h5390c1898e6c2b8a
7: 0x7fcd3bef0f2a - rustc::session::opt_span_bug_fmt::_{{closure}}::h7c6beff1b8c2acab
8: 0x7fcd3be3d055 - rustc::session::opt_span_bug_fmt::h8b8cb70ab73590aa
9: 0x7fcd3be3ce92 - rustc::session::bug_fmt::ha0645f57a1d17c87
10: 0x7fcd3dd46ca2 - rustc_trans::type_of::sizing_type_of::hac6f4c390971a5ca
11: 0x7fcd3dc863c3 - _<collections..vec..Vec<T> as core..iter..traits..FromIterator<T>>::from_iter::hc8dd23e1f341a34f
12: 0x7fcd3dcafe5d - rustc_trans::adt::mk_struct::h99083854ab09bd5b
13: 0x7fcd3dcad286 - rustc_trans::adt::represent_type::hd0a7f478d65fa630
14: 0x7fcd3dd47a9d - rustc_trans::type_of::in_memory_type_of::h642c7fd5249a3167
15: 0x7fcd3dd57e86 - rustc_trans::abi::FnType::unadjusted::_{{closure}}::h09238684ac765f3d
16: 0x7fcd3dca946e - rustc_trans::abi::FnType::unadjusted::h881cc0f40154edcc
17: 0x7fcd3dd00d79 - rustc_trans::declare::declare_fn::hb0a161c85d767c68
18: 0x7fcd3dd3f657 - rustc_trans::trans_item::TransItem::predefine::h43bc091dbd423801
19: 0x7fcd3dcbd8e1 - rustc_trans::base::trans_crate::hfc4e2ab878e1c72d
20: 0x7fcd3ef0ba92 - rustc_driver::driver::phase_4_translate_to_llvm::hc799bcf39cd85f66
21: 0x7fcd3ef46ad0 - rustc_driver::driver::compile_input::_{{closure}}::h688e4abb1bbb42bf
22: 0x7fcd3ef386a0 - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h45e03cee16dcf298
23: 0x7fcd3ee89b7f - rustc::ty::context::TyCtxt::create_and_enter::h0021bc4caf3a2e06
24: 0x7fcd3eefb094 - rustc_driver::driver::compile_input::hd9ecc57abd3cba85
25: 0x7fcd3ef2118d - rustc_driver::run_compiler::h184264500271cc39
26: 0x7fcd3ee62c43 - std::panicking::try::do_call::h17a7a17ad7240c5c
27: 0x7fcd3eb61336 - __rust_maybe_catch_panic
28: 0x7fcd3ee80039 - _<F as alloc..boxed..FnBox<A>>::call_box::h95ef76c8d48c6f60
29: 0x7fcd3eb4fba0 - std::sys::thread::Thread::new::thread_start::he0bf102845911132
30: 0x7fcd36fbb453 - start_thread
31: 0x7fcd3e7a07de - __GI___clone
32: 0x0 - <unknown>
Meta
rustc --version --verbose
:
rustc 1.13.0-nightly (e07dd59ea 2016-08-25)
binary: rustc
commit-hash: e07dd59eaeb7be95afd2fb3dc131108ae750c91c
commit-date: 2016-08-25
host: x86_64-unknown-linux-gnu
release: 1.13.0-nightly