Closed
Description
Using nightly. Decent number of features enabled. Using futures-await
. Attempting to use map_err
on the result coming out of a call to await!
seems to cause a panic.
code
Working code:
#[async]
fn _post(mut state: State) -> Result<(State, Response), (State, HandlerError)> {
let body_res = await!(Body::take_from(&mut state).concat2());
let body = match body_res {
Ok(body) => body.to_vec(),
Err(err) => {
return Err((state, err.into_handler_error()));
}
};
let res = create_response(&state, StatusCode::Ok, Some((body, mime::APPLICATION_JSON)));
Ok((state, res))
}
Broken code:
#[async]
fn _post(mut state: State) -> Result<(State, Response), (State, HandlerError)> {
let body = await!(Body::take_from(&mut state).concat2())
.map(|chunks| chunks.to_vec())
.map_err(|err| (state, err.into_handler_error()))?;
let res = create_response(&state, StatusCode::Ok, Some((body, mime::APPLICATION_JSON)));
Ok((state, res))
}
Let me know if adding any additional type info here would be helpful.
expectations
I expected to have the code successfully compile and be the same as the working code block.
Instead, got a panic during compilation.
meta
Nightly features:
#![feature(conservative_impl_trait, generators, nll, proc_macro, universal_impl_trait, use_nested_groups)]
rustc info:
$ rustc --version --verbose
rustc 1.25.0-nightly (a0dcecff9 2018-01-24)
binary: rustc
commit-hash: a0dcecff90c45ad5d4eb60859e22bb3f1b03842a
commit-date: 2018-01-24
host: x86_64-apple-darwin
release: 1.25.0-nightly
LLVM version: 4.0
Backtrace:
error: internal compiler error: librustc_mir/borrow_check/error_reporting.rs:762: End-user description not implemented for field access on `TyGenerator(DefId(0/1:49 ~ gateway_service[ace7]::service[0]::{{impl}}[0]::_post[0]::{{closure}}[0]), ClosureSubsts { substs: Slice([futures::Async<futures::__rt::Mu>, std::result::Result<(gotham::state::State, hyper::Response), (gotham::state::State, gotham::handler::HandlerError)>, gotham::state::State]) }, GeneratorInterior { witness: {futures::stream::Concat2<hyper::Body>, futures::Async<futures::__rt::Mu>, (), std::vec::Vec<u8>, std::result::Result<(gotham::state::State, hyper::Response), (gotham::state::State, gotham::handler::HandlerError)>}, movable: true })`
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.25.0-nightly (a0dcecff9 2018-01-24) running on x86_64-apple-darwin
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:509:9
stack backtrace:
0: 0x10a383eab - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::ha9efc95a1760cacd
1: 0x10a390044 - std::sys_common::backtrace::print::hf5c8aa5eb53db16a
2: 0x10a3836e0 - std::panicking::default_hook::{{closure}}::hdce9608c60053b8f
3: 0x10a3833e3 - std::panicking::default_hook::hba09553cc28730a2
4: 0x10a383b66 - std::panicking::rust_panic_with_hook::h3639511a0c7cb848
5: 0x1063bcbfa - std::panicking::begin_panic::h635ae642d665c620
6: 0x1063d287c - rustc_errors::Handler::bug::hbe64a18383da6dc4
7: 0x1091c39cb - <std::thread::local::LocalKey<T>>::with::h541fcea574b37332
8: 0x109665bd5 - rustc::ty::context::tls::with_opt::hcf7b444f3a2040d7
9: 0x109248f37 - rustc::session::opt_span_bug_fmt::h78c03a1ab5eaf5a1
10: 0x109248e01 - rustc::session::bug_fmt::h3fe1e243a47291cd
11: 0x1055c8ea1 - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::describe_field_from_ty::h49a8c174a0cb9b6c
12: 0x1055c8a2a - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::describe_field::h78965fd178f95d79
13: 0x1055c8404 - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::append_place_to_string::h8f79ea72234925a0
14: 0x1055c5c7c - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::report_use_of_moved_or_uninitialized::hc1998dae45d582c0
15: 0x1055d12b4 - rustc_mir::borrow_check::MirBorrowckCtxt::check_if_path_is_moved::h6b5e4bc029599395
16: 0x1055ce35f - <rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx> as rustc_mir::dataflow::DataflowResultsConsumer<'cx, 'tcx>>::visit_statement_entry::h62ebb1b4fffdcc55
17: 0x1055cd67d - rustc_mir::borrow_check::do_mir_borrowck::hc1e7f5ca4c20578f
18: 0x1055efc9b - rustc::ty::context::tls::enter::h1443e4f51080c1ab
19: 0x10567c795 - rustc::infer::InferCtxtBuilder::enter::h3665c5dd412e5fd6
20: 0x1055cc726 - rustc_mir::borrow_check::mir_borrowck::h5a5cf133637a758c
21: 0x10942b303 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::compute_result::h8ce26d29167e8c3d
22: 0x109500e96 - rustc::dep_graph::graph::DepGraph::with_task_impl::h92c13dbcd115d438
23: 0x1091aa3be - rustc_errors::Handler::track_diagnostics::hc789be56ee0e16d2
24: 0x109059cc3 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::h62b3bfc64dcc5416
25: 0x10942b394 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::force::h8f25e18a8c999fcc
26: 0x109145fd9 - rustc::ty::maps::plumbing::force_from_dep_node::hd09e3b3c2deab39c
27: 0x10952885f - rustc::dep_graph::graph::DepGraph::try_mark_green::hd9972ee6c4efc24b
28: 0x109090eb2 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read::ha976c0deb96cdb31
29: 0x10941c4df - rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::try_get::h74325177e7bc3dde
30: 0x1095935e0 - rustc::ty::maps::TyCtxtAt::optimized_mir::he2f762eeb346da9e
31: 0x109585033 - rustc::ty::sty::ClosureSubsts::field_tys::ha48451c7a027a51d
32: 0x1056db3ea - rustc_mir::borrow_check::nll::type_check::TypeChecker::typeck_mir::hc7ad7a734db20202
33: 0x1056d180d - rustc_mir::borrow_check::nll::type_check::type_check_internal::h518be4c3ad2ff3e9
34: 0x1055f0faf - rustc::ty::context::tls::enter::h4236a27145a73016
35: 0x10567c87f - rustc::infer::InferCtxtBuilder::enter::h600f468bc4789a28
36: 0x1056de262 - <rustc_mir::borrow_check::nll::type_check::TypeckMir as rustc_mir::transform::MirPass>::run_pass::hadea65a31f93be35
37: 0x1055e6c29 - rustc_mir::transform::mir_const::{{closure}}::h02e1b3b2b7d7b18f
38: 0x1055e3fe8 - rustc_mir::transform::mir_const::hcc025ad467878db2
39: 0x10941958b - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::compute_result::hbd8b9fd9e305d39f
40: 0x1095146d7 - rustc::dep_graph::graph::DepGraph::with_task_impl::hee66bf436686dd4d
41: 0x1091a72a9 - rustc_errors::Handler::track_diagnostics::hb5f11d2f9ffb02ae
42: 0x109081070 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::hd8ac9f49c4833a46
43: 0x109419617 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::force::h9d74c11776eebafb
44: 0x109419d3c - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::try_get::h04568e10b15c7ebb
45: 0x109593400 - rustc::ty::maps::TyCtxtAt::mir_const::hd2755156a7dbf95d
46: 0x1090a10a3 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const::h927c411a4f7efbe1
47: 0x1055e41c2 - rustc_mir::transform::mir_validated::h94b6df5bcb6c3001
48: 0x10941aa6b - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::compute_result::hfe06032d6b01c5d6
49: 0x1095146d7 - rustc::dep_graph::graph::DepGraph::with_task_impl::hee66bf436686dd4d
50: 0x109194709 - rustc_errors::Handler::track_diagnostics::h6906f37a714bb65d
51: 0x109063140 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::h82a8367f44bba970
52: 0x10941aaf7 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::force::ha7aa7d5f7e14a50f
53: 0x10941b21c - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::try_get::h1ac5c2c13a2a5e42
54: 0x1095934f0 - rustc::ty::maps::TyCtxtAt::mir_validated::hab2b7cdf300d8bf0
55: 0x1090a10d3 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_validated::he7d8147885139b09
56: 0x1054b0e4b - rustc_borrowck::borrowck::borrowck::hb6f9751697f3d9f3
57: 0x10950d7e7 - rustc::dep_graph::graph::DepGraph::with_task_impl::hc5e17307633b35cd
58: 0x109181f09 - rustc_errors::Handler::track_diagnostics::h1a92dd5f67bcfba5
59: 0x10906cbb0 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::h9ecc5cf53eea6ba4
60: 0x109429bc7 - rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::force::h903403cccee498b4
61: 0x10942a2ba - rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::try_get::h576007b4b6c14f04
62: 0x109593f42 - rustc::ty::maps::TyCtxtAt::borrowck::hd0c291eb8466ca41
63: 0x1090a1313 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::borrowck::h5cd5e26d06dfab2e
64: 0x1054b0bc1 - rustc_borrowck::borrowck::check_crate::h000dc470c6e4e6db
65: 0x103f6fb98 - <std::thread::local::LocalKey<T>>::with::hc97c0f695fc47a37
66: 0x103f6d1ec - <std::thread::local::LocalKey<T>>::with::h5232c8db13d095a5
67: 0x103f9b3e3 - rustc_driver::driver::compile_input::h13c6388277ea77a3
68: 0x103fac17c - rustc_driver::run_compiler::hebc5d6e3e17d092c
69: 0x103f2a2d1 - std::sys_common::backtrace::__rust_begin_short_backtrace::he16271a6bff11c29
70: 0x10a3b2fbe - __rust_maybe_catch_panic
71: 0x103ededdd - <F as alloc::boxed::FnBox<A>>::call_box::h838126c6997c937c
72: 0x10a392a67 - std::sys_common::thread::start_thread::hee6a12d8ac7037fd
73: 0x10a39eda8 - std::sys::unix::thread::Thread::new::thread_start::hca6ddd0e0fdf932d
74: 0x7fff6b51d6c0 - _pthread_body
75: 0x7fff6b51d56c - _pthread_start