Skip to content

Struct with a field of an associated type crashes in librustc_trans::trans::debuginfo #21010

@lifthrasiir

Description

@lifthrasiir
$ rustc -V
rustc 1.0.0-nightly (44a287e6e 2015-01-08 17:03:40 -0800)

$ cat t.rs
#![allow(unstable)]
#![crate_type="lib"]

// minimized from Chrono

pub trait OffsetState: Sized {}
pub trait Offset { type State: OffsetState; }

#[derive(Copy)] pub struct X;
impl Offset for X { type State = Y; }

#[derive(Copy)] pub struct Y;
impl OffsetState for Y {}

pub fn now() -> DateTime<X> { from_utc(Y) }

pub struct DateTime<Off: Offset> { pub offset: Off::State }
pub fn from_utc<Off: Offset>(offset: Off::State) -> DateTime<Off> { DateTime { offset: offset } }

$ rustc t.rs

$ RUST_BACKTRACE=1 rustc t.rs -g
error: internal compiler error: type_of with ty_projection
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.
rs:182

stack backtrace:
   1:     0x7f6e1bf91850 - sys::backtrace::write::h5b05e7b061a35107Czt
   2:     0x7f6e1bfb3a60 - failure::on_fail::h1e9b7e3de59488d1aPz
   3:     0x7f6e1bf215e0 - rt::unwind::begin_unwind_inner::h23dcfb4c37870bd62tz
   4:     0x7f6e16d16460 - rt::unwind::begin_unwind::h8180555736548804672
   5:     0x7f6e16d16d10 - diagnostic::Handler::bug::hfea99a1512d774b6tWF
   6:     0x7f6e1a26e0d0 - session::Session::bug::hda4aef05452f83daiRq
   7:     0x7f6e1af3eea0 - trans::type_of::type_of::h6cd1e104e1fe3019W0o
   8:     0x7f6e1af3eea0 - trans::type_of::type_of::h6cd1e104e1fe3019W0o
   9:     0x7f6e1b05ea80 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45597
  10:     0x7f6e1b05e660 - vec::Vec<T>.FromIterator<T>::from_iter::h17630431296221110156
  11:     0x7f6e1b05a600 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::h1ce61219403e8b66j9E
  12:     0x7f6e1b05d1e0 - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h47e619ecda26460e26E
  13:     0x7f6e1b056690 - trans::debuginfo::type_metadata::hf4b354653499ed02RSF
  14:     0x7f6e1b0648d0 - trans::debuginfo::subroutine_type_metadata::h6024a307b42d4766vOF
  15:     0x7f6e1b056690 - trans::debuginfo::type_metadata::hf4b354653499ed02RSF
  16:     0x7f6e1affd340 - trans::debuginfo::create_function_debug_context::h5c5f6eb95d461ae4wsE
  17:     0x7f6e1af5d0f0 - trans::base::new_fn_ctxt::hdc7fe29d7b0922abZxt
  18:     0x7f6e1b002c70 - trans::base::trans_closure::h1947fd5123bfe895EYt
  19:     0x7f6e1af21b10 - trans::base::trans_fn::h5d061f11fc4ac1e7j9t
  20:     0x7f6e1af1d0a0 - trans::base::trans_item::h34ec82732f0498f3Ewu
  21:     0x7f6e1b00a490 - trans::base::trans_crate::he5ffa45aaa619f67lsv
  22:     0x7f6e1c4ef3c0 - driver::phase_4_translate_to_llvm::h98aea3c7bb04643bPFa
  23:     0x7f6e1c4c9350 - driver::compile_input::h04aea004c559b910xba
  24:     0x7f6e1c598fe0 - monitor::unboxed_closure.22497
  25:     0x7f6e1c598e40 - thunk::F.Invoke<A, R>::invoke::h11849311349984608396
  26:     0x7f6e1c597bc0 - rt::unwind::try::try_fn::h13617610205470131813
  27:     0x7f6e1c0196c0 - rust_try_inner
  28:     0x7f6e1c0196b0 - rust_try
  29:     0x7f6e1c597eb0 - thunk::F.Invoke<A, R>::invoke::h14452289732390470265
  30:     0x7f6e1bfa1910 - sys::thread::thread_start::h93b0d38960a9fcacqrw
  31:     0x7f6e165330c0 - start_thread
  32:     0x7f6e1bbc6ec9 - __clone
  33:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions