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 #61770

Closed
nextzhou opened this issue Jun 12, 2019 · 1 comment

Comments

Projects
None yet
4 participants
@nextzhou
Copy link

commented Jun 12, 2019

I tried this code:

#![feature(async_await)]
use futures::executor::ThreadPool;

struct N{}
impl Drop for N {
    fn drop(&mut self) { println!("drop n") }
}

fn main() -> Result<(), std::io::Error> {
    let rc = std::rc::Rc::new(N{});
    ThreadPool::new()?.run(async {
        let mut fs = Vec::new();
        for _ in 0..100000 {
            fs.push(async {rc.clone()})
        }
        for f in fs {
            f.await;
        }
    });
    Ok(())
}

this happened:

error: internal compiler error: src/librustc_mir/transform/generator.rs:540: Broken MIR: generator contains type std::rc::Rc<N> in MIR, but typeck only knows about for<'r, 's, 't0, 't1> {std::vec::Vec<impl core::future::future::Future>, fn(std::vec::Vec<impl core::future::future::Future>) -> <std::vec::Vec<impl core::future::future::Future> as std::iter::IntoIterator>::IntoIter {<std::vec::Vec<impl core::future::future::Future> as std::iter::IntoIterator>::into_iter}, std::vec::IntoIter<impl core::future::future::Future>, impl core::future::future::Future, ()}
  --> src/main.rs:11:34
   |
11 |       ThreadPool::new()?.run(async {
   |  __________________________________^
12 | |         let mut fs = Vec::new();
13 | |         for _ in 0..100000 {
14 | |             fs.push(async {rc.clone()})
...  |
18 | |         }
19 | |     });
   | |_____^

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:573:9

Meta

rustc --version --verbose:

rustc 1.37.0-nightly (5f3656ce9 2019-06-11)
binary: rustc
commit-hash: 5f3656ce9a2212fad872605b7a4ee103a155e9f3
commit-date: 2019-06-11
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::StateTransform as rustc_mir::transform::MirPass>::run_pass
  17: rustc_mir::transform::run_passes::{{closure}}
  18: rustc_mir::transform::run_passes
  19: rustc_mir::transform::optimized_mir
  20: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  21: rustc::dep_graph::graph::DepGraph::with_task_impl
  22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  23: rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt>::layout_raw_uncached
  24: rustc::ty::layout::layout_raw
  25: rustc::ty::query::__query_compute::layout_raw
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::layout_raw>::compute
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  29: <rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  30: <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_statement
  31: <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass
  32: rustc_mir::transform::run_passes::{{closure}}
  33: rustc_mir::transform::run_passes
  34: rustc_mir::transform::optimized_mir
  35: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  36: rustc::dep_graph::graph::DepGraph::with_task_impl
  37: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  38: rustc_mir::monomorphize::collector::collect_items_rec
  39: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
  40: rustc::util::common::time
  41: rustc_mir::monomorphize::collector::collect_crate_mono_items
  42: rustc::util::common::time
  43: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  44: rustc::ty::query::__query_compute::collect_and_partition_mono_items
  45: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute
  46: rustc::dep_graph::graph::DepGraph::with_task_impl
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  48: rustc_codegen_ssa::base::codegen_crate
  49: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  50: rustc::util::common::time
  51: rustc_interface::passes::start_codegen
  52: rustc::ty::context::tls::enter_global
  53: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  54: rustc_interface::passes::create_global_ctxt::{{closure}}
  55: rustc_interface::passes::BoxedGlobalCtxt::enter
  56: rustc_interface::queries::Query<T>::compute
  57: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
  58: rustc_interface::interface::run_compiler_in_existing_thread_pool
  59: std::thread::local::LocalKey<T>::with
  60: scoped_tls::ScopedKey<T>::set
  61: 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::{{closure}}#0`
#1 [layout_raw] computing layout of `[static generator@src/main.rs:11:34: 19:6 rc:&std::rc::Rc<N> for<'r, 's, 't0, 't1> {std::vec::Vec<impl core::future::future::Future>, fn(std::vec::Vec<impl core::future::future::Future>) -> <std::vec::Vec<impl core::future::future::Future> as std::iter::IntoIterator>::IntoIter {<std::vec::Vec<impl core::future::future::Future> as std::iter::IntoIterator>::into_iter}, std::vec::IntoIter<impl core::future::future::Future>, impl core::future::future::Future, ()}]`
#2 [optimized_mir] processing `main`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error
@mati865

This comment has been minimized.

Copy link
Contributor

commented Jun 12, 2019

Duplicate of #61442

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.