Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken MIR: generator contains type std::vec::Vec<()> #62025

Closed
shiewa opened this issue Jun 21, 2019 · 8 comments

Comments

Projects
None yet
6 participants
@shiewa
Copy link

commented Jun 21, 2019

I tried this code:

#![feature(await_macro, async_await)]
#![recursion_limit = "128"]
pub const LIMIT: usize = 50;

#[runtime::main(runtime_tokio::Tokio)]
async fn main() {
            let text = "123\n456\n789";
            let lines = text.lines();

            for i in 0..(lines.size_hint().0 / LIMIT) {
                let mut futures = Vec::new();

                let ids = lines.clone().skip(i * LIMIT).take(LIMIT);
                for id in ids {
                    futures.push(scrape(id.to_string()));
                }

                futures::future::join_all(futures).await;
            }
}

async fn scrape(_line: String) {
    // do something
}

I get the following error:

error: internal compiler error: src/librustc_mir/transform/generator.rs:715: Broken MIR: generator contains type std::vec::Vec<()> in MIR, but typeck only knows about for<'r, 's, 't0, 't1, 't2> {&'r str, std::str::Lines<'s>, fn(std::ops::Range<usize>) -> <std::ops::Range<usize> as std::iter::IntoIterator>::IntoIter {<std::ops::Range<usize> as std::iter::IntoIterator>::into_iter}, usize, &'t0 std::str::Lines<'t1>, (usize, std::option::Option<usize>), std::ops::Range<usize>, std::vec::Vec<impl core::future::future::Future>, std::iter::Take<std::iter::Skip<std::str::Lines<'t2>>>, futures_util::future::join_all::JoinAll<impl core::future::future::Future>, ()}
 --> src/main.rs:5:1
  |
5 | #[runtime::main(runtime_tokio::Tokio)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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 (1d9981f04 2019-06-20) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `example`.

To learn more, run the command again with --verbose.

Meta

Installed crates:

  • runtime v0.3.0-alpha.5
  • runtime-tokio v0.3.0-alpha.5
  • futures-preview v0.3.0-alpha.16

rustc --version --verbose;

rustc 1.37.0-nightly (1d9981f04 2019-06-20)
binary: rustc
commit-hash: 1d9981f04e8957345205c07adc2742886420ac37
commit-date: 2019-06-20
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0

Backtrace:

stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:212
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:479
   8: std::panicking::begin_panic
   9: rustc_errors::Handler::span_bug
  10: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc::ty::context::tls::with_opt::{{closure}}
  12: rustc::ty::context::tls::with_context_opt
  13: rustc::ty::context::tls::with_opt
  14: rustc::util::bug::opt_span_bug_fmt
  15: rustc::util::bug::span_bug_fmt
  16: rustc_mir::transform::generator::compute_layout
  17: <rustc_mir::transform::generator::StateTransform as rustc_mir::transform::MirPass>::run_pass
  18: rustc_mir::transform::run_passes::{{closure}}
  19: rustc_mir::transform::run_passes
  20: rustc_mir::transform::optimized_mir
  21: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  22: rustc::dep_graph::graph::DepGraph::with_task_impl
  23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  24: rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt>::layout_raw_uncached
  25: rustc::ty::layout::layout_raw
  26: rustc::ty::query::__query_compute::layout_raw
  27: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::layout_raw>::compute
  28: rustc::dep_graph::graph::DepGraph::with_task_impl
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  30: <rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  31: <&mut I as core::iter::traits::iterator::Iterator>::next
  32: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  33: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  34: rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt>::layout_raw_uncached
  35: rustc::ty::layout::layout_raw
  36: rustc::ty::query::__query_compute::layout_raw
  37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::layout_raw>::compute
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: <rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  41: <&mut I as core::iter::traits::iterator::Iterator>::next
  42: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  43: <&mut I as core::iter::traits::iterator::Iterator>::next
  44: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  45: rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt>::layout_raw_uncached
  46: rustc::ty::layout::layout_raw
  47: rustc::ty::query::__query_compute::layout_raw
  48: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::layout_raw>::compute
  49: rustc::dep_graph::graph::DepGraph::with_task_impl
  50: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  51: <rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  52: <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_statement
  53: <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass
  54: rustc_mir::transform::run_passes::{{closure}}
  55: rustc_mir::transform::run_passes
  56: rustc_mir::transform::optimized_mir
  57: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  58: rustc::dep_graph::graph::DepGraph::with_task_impl
  59: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  60: rustc_mir::monomorphize::collector::collect_items_rec
  61: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
  62: rustc::util::common::time
  63: rustc_mir::monomorphize::collector::collect_crate_mono_items
  64: rustc::util::common::time
  65: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  66: rustc::ty::query::__query_compute::collect_and_partition_mono_items
  67: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute
  68: rustc::dep_graph::graph::DepGraph::with_task_impl
  69: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  70: rustc_codegen_ssa::base::codegen_crate
  71: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  72: rustc::util::common::time
  73: rustc_interface::passes::start_codegen
  74: rustc::ty::context::tls::enter_global
  75: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  76: rustc_interface::passes::create_global_ctxt::{{closure}}
  77: rustc_interface::passes::BoxedGlobalCtxt::enter
  78: rustc_interface::queries::Query<T>::compute
  79: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
  80: rustc_interface::interface::run_compiler_in_existing_thread_pool
  81: std::thread::local::LocalKey<T>::with
  82: scoped_tls::ScopedKey<T>::set
  83: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [optimized_mir] processing `main::main::{{closure}}#0`
#1 [layout_raw] computing layout of `[static generator@src/main.rs:5:1: 5:39 for<'r, 's, 't0, 't1, 't2> {&'r str, std::str::Lines<'s>, fn(std::ops::Range<usize>) -> <std::ops::Range<usize> as std::iter::IntoIterator>::IntoIter {<std::ops::Range<usize> as std::iter::IntoIterator>::into_iter}, usize, &'t0 std::str::Lines<'t1>, (usize, std::option::Option<usize>), std::ops::Range<usize>, std::vec::Vec<std::future::GenFuture<[static generator@src/main.rs:22:32: 24:2 _line:std::string::String {}]>>, std::iter::Take<std::iter::Skip<std::str::Lines<'t2>>>, futures_util::future::join_all::JoinAll<std::future::GenFuture<[static generator@src/main.rs:22:32: 24:2 _line:std::string::String {}]>>, ()}]`
#2 [layout_raw] computing layout of `std::future::GenFuture<[static generator@src/main.rs:5:1: 5:39 for<'r, 's, 't0, 't1, 't2> {&'r str, std::str::Lines<'s>, fn(std::ops::Range<usize>) -> <std::ops::Range<usize> as std::iter::IntoIterator>::IntoIter {<std::ops::Range<usize> as std::iter::IntoIterator>::into_iter}, usize, &'t0 std::str::Lines<'t1>, (usize, std::option::Option<usize>), std::ops::Range<usize>, std::vec::Vec<std::future::GenFuture<[static generator@src/main.rs:22:32: 24:2 _line:std::string::String {}]>>, std::iter::Take<std::iter::Skip<std::str::Lines<'t2>>>, futures_util::future::join_all::JoinAll<std::future::GenFuture<[static generator@src/main.rs:22:32: 24:2 _line:std::string::String {}]>>, ()}]>`
#3 [layout_raw] computing layout of `[static generator@src/main.rs:5:1: 5:39 {std::future::GenFuture<[static generator@src/main.rs:5:1: 5:39 for<'r, 's, 't0, 't1, 't2> {&'r str, std::str::Lines<'s>, fn(std::ops::Range<usize>) -> <std::ops::Range<usize> as std::iter::IntoIterator>::IntoIter {<std::ops::Range<usize> as std::iter::IntoIterator>::into_iter}, usize, &'t0 std::str::Lines<'t1>, (usize, std::option::Option<usize>), std::ops::Range<usize>, std::vec::Vec<std::future::GenFuture<[static generator@src/main.rs:22:32: 24:2 _line:std::string::String {}]>>, std::iter::Take<std::iter::Skip<std::str::Lines<'t2>>>, futures_util::future::join_all::JoinAll<std::future::GenFuture<[static generator@src/main.rs:22:32: 24:2 _line:std::string::String {}]>>, ()}]>, ()}]`
#4 [optimized_mir] processing `main`
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack```
@mati865

This comment has been minimized.

Copy link
Contributor

commented Jun 21, 2019

Probably duplicate of #61442

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2019

Does this still reproduce?

@zimond

This comment has been minimized.

Copy link

commented Jun 26, 2019

Using 2019-06-25 after #61442 , still reproduce

@mati865

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2019

@zimond the fix landed in 2019-06-26 nightly. Could you try that version?

@zimond

This comment has been minimized.

Copy link

commented Jun 26, 2019

@mati865 The latest nightly is 2019-06-25 with commit tag 5f9c044

@zimond

This comment has been minimized.

Copy link

commented Jun 26, 2019

and I just tested #62126, it's still broken.

@mati865

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2019

@zimond it can be a bit confusing because when you install nightly-2019-06-25 you will get rustc 1.37.0-nightly (8aa42ed7c 2019-06-24). In parentheses you can see included commits date, not nightly version.
At the moment rustup toolchain install nightly is the same as rustup toolchain install nightly-2019-06-26.

Back to the issue, I confirm it has been fixed on the master by #61872. Fix will be available in tomorrows nightly.

@zimond

This comment has been minimized.

Copy link

commented Jun 26, 2019

Yeah.. I just saw the commit log after commenting this. It's indeed fixed, cheers.

@cramertj cramertj closed this Jun 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.