You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running into a compiler error when trying to compile this bit of code with rustc 1.22.0-nightly (eba374f 2017-09-11) running on x86_64-unknown-linux-gnu and the current futures-await crate (579a98bb):
#![feature(proc_macro, conservative_impl_trait, generators)]
extern crate futures_await as futures;
use futures::prelude::*;
use std::io::Error;
#[async]
fn foo(x: i8) -> Result<i8, (i8, Error)> {
Ok(x)
}
#[async]
fn bar() -> Result<(),()> {
let mut x = Ok(1);
loop {
let y = match x {
Ok(a) => a,
Err((b, _e)) => b,
//Err((b, _)) => b, // Compilation works fine if we use this line instead of the one above!
};
x = await!(foo(y));
}
}
fn main() {
bar().wait().unwrap();
}
The compiler error reads:
$ RUST_BACKTRACE=1 cargo +nightly run --verbose
Fresh futures v0.1.15
Fresh futures-await-macro v0.1.0 (https://github.com/alexcrichton/futures-await#579a98bb)
Fresh unicode-xid v0.1.0
Fresh proc-macro2 v0.1.3
Fresh quote v0.3.15 (https://github.com/dtolnay/quote#873c0d0e)
Fresh synom v0.11.3 (https://github.com/dtolnay/syn#d5e98599)
Fresh syn v0.11.11 (https://github.com/dtolnay/syn#d5e98599)
Fresh futures-async-macro v0.1.0 (https://github.com/alexcrichton/futures-await#579a98bb)
Fresh futures-await v0.1.0 (https://github.com/alexcrichton/futures-await#579a98bb)
Compiling foo v0.1.0 (file:///home/manuel/tmp/await-bug)
Running `rustc --crate-name foo src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=68d8605c99341a0a -C extra-filename=-68d8605c99341a0a --out-dir /home/manuel/tmp/await-bug/target/debug/deps -L dependency=/home/manuel/tmp/await-bug/target/debug/deps --extern futures_await=/home/manuel/tmp/await-bug/target/debug/deps/libfutures_await-5aec48bc7b80f434.rlib`
error: internal compiler error: /checkout/src/librustc_mir/transform/generator.rs:352: Broken MIR: generator contains type std::io::Error in MIR, but typeck only knows about (std::result::Result<(), ()>, std::result::Result<i8, (i8, std::io::Error)>, i8, (), impl futures::__rt::MyFuture<std::result::Result<i8, (i8, std::io::Error)>>)
--> src/main.rs:14:27
|
1 | | #![feature(proc_macro, conservative_impl_trait, generators)]
| |____^
...
14| fn bar() -> Result<(),()> {
| ___________________________^
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.22.0-nightly (eba374fb2 2017-09-11) running on x86_64-unknown-linux-gnu
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:439:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at /checkout/src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:60
at /checkout/src/libstd/panicking.rs:381
3: std::panicking::default_hook
at /checkout/src/libstd/panicking.rs:391
4: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:577
5: std::panicking::begin_panic
6: rustc_errors::Handler::span_bug
7: rustc::session::opt_span_bug_fmt::{{closure}}
8: rustc::session::span_bug_fmt
9: <rustc_mir::transform::generator::StateTransform as rustc::mir::transform::MirPass>::run_pass
10: rustc_mir::transform::run_suite
11: rustc_mir::transform::optimized_mir
12: rustc::dep_graph::graph::DepGraph::with_task
13: rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::try_get
14: rustc::ty::maps::TyCtxtAt::optimized_mir
15: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::optimized_mir
16: rustc_mir::shim::make_shim
17: rustc::dep_graph::graph::DepGraph::with_task
18: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_shims<'tcx>>::try_get
19: rustc::ty::maps::TyCtxtAt::mir_shims
20: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::instance_mir
21: rustc_trans::collector::collect_items_rec
22: rustc_trans::collector::collect_items_rec
23: rustc_trans::collector::collect_items_rec
24: rustc_trans::collector::collect_items_rec
25: rustc_trans::collector::collect_items_rec
26: rustc_trans::base::collect_and_partition_translation_items::{{closure}}
27: rustc_trans::base::trans_crate
28: rustc_driver::driver::phase_4_translate_to_llvm
29: rustc_driver::driver::compile_input::{{closure}}
30: rustc::ty::context::TyCtxt::create_and_enter
31: rustc_driver::driver::compile_input
32: rustc_driver::run_compiler
error: Could not compile `foo`.
Caused by:
process didn't exit successfully: `rustc --crate-name foo src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=68d8605c99341a0a -C extra-filename=-68d8605c99341a0a --out-dir /home/manuel/tmp/await-bug/target/debug/deps -L dependency=/home/manuel/tmp/await-bug/target/debug/deps --extern futures_await=/home/manuel/tmp/await-bug/target/debug/deps/libfutures_await-5aec48bc7b80f434.rlib` (exit code: 101)
Note, however, that if I use Err((b, _)) in the match statement instead of Err((b, _e)) the compilation succeeds.
If you need any other information to fix this issue, please let me know!
The text was updated successfully, but these errors were encountered:
I am running into a compiler error when trying to compile this bit of code with rustc 1.22.0-nightly (eba374f 2017-09-11) running on x86_64-unknown-linux-gnu and the current
futures-await
crate (579a98bb):The compiler error reads:
Note, however, that if I use
Err((b, _))
in the match statement instead ofErr((b, _e))
the compilation succeeds.If you need any other information to fix this issue, please let me know!
The text was updated successfully, but these errors were encountered: