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

ICE using associated type from trait implemented for reference type #23406

Closed
jcmoyer opened this issue Mar 16, 2015 · 1 comment
Closed

ICE using associated type from trait implemented for reference type #23406

jcmoyer opened this issue Mar 16, 2015 · 1 comment
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jcmoyer
Copy link
Contributor

jcmoyer commented Mar 16, 2015

Minimal code to reproduce:

trait Inner {
    type T;
}

impl<'a> Inner for &'a i32 {
    type T = i32;
}

fn f<'a>(x: &'a i32) -> <&'a i32 as Inner>::T {
    *x
}

fn main() {}

I was actually trying to implement this for &'a Option<T> so I could get the T out of Option<T>, but this produces the same error (although with &'a Option<T> I get a different backtrace, and it doesn't ICE until I actually use the function - so I'm not sure if it's a separate issue or not). It does not ICE when the references are removed, i.e. impl Inner for i32 and f(x: i32) -> <i32 as Inner>::T. Same for the Option<T> case.

Version:

rustc 1.0.0-nightly (30e1f9a1c 2015-03-14) (built 2015-03-15)
binary: rustc
commit-hash: 30e1f9a1c2bf7134135800bc9afd082773defadc
commit-date: 2015-03-14
build-date: 2015-03-15
host: i686-unknown-linux-gnu
release: 1.0.0-nightly

Error message and backtrace:

error: internal compiler error: fictitious type <&'static i32 as Inner>::T in sizing_type_of()
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
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:190

stack backtrace:
   1:   0xfe0a14 - sys::backtrace::write::hc52363cb69d92d49YyC
   2:  0x1007933 - panicking::on_panic::haa4c63d646619106OGI
   3:   0xf31989 - rt::unwind::begin_unwind_inner::h3622bffc67b74defmnI
   4: 0x1a4700fa - rt::unwind::begin_unwind::h17473118271825318944
   5: 0x1a4709ce - diagnostic::Handler::bug::ha5af5744723c82a6lgB
   6:  0x6c92b78 - session::Session::bug::h7830cc258e0a71f48vn
   7:   0x61e93f - trans::type_of::sizing_type_of::h65ea81377c3e14831wo
   8:   0x646f82 - trans::common::type_is_immediate::hf913e55ab71352abADk
   9:   0x6e91a4 - trans::type_of::type_of_rust_fn::he4cc5eff6b6755ba0ro
  10:   0x6f1ee3 - trans::base::decl_rust_fn::ha6f27bbe2af80566Qsr
  11:   0x701081 - trans::base::register_fn::ha69eafedc56aaa9590t
  12:   0x5fc507 - trans::base::get_item_val::h067715933c9d99b7Vnu
  13:   0x5f902a - trans::base::trans_item::h7f6909c63808f532CSt
  14:   0x706006 - trans::base::trans_crate::hea1a13db65a44e5ffPu
  15:   0x8f51ca - driver::phase_4_translate_to_llvm::h406ec02b84c498ackOa
  16:   0x8cef6e - driver::compile_input::hf7e4519402c8bacfRba
  17:   0x994888 - run_compiler::h3c0938d24865bfd7x2b
  18:   0x992209 - thunk::F.Invoke<A, R>::invoke::h12389329639459538829
  19:   0x9912a6 - rt::unwind::try::try_fn::h2311466047322169838
  20:  0x1088f7a - rust_try_inner
  21:  0x1088f53 - rust_try
  22:   0x99177e - thunk::F.Invoke<A, R>::invoke::h15816452122554159345
  23:   0xff60f4 - sys::thread::thread_start::h8d422a9a48991e61B1G
  24:   0x4d5d4b - start_thread
  25:   0x1ff9dd - <unknown>
@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 16, 2015
@steveklabnik
Copy link
Member

This still ICEs for me on today's nightly.

bltavares added a commit to bltavares/glacier that referenced this issue Oct 31, 2015
@nikomatsakis nikomatsakis added the A-associated-items Area: Associated items (types, constants & functions) label Nov 4, 2015
eefriedman added a commit to eefriedman/rust that referenced this issue Nov 14, 2015
bors added a commit that referenced this issue Nov 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants