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

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

Closed
lschmelzeisen opened this issue Oct 24, 2015 · 2 comments

Comments

@lschmelzeisen
Copy link

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>
@lschmelzeisen
Copy link
Author

Also panics on nightly.

rustc --version --verbose:

rustc 1.5.0-nightly (7beebbe56 2015-10-22)
binary: rustc
commit-hash: 7beebbe564fa0c93c7c224c75c98a81c23ed42d9
commit-date: 2015-10-22
host: x86_64-unknown-linux-gnu
release: 1.5.0-nightly

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:385
stack backtrace:
   1:     0x7fd5e45263e0 - sys::backtrace::tracing::imp::write::h88824fa7cde382fcamt
   2:     0x7fd5e452ccb5 - panicking::log_panic::_<closure>::closure.39651
   3:     0x7fd5e452c725 - panicking::log_panic::h6e56f24ee89301beimx
   4:     0x7fd5e44f0063 - sys_common::unwind::begin_unwind_inner::h4469900167bcc3a4efs
   5:     0x7fd5e44f09c8 - sys_common::unwind::begin_unwind_fmt::h3d525738d0e295e8kes
   6:     0x7fd5e3a24252 - trans::type_of::in_memory_type_of::ha83e24ebd5c0460fNNN
   7:     0x7fd5e3a36c97 - trans::type_of::arg_type_of::h56c2a4c873c0a26fbMN
   8:     0x7fd5e3aff6ae - trans::type_of::type_of_rust_fn::h29e768c9f0be56885xN
   9:     0x7fd5e3a310fe - trans::declare::declare_rust_fn::hd7b899e52fe7c39aAEA
  10:     0x7fd5e3a5f345 - trans::base::register_fn::hfa00ae8d65b318b270i
  11:     0x7fd5e3a60e51 - trans::base::register_method::hf91d920ea3378723grj
  12:     0x7fd5e3a594fb - trans::base::get_item_val::hbd738babbb4d7e93ydj
  13:     0x7fd5e3a56595 - trans::base::trans_item::h4980eeed9cb665cdMRi
  14:     0x7fd5e3a63ba3 - trans::base::trans_crate::h9f7ce6cf717c6143JDj
  15:     0x7fd5e4a04dbc - driver::phase_4_translate_to_llvm::hce73529426bb2908EPa
  16:     0x7fd5e49fed41 - driver::phase_3_run_analysis_passes::_<closure>::closure.21915
  17:     0x7fd5e49df463 - middle::ty::context::_<impl>::create_and_enter::create_and_enter::h17188378283146851130
  18:     0x7fd5e49da45e - driver::phase_3_run_analysis_passes::h13798991786934394891
  19:     0x7fd5e49baca2 - driver::compile_input::h21f7caa6eac185d17ba
  20:     0x7fd5e4b11b8b - run_compiler::h0d0562bdd0cad39chqc
  21:     0x7fd5e4b0ec06 - sys_common::unwind::try::try_fn::try_fn::h8047687583817760752
  22:     0x7fd5e4524108 - __rust_try
  23:     0x7fd5e451815b - sys_common::unwind::try::inner_try::hcc921df9d6a17f8fMbs
  24:     0x7fd5e4b0ef54 - boxed::_<impl>::call_box::call_box::h1436226236130625411
  25:     0x7fd5e452b783 - sys::thread::_<impl>::new::thread_start::hea8939a5a657d2e7wEw
  26:     0x7fd5ddc07a50 - start_thread
  27:     0x7fd5e41c593c - clone
  28:                0x0 - <unknown>

@sfackler
Copy link
Member

Unsized enums don't work at all right now, unfortunately.

Dup of #16812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants