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

Mir: Value-like struct initializer fails to compile #30514

Closed
nagisa opened this issue Dec 21, 2015 · 0 comments
Closed

Mir: Value-like struct initializer fails to compile #30514

nagisa opened this issue Dec 21, 2015 · 0 comments
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@nagisa
Copy link
Member

nagisa commented Dec 21, 2015

#![feature(rustc_attrs)]

struct A;

#[rustc_mir(graphviz="foo.gv")]
fn mir() {
    A;
}

fn main() {
    mir();
}

Will fail with

error: internal compiler error: expected closure or fn
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
thread 'rustc' panicked at 'Box<Any>', src/libsyntax/errors/mod.rs:230
stack backtrace:
   1:     0x7f95437b48ee - sys::backtrace::tracing::imp::write::hf6d5c8e3c66fa27b19t
   2:     0x7f95437bb9d5 - panicking::log_panic::closure.41821
   3:     0x7f95437bb475 - panicking::log_panic::h144dc9280b7645fcjhy
   4:     0x7f95437828e3 - sys_common::unwind::begin_unwind_inner::h55d5feb426745bbeX0s
   5:     0x7f953f88f437 - sys_common::unwind::begin_unwind::h9096788442279507124
   6:     0x7f953f88f7f4 - errors::Handler::bug::h4aa521e1f5a0e236f2c
   7:     0x7f9540c34a2c - session::Session::bug::hdc71a3fb8a9de8b66Qr
   8:     0x7f954211fdd5 - trans::declare::declare_rust_fn::h3499333bf3b164a8ybC
   9:     0x7f954218e65c - trans::declare::define_internal_rust_fn::hca6541cf5ddec74cRlC
  10:     0x7f9542180d8e - trans::monomorphize::monomorphic_fn::h4e88fa61c342a4b4OyP
  11:     0x7f9542232972 - trans::mir::did::MirContext<'bcx, 'tcx>::trans_fn_ref::h55237ed814e0e1dd6rP
  12:     0x7f954222ed02 - trans::mir::constant::MirContext<'bcx, 'tcx>::trans_constant::h277fbb9a4164ee637qO
  13:     0x7f954222d715 - trans::mir::operand::MirContext<'bcx, 'tcx>::trans_operand::h1ccc23113196f11cpbP
  14:     0x7f954222f264 - trans::mir::rvalue::MirContext<'bcx, 'tcx>::trans_rvalue::h3fd0006d084b3140KFO
  15:     0x7f954222d5d5 - trans::mir::statement::MirContext<'bcx, 'tcx>::trans_statement::hd3d43f205659cc06llP
  16:     0x7f954213f525 - trans::mir::trans_mir::ha8bcfa1e861a5f5fqNN
  17:     0x7f954213a878 - trans::base::trans_closure::haef7ad19910b1872Adj
  18:     0x7f9542142b4c - trans::base::trans_fn::h663accb72c321f7bJnj
  19:     0x7f9542147117 - trans::base::trans_item::h2e72d9aa09c9cb4fwNj
  20:     0x7f9542153715 - trans::base::trans_crate::hf6ee98bf37c50fb1Ezk
  21:     0x7f9543ceaeea - driver::phase_4_translate_to_llvm::h3282cc6c2caab9027Ua
  22:     0x7f9543ce4c87 - driver::phase_3_run_analysis_passes::closure.23230
  23:     0x7f9543cc29d5 - middle::ty::context::ctxt<'tcx>::create_and_enter::h5420659107844287102
  24:     0x7f9543cbe139 - driver::phase_3_run_analysis_passes::h5834150331257021912
  25:     0x7f9543ca1cbd - driver::compile_input::h623a21a74ad11852jca
  26:     0x7f9543e03b2b - run_compiler::h1b7d8da52bbb04c7Vyc
  27:     0x7f9543e00d58 - sys_common::unwind::try::try_fn::h4212622780748696621
  28:     0x7f95437b25e8 - __rust_try
  29:     0x7f95437a967b - sys_common::unwind::try::inner_try::hb757dfa83a0260eavXs
  30:     0x7f9543e01080 - boxed::F.FnBox<A>::call_box::h10788927616206636218
  31:     0x7f95437b9c63 - sys::thread::Thread::new::thread_start::h65b91c47bba3fbc3wjx
  32:     0x7f953d4754a3 - start_thread
  33:     0x7f954344713c - clone
  34:                0x0 - <unknown>

The reason is that we assign ItemKind::Struct to this kind of unit-structs, and then unconditionally try to translate these as if they were a functions (which holds true for tuple-like structs, but not unit-like structs).

@luqmana luqmana added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Dec 22, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Dec 25, 2015
Fixes rust-lang#30514

i also went ahead and removed the redundant `ItemKind`s.

r? @nikomatsakis (this is an easy one I guess)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants