Skip to content

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

Closed
@plietar

Description

@plietar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coroutinesArea: CoroutinesA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions