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 with generators #48048

Closed
raviqqe opened this issue Feb 7, 2018 · 1 comment
Closed

Broken MIR with generators #48048

raviqqe opened this issue Feb 7, 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

@raviqqe
Copy link

raviqqe commented Feb 7, 2018

Similar to #44184 but I'm not sure if they have the same cause or not.

#![feature(generators)]

fn main() {
    let x = (|_| {},);

    || {
        let x = x;

        x.0({
            yield;
        });
    };
}

Build log:

> RUST_BACKTRACE=full cargo build               
   Compiling rust-async-await-examples v0.1.0 (file:///home/raviqqe/src/github.com/raviqqe/rust-async-await-examples)
error: internal compiler error: librustc_mir/transform/generator.rs:495: Broken MIR: generator contains type &[closure@src/main.rs:4:14: 4:20] in MIR, but typeck only knows about {([closure@src/main.rs:4:14
: 4:20],), ()}                                                                                                                                
  --> src/main.rs:6:5                                                                                   
   |                                                                                                                                             
6  | /     || {                                                     
7  | |         let x = x;                                                                                                     
8  | |                                                                               
9  | |         x.0({                                                                  
10 | |             yield;                                                         
11 | |         });                                                       
12 | |     };                                                   
   | |_____^                                                                                  
                                           
thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:482:9
stack backtrace:                                                             
   0: 0xb0df70b3 - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h0e675f09d0ea6efb
                       at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: 0xb0dee0d7 - std::sys_common::backtrace::_print::hab188ab7e2264fa5
                       at libstd/sys_common/backtrace.rs:71
   2: 0xb0df3b63 - std::panicking::default_hook::{{closure}}::h6de89401c7cfba88
                       at libstd/sys_common/backtrace.rs:59
                       at libstd/panicking.rs:380
   3: 0xb0df37a3 - std::panicking::default_hook::h77c5e57344ea1784                                               
                       at libstd/panicking.rs:396
   4: 0xb0df402b - std::panicking::rust_panic_with_hook::h25665bb68f9c33fc                
                       at libstd/panicking.rs:576
   5: 0xb03f0eff - std::panicking::begin_panic::hf4ea98dd652225c7
   6: 0xb03eb53b - rustc_errors::Handler::span_bug::he0e663394c58146e
   7: 0xb042ddc3 - rustc::session::opt_span_bug_fmt::{{closure}}::haf4055a290286ee8
   8: 0xb042dc97 - rustc::session::span_bug_fmt::hee67d12eca98dbd4
   9: 0xb0531463 - <rustc_mir::transform::generator::StateTransform as rustc_mir::transform::MirPass>::run_pass::had9d05b7ba1db7f2
  10: 0xb058f9c7 - rustc_mir::transform::optimized_mir::{{closure}}::h7ce2e52ae25ea6aa
  11: 0xb053a543 - rustc_mir::transform::optimized_mir::h445785565316d102
  12: 0xafe5977b - rustc::dep_graph::graph::DepGraph::with_task_impl::h3a29a7f629570871
  13: 0xb010f97b - rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::force::h7b56c39bb8303000
  14: 0xb01100bf - rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::try_get::h5633b7bfd050e56c
  15: 0xb01f8aa3 - rustc::ty::maps::TyCtxtAt::optimized_mir::h25db50b902f2c8d6
  16: 0xb01f618f - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::optimized_mir::h5882e75dd3b20368
  17: 0xb0500c2b - rustc_mir::shim::make_shim::hc8d2a6409593d7a0
  18: 0xafe6959b - rustc::dep_graph::graph::DepGraph::with_task_impl::h978a41a5ecd39563
  19: 0xb013917b - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_shims<'tcx>>::force::hb539e45b421eb998
  20: 0xb0139a37 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_shims<'tcx>>::try_get::h89de7c175fc7a084
  21: 0xb01f9a77 - rustc::ty::maps::TyCtxtAt::mir_shims::hfd281ebae9f5e7f2
  22: 0xb0073247 - rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::instance_mir::h3beb5ac11f8f3252
  23: 0xb057eb9b - rustc_mir::monomorphize::collector::collect_items_rec::hedb90edba41840ef
  24: 0xb057f6f7 - rustc_mir::monomorphize::collector::collect_items_rec::hedb90edba41840ef
  25: 0xb057d8a3 - rustc_mir::monomorphize::collector::collect_crate_mono_items::h6c068d30b04615ad
  26: 0xac0f2bcb - rustc_trans::base::collect_and_partition_translation_items::he0b50da974cf616b
  27: 0xafe53203 - rustc::dep_graph::graph::DepGraph::with_task_impl::h175249ac280b602a
  28: 0xb01d60a3 - rustc::ty::maps::<impl rustc::ty::maps::queries::collect_and_partition_translation_items<'tcx>>::force::hc7f3cedff79b2e40
  29: 0xb01d687f - rustc::ty::maps::<impl rustc::ty::maps::queries::collect_and_partition_translation_items<'tcx>>::try_get::hc14bee7a47d847cc
  30: 0xb01fdb47 - rustc::ty::maps::TyCtxtAt::collect_and_partition_translation_items::hfe44aa4a7c757c20
  31: 0xb01f725b - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::collect_and_partition_translation_items::h3b09465602c4412e
  32: 0xac0ef0d3 - rustc_trans::base::trans_crate::h7d2492fa073d403b
  33: 0xac14bb93 - <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate::h0375a1b8d27d3d45
  34: 0xb0f788cb - rustc_driver::driver::phase_4_translate_to_llvm::h1ef6b9e392ff1ffb
  35: 0xb0f73133 - rustc_driver::driver::compile_input::{{closure}}::h0c654196b84b4f55
  36: 0xb0f08637 - rustc::ty::context::TyCtxt::create_and_enter::h93711c24bd13b118
  37: 0xb0f71833 - rustc_driver::driver::compile_input::hd3b772952eb5ec6d
  38: 0xb0f88f4f - rustc_driver::run_compiler::hfc7537ef811b8b4e
  39: 0xb0ebf447 - std::sys_common::backtrace::__rust_begin_short_backtrace::h12654191a5e25e74
  40: 0xb0e085ef - __rust_maybe_catch_panic
                       at libpanic_unwind/lib.rs:102
  41: 0xb0ef5327 - <F as alloc::boxed::FnBox<A>>::call_box::h0c2113b4a6bfc4a2
  42: 0xb0e01bb7 - std::sys::unix::thread::Thread::new::thread_start::hb2b6d7bbaa9b84de
                       at /checkout/src/liballoc/boxed.rs:798
                       at libstd/sys_common/thread.rs:24
                       at libstd/sys/unix/thread.rs:90

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 (29c8276ce 2018-02-07) running on armv7-unknown-linux-gnueabihf

error: Could not compile `rust-async-await-examples`.

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

Workaround

Define a temporary variable explicitly.

#![feature(generators)]

fn main() {
    let x = (|_| {},);

    || {
        let x = x;

        let f = x.0;

        f({
            yield;
        });
    };
}

Meta

rustc --version --verbose

rustc 1.25.0-nightly (29c8276ce 2018-02-07)
binary: rustc
commit-hash: 29c8276cee4a0eab7e0634ff25c6b47bd9f87c6c
commit-date: 2018-02-07
host: armv7-unknown-linux-gnueabihf
release: 1.25.0-nightly
LLVM version: 4.0

cat /etc/os-release

NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

uname -a

Linux localhost 3.14.0 #1 SMP PREEMPT Mon Jan 8 23:10:11 PST 2018 armv7l GNU/Linux
@kennytm kennytm 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 Feb 7, 2018
@eddyb
Copy link
Member

eddyb commented Feb 7, 2018

cc @Zoxc @nikomatsakis

raviqqe added a commit to raviqqe/flame that referenced this issue Feb 8, 2018
kennytm added a commit to kennytm/rust that referenced this issue Feb 9, 2018
Fix visitation order of calls so that it matches execution order. Fixes rust-lang#48048

r? @nikomatsakis
kennytm added a commit to kennytm/rust that referenced this issue Feb 10, 2018
Fix visitation order of calls so that it matches execution order. Fixes rust-lang#48048

r? @nikomatsakis
@bors bors closed this as completed in 774997d Feb 10, 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