Closed
Description
The compiler panics with certain combinations of enum variants with trait objects. See the minimal example below.
I tried this code:
use std::fmt::Debug;
#[derive(Debug)]
pub enum E {
A(TraitChild),
}
pub trait TraitParent: Debug{}
pub trait TraitChild: TraitParent {}
I expected to see this happen: A error message or the compiler passing fine
Instead, this happened: The compiler paniced
Meta
$ cargo rustc -- --version --verbose
Compiling compiler-bug v0.1.0 (file:///tmp/compiler-bug)
rustc 1.7.0 (a5d1e7a59 2016-02-29)
binary: rustc
commit-hash: a5d1e7a59a2a3413c377b003075349f854304b5e
commit-date: 2016-02-29
host: x86_64-unknown-linux-gnu
release: 1.7.0
$ cargo rustc -- --version --verbose
Compiling compiler-bug v0.1.0 (file:///tmp/compiler-bug)
rustc 1.9.0-nightly (5ab11d72c 2016-04-02)
binary: rustc
commit-hash: 5ab11d72cab23f0cea63cbf7a88817ff2a45bab0
commit-date: 2016-04-02
host: x86_64-unknown-linux-gnu
release: 1.9.0-nightly
Backtrace:
(build with stable release)
$ RUST_BACKTRACE=1 cargo build
Compiling compiler-bug v0.1.0 (file:///tmp/compiler-bug)
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: E for ty=E', ../src/librustc_trans/trans/type_of.rs:391
stack backtrace:
1: 0x7f320079dd50 - sys::backtrace::tracing::imp::write::hf7e21f48f7cb711bEju
2: 0x7f32007a4bf5 - panicking::default_handler::_<closure>::closure.42502
3: 0x7f32007a465e - panicking::default_handler::hac4d0be12e3129d2Gwy
4: 0x7f320076d416 - sys_common::unwind::begin_unwind_inner::hf13a3e016c1e78e1bct
5: 0x7f320076de18 - sys_common::unwind::begin_unwind_fmt::h878e9fd8b85e0857hbt
6: 0x7f31fec7800d - trans::type_of::in_memory_type_of::h593071fa1c7a88b5IUR
7: 0x7f31feca1827 - trans::type_of::arg_type_of::h3d363dab76b0535a6SR
8: 0x7f31fed56b10 - trans::type_of::type_of_rust_fn::h5d71e0357c84d3abDER
9: 0x7f31fec98a3c - trans::declare::declare_rust_fn::h52167f891835ed397yC
10: 0x7f31fecc6cf5 - trans::base::register_fn::hffc4a9f6758ed15cGlk
11: 0x7f31fecc8891 - trans::base::register_method::hef8bc997fd575557JLk
12: 0x7f31fecc22e3 - trans::base::get_item_val::h0a9a752f98588e3d2xk
13: 0x7f31fecc018d - trans::base::trans_item::h756f54b4e629ccb0Odk
14: 0x7f31fecd9e4a - trans::base::TransItemsWithinModVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h3b5bc0bcbe5b15a04dl
15: 0x7f31feccb827 - trans::base::trans_crate::h226b7eed3e3bb400zXk
16: 0x7f3200cd5df4 - driver::phase_4_translate_to_llvm::h876e6f0b6afd272d5Ta
17: 0x7f3200ccbba6 - driver::phase_3_run_analysis_passes::_<closure>::closure.26772
18: 0x7f3200cac45d - middle::ty::context::ctxt<'tcx>::create_and_enter::h11454974807351631650
19: 0x7f3200ca7d52 - driver::phase_3_run_analysis_passes::h12040458575817631055
20: 0x7f3200c788cb - driver::compile_input::h71d4e311662cb5e0nca
21: 0x7f3200c69e2b - run_compiler::h002f3bf18be58fd27wc
22: 0x7f3200c66c61 - sys_common::unwind::try::try_fn::h13318254547800529440
23: 0x7f320079bb18 - __rust_try
24: 0x7f320079332b - sys_common::unwind::try::inner_try::h7232ca0b9dac160cJ8s
25: 0x7f3200c66fc0 - boxed::F.FnBox<A>::call_box::h7593089220679888244
26: 0x7f32007a2dc3 - sys::thread::Thread::new::thread_start::h93f164b37c9b35e1Ctx
27: 0x7f31f9d136f9 - start_thread
28: 0x7f320041a2dc - clone
29: 0x0 - <unknown>
Could not compile `compiler-bug`.
To learn more, run the command again with --verbose.