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

ICE with generators and impl Trait: "Cannot create local trans-item" #44181

Closed
plietar opened this Issue Aug 30, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@plietar
Copy link
Contributor

plietar commented Aug 30, 2017

I've hit an ICE with the new generator support that has just landed (nightly c11f689 2017-08-29).

I've reduced it to the following :

// lib.rs
#![feature(conservative_impl_trait, generators, generator_trait)]

use std::ops::Generator;

fn msg() -> String { format!("Hello, {}!" , "world") }

pub fn foo() -> impl Generator<Yield=(), Return=String> {
    || {
        yield;
        return msg();
    }
}
// main.rs
#![feature(conservative_impl_trait, generator_trait)]

extern crate foo;

use std::ops::Generator;

fn main() {
    foo::foo().resume();
}
error: internal compiler error: src/librustc_trans/collector.rs:739: Cannot create local trans-item for DefId { krate: CrateNum(12), node: DefIndex(4) => foo/e088486::msg[0] }

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.21.0-nightly (c11f689d2 2017-08-29) running on x86_64-apple-darwin

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

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:496:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: rustc_errors::Handler::bug
   6: rustc::session::opt_span_bug_fmt::{{closure}}
   7: rustc::session::opt_span_bug_fmt
   8: rustc::session::bug_fmt
   9: rustc_trans::collector::should_trans_locally
  10: rustc_trans::collector::visit_instance_use
  11: <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
  12: rustc::mir::visit::Visitor::visit_mir
  13: rustc_trans::collector::collect_items_rec
  14: rustc_trans::collector::collect_items_rec
  15: rustc_trans::base::collect_and_partition_translation_items::{{closure}}
  16: rustc_trans::base::trans_crate
  17: rustc_driver::driver::phase_4_translate_to_llvm
  18: rustc_driver::driver::compile_input::{{closure}}
  19: rustc::ty::context::TyCtxt::create_and_enter
  20: rustc_driver::driver::compile_input
  21: rustc_driver::run_compiler

This is essentially the same issue as #43135. I can't reproduce the original ICE with closures as described there, but I run into it with generators.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 30, 2017

I believe this ICE is more related to "impl Trait" rather than generators, but we'll find out!

@arielb1

This comment has been minimized.

Copy link
Contributor

arielb1 commented Aug 30, 2017

I think f2df185 also needs to be adapted for generators.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 31, 2017

@arielb1 looks like you're spot on! Thanks for the pointer!

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Aug 31, 2017

Rollup merge of rust-lang#44202 - alexcrichton:xcrate-generators, r=a…
…rielb1

rustc: Fix reachability with cross-crate generators

Same solution as in f2df185

Closes rust-lang#44181

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Sep 1, 2017

Rollup merge of rust-lang#44202 - alexcrichton:xcrate-generators, r=a…
…rielb1

rustc: Fix reachability with cross-crate generators

Same solution as in f2df185

Closes rust-lang#44181

@bors bors closed this in 41d3e83 Sep 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment