Skip to content

1.27 Internal compiler error while passing a not-variable-bind generator into a macro: #50878

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

Closed
DutchGhost opened this issue May 18, 2018 · 0 comments
Labels
A-coroutines Area: Coroutines A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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

@DutchGhost
Copy link
Contributor

DutchGhost commented May 18, 2018

passing a generator as tmp into a macro caused an ICE:

#![feature(generators, generator_trait)]

use std::ops::{GeneratorState, Generator};

macro_rules! yield_from {
    ($generator:expr) => {
        unsafe {
            loop {
                match $generator.resume() {
                    GeneratorState::Yielded(y) => yield y,
                    GeneratorState::Complete(ret) => break ret,
                }
            }
        }
    };
}


fn main() {
    || {
        yield_from!(|| {
            yield;
        });
        return;
    };
}

Backtrace:

error: internal compiler error: librustc_mir\transform\generator.rs:495: Broken MIR: generator contains type [generator@src\lib.rs:108:25: 110:14 {()}] in MIR, but typeck only knows about for<'r> {&'r mut [generator@src\lib.rs:108:25: 110:14 {()}], std::ops::GeneratorState<(), ()>, ()}
   --> src\lib.rs:107:9
    |
107 | /         || {
108 | |             yield_from!(|| {
109 | |                 yield;
110 | |             });
111 | |             return;
112 | |         };
    | |_________^

thread 'main' panicked at 'Box<Any>', librustc_errors\lib.rs:499:9
stack backtrace:
   0: <std::collections::hash::map::DefaultHasher as core::fmt::Debug>::fmt
   1: <std::sys::windows::dynamic_lib::DynamicLibrary as core::ops::drop::Drop>::drop
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: <rustc::ty::SymbolName as core::fmt::Debug>::fmt
   5: std::panicking::rust_panic_with_hook
   6: <rustc_mir::dataflow::graphviz::Edge as core::fmt::Debug>::fmt
   7: <rustc_mir::transform::uniform_array_move_out::LocalUse as core::fmt::Debug>::fmt
   8: <rustc_mir::transform::qualify_consts::Qualif as core::fmt::UpperHex>::fmt
   9: <rustc_mir::transform::qualify_consts::Qualif as core::fmt::UpperHex>::fmt
  10: <rustc_mir::transform::qualify_consts::Qualif as core::fmt::UpperHex>::fmt
  11: <rustc_mir::transform::qualify_consts::Qualif as core::fmt::UpperHex>::fmt
  12: <rustc_mir::dataflow::impls::borrows::Borrows<'a, 'gcx, 'tcx> as rustc_mir::dataflow::BitDenotation>::start_block_effect
  13: <rustc_mir::dataflow::impls::borrows::Borrows<'a, 'gcx, 'tcx> as rustc_mir::dataflow::BitDenotation>::start_block_effect
  14: <rustc_mir::transform::generator::StateTransform as rustc_mir::transform::MirPass>::run_pass
  15: <rustc_mir::transform::MirSource as core::fmt::Debug>::fmt
  16: rustc_mir::transform::optimized_mir
  17: rustc::ty::query::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::query::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  18: rustc::ty::context::tls::track_diagnostic
  19: rustc::ty::context::tls::track_diagnostic
  20: rustc::dep_graph::graph::DepGraph::assert_ignored
  21: rustc::ty::context::tls::track_diagnostic
  22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  24: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::optimized_mir
  25: rustc_mir::shim::provide
  26: rustc::ty::query::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::query::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  27: rustc::ty::context::tls::track_diagnostic
  28: rustc::ty::context::tls::track_diagnostic
  29: rustc::dep_graph::graph::DepGraph::assert_ignored
  30: rustc::ty::context::tls::track_diagnostic
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  32: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  33: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::instance_mir
  34: rustc_mir::monomorphize::collector::collect_crate_mono_items
  35: rustc_mir::monomorphize::collector::collect_crate_mono_items
  36: rustc_mir::util::def_use::Info::use_count
  37: <rustc_mir::dataflow::impls::borrows::Borrows<'a, 'gcx, 'tcx> as rustc_mir::dataflow::BitDenotation>::start_block_effect
  38: rustc_mir::monomorphize::collector::collect_crate_mono_items
  39: <rustc_codegen_llvm::time_graph::TimelineId as core::fmt::Debug>::fmt
  40: <rustc_codegen_llvm::base::ValueIter as core::iter::iterator::Iterator>::next
  41: rustc::ty::context::tls::track_diagnostic
  42: rustc::ty::context::tls::track_diagnostic
  43: rustc::dep_graph::graph::DepGraph::assert_ignored
  44: rustc::ty::context::tls::track_diagnostic
  45: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  47: <rustc_codegen_llvm::back::linker::MsvcLinker<'a> as rustc_codegen_llvm::back::linker::Linker>::finalize
  48: rustc::ty::context::tls::track_diagnostic
  49: rustc::ty::context::tls::track_diagnostic
  50: rustc::dep_graph::graph::DepGraph::assert_ignored
  51: rustc::ty::context::tls::track_diagnostic
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  53: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  54: <rustc_metadata::encoder::ImplVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  55: rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
  56: rustc::ty::context::TyCtxt::encode_metadata
  57: rustc_codegen_llvm::base::codegen_instance
  58: <rustc_codegen_llvm::time_graph::TimelineId as core::fmt::Debug>::fmt
  59: <rustc_codegen_llvm::base::ValueIter as core::iter::iterator::Iterator>::next
  60: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  61: rustc_driver::target_features::add_configuration
  62: rustc_driver::driver::phase_4_codegen
  63: rustc_driver::profile::dump
  64: <humantime::date::Error as std::error::Error>::cause
  65: <rustc_driver::pretty::IdentifiedAnnotation<'hir> as rustc_driver::pretty::PrinterSupport>::sess
  66: <unknown>
  67: rustc_driver::driver::compile_input
  68: rustc_driver::run_compiler
  69: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  70: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  71: _rust_maybe_catch_panic
  72: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  73: rustc_driver::main
  74: <unknown>
  75: std::panicking::update_panic_count
  76: _rust_maybe_catch_panic
  77: std::rt::lang_start_internal
  78: <unknown>
  79: <unknown>
  80: BaseThreadInitThunk
  81: RtlUserThreadStart
query stack during panic:
#0 [optimized_mir] processing `internal_compiler_errors::broken_mir::{{closure}}`
#1 [mir_shims] generating MIR shim for `std::ptr::drop_in_place`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
#3 [exported_symbols] exported_symbols
end of query stack
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.28.0-nightly (e3bf634e0 2018-06-28) running on x86_64-pc-windows-msvc

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

note: some of the compiler flags provided by cargo are hidden
@DutchGhost DutchGhost changed the title Internal compiler error while passing a not-bind generator into a macro: 1.27 Internal compiler error while passing a not-bind generator into a macro: May 18, 2018
@DutchGhost DutchGhost changed the title 1.27 Internal compiler error while passing a not-bind generator into a macro: 1.27 Internal compiler error while passing a not-variable-bind generator into a macro: May 18, 2018
@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. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. labels May 19, 2018
@Zoxc Zoxc added the A-coroutines Area: Coroutines label Jul 14, 2018
bors added a commit that referenced this issue Aug 15, 2018
Record adjustments and original type for expressions in the generator interior

Fixes #50878 and #52398.

r? @eddyb
bors added a commit that referenced this issue Aug 15, 2018
Record adjustments and original type for expressions in the generator interior

Fixes #50878 and #52398.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coroutines Area: Coroutines A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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