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

Immovable generator issue #47736

Closed
andreytkachenko opened this issue Jan 25, 2018 · 1 comment
Closed

Immovable generator issue #47736

andreytkachenko opened this issue Jan 25, 2018 · 1 comment
Labels
A-coroutines Area: Coroutines C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@andreytkachenko
Copy link

compiler fails with error when try compile the code:

#![feature(generators, generator_trait, conservative_impl_trait)]

extern crate futures;

use std::ops::{ Generator };
use futures::{ Future, Async };

fn tmp() -> impl Future<Item = u32, Error = ()> {
    futures::future::ok(123)
}

fn gen() -> impl Generator<Yield = Async<u32>, Return = ()> {
    unsafe {static move || {
        let dist = {
            let mut future = tmp();

            loop  {
                match Future::poll(&mut future) {
                    Ok(Async::Ready(e)) => {
                        break Ok(e)
                    }

                    Ok(Async::NotReady) => {}

                    Err(e) => {
                        break Err(e)
                    }
                }

                yield Async::NotReady
            }
        }.unwrap();
        
        match (&dist,) {
            (tmp,) => (),
        }
    }}
}

fn main() {
    let mut g = gen();
    
    println!("{:?}", g.resume());
    
}

and the error message:

error: internal compiler error: librustc_mir/transform/generator.rs:461: Broken MIR: generator contains type u32 in MIR, but typeck only knows about {impl futures::Future, futures::Async<u32>, ()}
  --> src/main.rs:13:13
   |
13 |       unsafe {static move || {
   |  _____________^
14 | |         let dist = {
15 | |             let mut future = tmp();
16 | |
...  |
36 | |         }
37 | |     }}
   | |_____^

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.25.0-nightly (a0dcecff9 2018-01-24) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:456:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:68
             at libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:380
   3: std::panicking::default_hook
             at libstd/panicking.rs:390
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:576
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::span_bug
   7: rustc::session::opt_span_bug_fmt::{{closure}}
   8: rustc::ty::context::tls::with_opt
   9: rustc::session::span_bug_fmt
  10: <rustc_mir::transform::generator::StateTransform as rustc_mir::transform::MirPass>::run_pass
  11: rustc_mir::transform::optimized_mir::{{closure}}
  12: rustc_mir::transform::optimized_mir
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::compute_result
  14: rustc::dep_graph::graph::DepGraph::with_task_impl
  15: rustc_errors::Handler::track_diagnostics
  16: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  17: rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::force
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::try_get
  19: rustc::ty::maps::TyCtxtAt::optimized_mir
  20: rustc::ty::sty::ClosureSubsts::field_tys
  21: rustc_mir::borrow_check::nll::type_check::TypeChecker::typeck_mir
  22: rustc_mir::borrow_check::nll::type_check::type_check_internal
  23: rustc::ty::context::tls::enter
  24: rustc::infer::InferCtxtBuilder::enter
  25: <rustc_mir::borrow_check::nll::type_check::TypeckMir as rustc_mir::transform::MirPass>::run_pass
  26: rustc_mir::transform::mir_const::{{closure}}
  27: rustc_mir::transform::mir_const
  28: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::compute_result
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc_errors::Handler::track_diagnostics
  31: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  32: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::force
  33: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::try_get
  34: rustc::ty::maps::TyCtxtAt::mir_const
  35: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const
  36: rustc_mir::transform::mir_validated
  37: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::compute_result
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc_errors::Handler::track_diagnostics
  40: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  41: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::force
  42: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::try_get
  43: rustc::ty::maps::TyCtxtAt::mir_validated
  44: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_validated
  45: rustc_borrowck::borrowck::borrowck
  46: rustc::dep_graph::graph::DepGraph::with_task_impl
  47: rustc_errors::Handler::track_diagnostics
  48: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  49: rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::force
  50: rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::try_get
  51: rustc::ty::maps::TyCtxtAt::borrowck
  52: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::borrowck
  53: rustc_borrowck::borrowck::check_crate
  54: <std::thread::local::LocalKey<T>>::with
  55: <std::thread::local::LocalKey<T>>::with
  56: rustc_driver::driver::compile_input
  57: rustc_driver::run_compiler
@PaulGrandperrin
Copy link

I'm also hitting this bug

@cuviper cuviper added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-coroutines Area: Coroutines labels Jan 27, 2018
@bors bors closed this as completed in 5647356 Feb 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coroutines Area: Coroutines C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants