Skip to content

rustc panics on deriving Debug for an Enum containing a Variant with a Trait member #29283

Closed
@lschmelzeisen

Description

@lschmelzeisen

rustc panics if one tries to compile a file, where Debug is derived for an enum that contains a constructor with a trait member, when the trait extends Debug.

Compile following file bug.rs fails:

#[derive(Debug)]
enum A{
    B(C),
}

trait C: std::fmt::Debug {}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.3.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.3.0

RUST_BACKTRACE=1 rustc bug.rs:

bug.rs:2:1: 4:2 warning: enum is never used: `A`, #[warn(dead_code)] on by default
bug.rs:2 enum A{
bug.rs:3     B(C),
bug.rs:4 }
error: internal compiler error: unexpected panic
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 'Unexpected type returned from struct_tail: A for ty=A', src/librustc_trans/trans/type_of.rs:373

stack backtrace:
   1:     0x7f73575f466e - sys::backtrace::write::ha67a6a2049d22fadIvs
   2:     0x7f73575fcd55 - panicking::on_panic::hfa4bf0215983f759lzx
   3:     0x7f73575bd94e - rt::unwind::begin_unwind_inner::ha1b5da93bdf7e8ffC0w
   4:     0x7f73575be6b6 - rt::unwind::begin_unwind_fmt::hac9e09b20e42a51cIZw
   5:     0x7f73563d6409 - trans::type_of::in_memory_type_of::h23715c0ef212ea6fCmN
   6:     0x7f73563d8031 - trans::type_of::type_of::h8550e66cb849440e0lN
   7:     0x7f735649249e - trans::type_of::type_of_rust_fn::h6ec65cf6a94d2c69Y9M
   8:     0x7f73563e0707 - trans::declare::declare_rust_fn::h23ae5856407a285cI0A
   9:     0x7f7356408022 - trans::base::register_fn::h0e113c195f5606edUoj
  10:     0x7f735640a0be - trans::base::register_method::hf4a5efbc19bfaa61rPj
  11:     0x7f735640344a - trans::base::get_item_val::h3ba0fb4a6fd13470BBj
  12:     0x7f7356400305 - trans::base::trans_item::hd3ac3af06c93993fPdj
  13:     0x7f735640c40c - trans::base::trans_crate::h14e6ea6d455593f8i0j
  14:     0x7f7357b632f4 - driver::phase_4_translate_to_llvm::h8ce7c7bfb0fd9b185Oa
  15:     0x7f7357b5d885 - driver::phase_3_run_analysis_passes::closure.16542
  16:     0x7f7357b57ab1 - middle::ty::ctxt<'tcx>::create_and_enter::h9578579149294230291
  17:     0x7f7357b52991 - driver::phase_3_run_analysis_passes::h8415522514568150077
  18:     0x7f7357b36a90 - driver::compile_input::h52c7dafd49963360Tba
  19:     0x7f7357c1ca63 - run_compiler::h473c62e00f865fa9A7b
  20:     0x7f7357c1a4de - boxed::F.FnBox<A>::call_box::h10713159552398332324
  21:     0x7f7357c19e09 - rt::unwind::try::try_fn::h16887904248528792425
  22:     0x7f73575fc84d - __rust_try
  23:     0x7f73575e78f7 - rt::unwind::try::inner_try::hafffff77ddacfa5fvWw
  24:     0x7f7357c1a028 - boxed::F.FnBox<A>::call_box::h5417278073590676257
  25:     0x7f73575fb991 - sys::thread::Thread::new::thread_start::h29dca2a2cf2294b535v
  26:     0x7f7351e9b4a3 - start_thread
  27:     0x7f735725913c - clone
  28:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions