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

src/librustc_mir/transform/generator.rs:715: Broken MIR #62126

Closed
gila opened this issue Jun 25, 2019 · 1 comment
Closed

src/librustc_mir/transform/generator.rs:715: Broken MIR #62126

gila opened this issue Jun 25, 2019 · 1 comment

Comments

@gila
Copy link

gila commented Jun 25, 2019

The minimal code that reproduces the issue:

#![feature(async_await)]
use futures::{executor::LocalPool, future, task::LocalSpawnExt};

async fn do_something(s: String) -> Result<String, String> {
    Ok(s)
}

async fn do_it() {
    for i in 0 ..= 3 {
        let s = format!("test-{}", i);
        let result = do_something(s).await;
        // when removing the dbg!() the code compiles 
        dbg!(result);
    }
}

#[test]
fn mir_error() {
    let mut p = LocalPool::new();
    let mut s = p.spawner();
    s.spawn_local(do_it()).unwrap();
    p.run_until_stalled();
}

Getting the following error:

  --> spdk-rs/tests/for.rs:8:18
   |
8  |   async fn do_it() {
   |  __________________^
9  | |     for i in 0 ..= 3 {
10 | |         let s = format!("test-{}", i);
11 | |         let result = do_something(s).await;
12 | |         dbg!(result);
13 | |     }
14 | | }
   | |_^

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:578:9
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>::force_query
  24: rustc::ty::query::plumbing::force_from_dep_node
  25: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  26: rustc::dep_graph::graph::DepGraph::try_mark_green
  27: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  28: <rustc::ty::layout::LayoutCx<rustc::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  29: <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_statement
  30: <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass
  31: rustc_mir::transform::run_passes::{{closure}}
  32: rustc_mir::transform::run_passes
  33: rustc_mir::transform::optimized_mir
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: rustc_mir::monomorphize::collector::collect_items_rec
  38: rustc_mir::monomorphize::collector::collect_items_rec
  39: rustc_mir::monomorphize::collector::collect_items_rec
  40: rustc_mir::monomorphize::collector::collect_items_rec
  41: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
  42: rustc::util::common::time
  43: rustc_mir::monomorphize::collector::collect_crate_mono_items
  44: rustc::util::common::time
  45: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  46: rustc::ty::query::__query_compute::collect_and_partition_mono_items
  47: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute
  48: rustc::dep_graph::graph::DepGraph::with_task_impl
  49: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  50: rustc_codegen_ssa::base::codegen_crate
  51: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  52: rustc::util::common::time
  53: rustc_interface::passes::start_codegen
  54: rustc::ty::context::tls::enter_global
  55: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  56: rustc_interface::passes::create_global_ctxt::{{closure}}
  57: rustc_interface::passes::BoxedGlobalCtxt::enter
  58: rustc_interface::queries::Query<T>::compute
  59: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
  60: rustc_interface::interface::run_compiler_in_existing_thread_pool
  61: std::thread::local::LocalKey<T>::with
  62: scoped_tls::ScopedKey<T>::set
  63: 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 `do_it::{{closure}}#0`
#1 [layout_raw] computing layout of `[static generator@spdk-rs/tests/for.rs:8:18: 14:2 {fn(std::ops::RangeInclusive<i32>) -> <std::ops::RangeInclusive<i32> as std::iter::IntoIterator>::IntoIter {<std::ops::RangeInclusive<i32> as std::iter::IntoIterator>::into_iter}, fn(i32, i32) -> std::ops::RangeInclusive<i32> {std::ops::RangeInclusive::<i32>::new}, i32, std::ops::RangeInclusive<i32>, std::string::String, std::future::GenFuture<[static generator@spdk-rs/tests/for.rs:4:60: 6:2 s:std::string::String {}]>, ()}]`
#2 [optimized_mir] processing `do_it`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

Meta

rustc 1.37.0-nightly (8aa42ed7c 2019-06-24)
binary: rustc
commit-hash: 8aa42ed7c2adb9f37faa6eb905f890f6199e1db9
commit-date: 2019-06-24
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0

I think this might be somewhat related to #62025 and perhaps #61442 but i'll leave that to the experts.

@cramertj
Copy link
Member

Fixed in #61872

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants