Skip to content

Broken MIR: generator contains type impl std::future::Future in MIR, but typeck only knows about {impl std::future::Future, ()} #61834

Closed
@LunaBorowska

Description

@LunaBorowska

I tried this code with edition 2018:

#![feature(async_await)]
async fn a() {}
async fn b() {}
async fn start() {
    a();
    b().await;
}
fn main() {
    start();
}

This happened:

error: internal compiler error: src/librustc_mir/transform/generator.rs:714: Broken MIR: generator contains type impl std::future::Future in MIR, but typeck only knows about {impl std::future::Future, ()}
 --> src/main.rs:4:18
  |
4 |   async fn start() {
  |  __________________^
5 | |     a();
6 | |     b().await;
7 | | }
  | |_^

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 (0e4a56b4b 2019-06-13) running on x86_64-unknown-linux-gnu

Meta

rustc --version --verbose:

rustc 1.37.0-nightly (0e4a56b4b 2019-06-13)
binary: rustc
commit-hash: 0e4a56b4b04ea98bb16caada30cb2418dd06e250
commit-date: 2019-06-13
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0

Backtrace:

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:578:9
stack backtrace:
   0:     0x7ff89049918b - backtrace::backtrace::libunwind::trace::h41595b2657878dbc
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1:     0x7ff89049918b - backtrace::backtrace::trace_unsynchronized::h4efe511900bf5e12
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2:     0x7ff89049918b - std::sys_common::backtrace::_print::h7275b63687b21f98
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x7ff89049918b - std::sys_common::backtrace::print::h790c12384440cac4
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x7ff89049918b - std::panicking::default_hook::{{closure}}::he6cba1bdf748f1c3
                               at src/libstd/panicking.rs:198
   5:     0x7ff890498e8c - std::panicking::default_hook::h1296d9a476e7a9c2
                               at src/libstd/panicking.rs:212
   6:     0x7ff88e1d33f1 - rustc::util::common::panic_hook::ha2e96a0b919e5a1a
   7:     0x7ff8904999e9 - std::panicking::rust_panic_with_hook::h8d2408723e9a2bd4
                               at src/libstd/panicking.rs:479
   8:     0x7ff88f733b51 - std::panicking::begin_panic::h99404a5a8c9393e6
   9:     0x7ff88f731a56 - rustc_errors::Handler::span_bug::h490e1671e2e515c8
  10:     0x7ff88f4eeb52 - rustc::util::bug::opt_span_bug_fmt::{{closure}}::hdb0241a0d138b557
  11:     0x7ff88f4ec61a - rustc::ty::context::tls::with_opt::{{closure}}::hc463290490e6bd93
  12:     0x7ff88f4ec580 - rustc::ty::context::tls::with_context_opt::h864c92ca64bcd209
  13:     0x7ff88f4ec5c7 - rustc::ty::context::tls::with_opt::h0139b8ed23799d5b
  14:     0x7ff88f4eea48 - rustc::util::bug::opt_span_bug_fmt::he42ee4c44975fb76
  15:     0x7ff88f4ee9fa - rustc::util::bug::span_bug_fmt::hc2a12a0744cb6581
  16:     0x7ff88f64c420 - rustc_mir::transform::generator::compute_layout::h59cccf9a051dc6e9
  17:     0x7ff88f64e7f2 - <rustc_mir::transform::generator::StateTransform as rustc_mir::transform::MirPass>::run_pass::h5455abb94d103444
  18:     0x7ff88f3e8c1d - rustc_mir::transform::run_passes::{{closure}}::hc5896914630654b8
  19:     0x7ff88f3e88c4 - rustc_mir::transform::run_passes::h31e820477fdcc7cc
  20:     0x7ff88f3e982f - rustc_mir::transform::optimized_mir::hcdb77108b4828931
  21:     0x7ff88e166e7d - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute::ha863b92e11001b35
  22:     0x7ff88dd1ad08 - rustc::dep_graph::graph::DepGraph::with_task_impl::h3c249e1459ce4cf0
  23:     0x7ff88dfeb98c - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h6f6a4849e78cab89
  24:     0x7ff88e24a178 - rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt>::layout_raw_uncached::h51deb19f7091cba9
  25:     0x7ff88e247473 - rustc::ty::layout::layout_raw::hcd1f01e2c83e8363
  26:     0x7ff88ddcae79 - rustc::ty::query::__query_compute::layout_raw::hab67f82b3fd58a77
  27:     0x7ff88e167d4a - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::layout_raw>::compute::hbd5a4cb7a97851aa
  28:     0x7ff88dd13118 - rustc::dep_graph::graph::DepGraph::with_task_impl::h177648ace895bb06
  29:     0x7ff88e032a3b - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::ha2dbb73f32e739a7
  30:     0x7ff88e252764 - <rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of::h08b5157be6aa3f2e
  31:     0x7ff88f447ead - <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_statement::h8a138fa6e5e7dc0e
  32:     0x7ff88f43f849 - <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass::ha6e576a0006a7da8
  33:     0x7ff88f3e8c1d - rustc_mir::transform::run_passes::{{closure}}::hc5896914630654b8
  34:     0x7ff88f3e88c4 - rustc_mir::transform::run_passes::h31e820477fdcc7cc
  35:     0x7ff88f3e982f - rustc_mir::transform::optimized_mir::hcdb77108b4828931
  36:     0x7ff88e166e7d - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute::ha863b92e11001b35
  37:     0x7ff88dd1ad08 - rustc::dep_graph::graph::DepGraph::with_task_impl::h3c249e1459ce4cf0
  38:     0x7ff88dfeb98c - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h6f6a4849e78cab89
  39:     0x7ff88f5f54fd - rustc_mir::monomorphize::collector::collect_items_rec::h706317fcd2797400
  40:     0x7ff88f5f61f1 - rustc_mir::monomorphize::collector::collect_items_rec::h706317fcd2797400
  41:     0x7ff88f4985cd - rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}::h13f4d3024d161e1e
  42:     0x7ff88f473447 - rustc::util::common::time::h48c2bfe2820c85e9
  43:     0x7ff88f5f47ea - rustc_mir::monomorphize::collector::collect_crate_mono_items::ha257437826f5d63f
  44:     0x7ff88f47382d - rustc::util::common::time::hdc18f22e136943a2
  45:     0x7ff88f657d59 - rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items::h75572e8d5100e04f
  46:     0x7ff88634635a - rustc::ty::query::__query_compute::collect_and_partition_mono_items::h6384799bc0dd81e7
  47:     0x7ff886374889 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute::hdcf5909d894cd534
  48:     0x7ff88630edfa - rustc::dep_graph::graph::DepGraph::with_task_impl::h18e4d6354f7571f6
  49:     0x7ff88638176b - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h27044e0b5cb11e01
  50:     0x7ff88641f6cf - rustc_codegen_ssa::base::codegen_crate::h74b58a2ac9b23913
  51:     0x7ff88641cc8a - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate::h50e9412946ee1e63
  52:     0x7ff88feb3d67 - rustc::util::common::time::haa32cafeeb3d54cb
  53:     0x7ff88fe5f13b - rustc_interface::passes::start_codegen::hcdb1e9299570ccd1
  54:     0x7ff88fe46317 - rustc::ty::context::tls::enter_global::h5d834d2634f7fc92
  55:     0x7ff88fe5f941 - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h10a967fa77f2b087
  56:     0x7ff88febbb05 - rustc_interface::passes::create_global_ctxt::{{closure}}::h7a059b6cf199597d
  57:     0x7ff88fe5e496 - rustc_interface::passes::BoxedGlobalCtxt::enter::h4a247e90412a9579
  58:     0x7ff88fe48740 - rustc_interface::queries::Query<T>::compute::h595d6a8dccab9742
  59:     0x7ff88ff327e4 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen::h93f94310b1d268e6
  60:     0x7ff89078d840 - rustc_interface::interface::run_compiler_in_existing_thread_pool::h35eddbfcfbbe0eb4
  61:     0x7ff8907ff5f6 - std::thread::local::LocalKey<T>::with::hea85159711765771
  62:     0x7ff890797fb5 - scoped_tls::ScopedKey<T>::set::he08d6211f459724f
  63:     0x7ff8907caad4 - syntax::with_globals::h2c63be024f0c1f38
  64:     0x7ff8907e989d - std::sys_common::backtrace::__rust_begin_short_backtrace::hfc7fb053a9ed90ec
  65:     0x7ff8904aa8da - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:82
  66:     0x7ff8907756d9 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0cd7d8fc1b0a39a3
  67:     0x7ff89047ceef - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::he71721d2d956d451
                               at /rustc/0e4a56b4b04ea98bb16caada30cb2418dd06e250/src/liballoc/boxed.rs:746
  68:     0x7ff8904a95b0 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::he520045b8d28ce5c
                               at /rustc/0e4a56b4b04ea98bb16caada30cb2418dd06e250/src/liballoc/boxed.rs:746
  69:     0x7ff8904a95b0 - std::sys_common::thread::start_thread::h2e98d1272dc6d74b
                               at src/libstd/sys_common/thread.rs:13
  70:     0x7ff8904a95b0 - std::sys::unix::thread::Thread::new::thread_start::h18485805666ccd3c
                               at src/libstd/sys/unix/thread.rs:79
  71:     0x7ff8903d4a92 - start_thread
  72:     0x7ff8902f3cd3 - __clone
  73:                0x0 - <unknown>
query stack during panic:
#0 [optimized_mir] processing `start::{{closure}}#0`
#1 [layout_raw] computing layout of `[static generator@a.rs:4:22: 7:2 {std::future::GenFuture<[static generator@a.rs:3:14: 3:16 {}]>, ()}]`
#2 [optimized_mir] processing `start`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

Metadata

Metadata

Assignees

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-async-awaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions