Skip to content

Compiler Error: trying to take the sizing type of A, an unsized type #17622

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

Closed
DanSimon opened this issue Sep 29, 2014 · 1 comment
Closed

Compiler Error: trying to take the sizing type of A, an unsized type #17622

DanSimon opened this issue Sep 29, 2014 · 1 comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@DanSimon
Copy link

Hi, I've been giving rust a try and hit my first compiler bug today. I was playing around with traits and ran into an error with the following code:

trait A{
  fn as_A(&self) -> &A {self}
}
impl<T> A for T {}

trait B: A {
  fn as_B(&self) -> &B {self}
}
impl<T> B for T{}


fn main() {
  let i = 5i;
  let a: &A = i.as_A();
  let b: &B = a.as_B();

}

In particular it seems it's the last line in main that breaks things, if I comment that out it compiles (and runs) without issue.

Here's output from rustc:

error: internal compiler error: trying to take the sizing type of A, an unsized type
note: the compiler hit an unexpected failure path. 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
task 'rustc' failed at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:169

stack backtrace:
   1:        0x10989b379 - rt::backtrace::imp::write::h2414555c4c37a887I3q
   2:        0x10989e6d1 - failure::on_fail::h1701d0172e857b91mkr
   3:        0x109b250e5 - unwind::begin_unwind_inner::h88d806fd0639a3f8PQd
   4:        0x1078cfcf7 - unwind::begin_unwind::h4539702463021714404
   5:        0x1078d0503 - diagnostic::Handler::bug::hd29f0a8937d8d898OnF
   6:        0x106529788 - driver::session::Session::bug::hd2c0dce8f59c4470H8w
   7:        0x1068d3cf0 - middle::trans::type_of::sizing_type_of::h313347362780bbe6uA9
   8:        0x106902f76 - middle::trans::meth::get_vtable::h23eb4b91988d1ee1CAk
   9:        0x10690244b - middle::trans::expr::apply_adjustments::unsized_info::h2fa4212e33caf84cE32
  10:        0x106904666 - middle::trans::expr::apply_adjustments::unsize_expr::closure.123231
  11:        0x10690488f - middle::trans::expr::apply_adjustments::into_fat_ptr::h47c26a86c19956e7Xa3
  12:        0x106901a77 - middle::trans::expr::apply_adjustments::apply_autoref::h7b9d1991ca519eb3BQ2
  13:        0x10690133e - middle::trans::expr::apply_adjustments::apply_autoref::h7b9d1991ca519eb3BQ2
  14:        0x1068c2eea - middle::trans::expr::trans::hdc96210c715b5b95PE2
  15:        0x1068c0ca2 - middle::trans::expr::trans_into::hfe3428499c973cb55A2
  16:        0x1068c1224 - middle::trans::controlflow::trans_block::h1e499b6fd0a7e6e5JJY
  17:        0x10696e0c0 - middle::trans::base::trans_closure::haf692ac5faf172742Le
  18:        0x1068b3f18 - middle::trans::base::trans_fn::hdec6118bfe3b4ab7fXe
  19:        0x1068b58af - middle::trans::monomorphize::monomorphic_fn::h864824dfcc4e7eceCbY
  20:        0x1068eb542 - middle::trans::callee::trans_fn_ref_with_substs::h673f3c4696e53bccgv1
  21:        0x1068e81ab - middle::trans::callee::trans_fn_ref::hf20ab71f600338cdQj1
  22:        0x1068c9fb3 - middle::trans::meth::trans_method_callee::hfdc6530e298ffac4A3j
  23:        0x1068f097b - middle::trans::callee::trans_method_call::closure.123088
  24:        0x1068c86d4 - middle::trans::callee::trans_call_inner::h301f3b9e709a1322YQ1
  25:        0x1068f07a7 - middle::trans::callee::trans_method_call::h67d120293015b7dcrM1
  26:        0x1068fe68a - middle::trans::expr::trans_rvalue_dps_unadjusted::h54db2681bd07dae8lY3
  27:        0x1068fd3b6 - middle::trans::expr::trans_unadjusted::h9cc2b45c52809552Jl3
  28:        0x1068c22d8 - middle::trans::expr::trans::hdc96210c715b5b95PE2
  29:        0x1068c0ca2 - middle::trans::expr::trans_into::hfe3428499c973cb55A2
  30:        0x10699902e - middle::trans::_match::store_local::closure.127328
  31:        0x106998e95 - middle::trans::_match::mk_binding_alloca::h9094225994960386624
  32:        0x1069653ed - middle::trans::_match::store_local::h947208861053437209h
  33:        0x1068c048a - middle::trans::base::init_local::h2aaa53b640774791CUd
  34:        0x1068bfa28 - middle::trans::controlflow::trans_stmt::ha7f02b72ef27a137NEY
  35:        0x1068c1128 - middle::trans::controlflow::trans_block::h1e499b6fd0a7e6e5JJY
  36:        0x10696e0c0 - middle::trans::base::trans_closure::haf692ac5faf172742Le
  37:        0x1068b3f18 - middle::trans::base::trans_fn::hdec6118bfe3b4ab7fXe
  38:        0x1068b13ba - middle::trans::base::trans_item::he6ebd92b5686816fogf
  39:        0x1069776a8 - middle::trans::base::trans_crate::h2c2cc9b3b16c339cEgg
  40:        0x106d7e2c5 - driver::driver::phase_4_translate_to_llvm::hee626525d2620f45Fzw
  41:        0x106d77043 - driver::driver::compile_input::hc14952e9836c6a78L6v
  42:        0x106df5354 - driver::run_compiler::h030d1894305ee9d6DWz
  43:        0x106df3546 - driver::main_args::closure.146018
  44:        0x10655793b - task::TaskBuilder<S>::try_future::closure.101302
  45:        0x106557833 - task::TaskBuilder<S>::spawn_internal::closure.101273
  46:        0x1064d233d - task::spawn_opts::closure.8577
  47:        0x109b895ec - rust_try_inner
  48:        0x109b895d6 - rust_try
  49:        0x109b224f7 - unwind::try::h30d9faee9b52a896xFd
  50:        0x109b2236c - task::Task::run::hd688c2a33087bff5MVc
  51:        0x1064d2192 - task::spawn_opts::closure.8516
  52:        0x109b2402a - thread::thread_start::hb8f9fbaf424323191fd
  53:     0x7fff88b84899 - _pthread_body
  54:     0x7fff88b8472a - _pthread_struct_init

I am using rustc 0.12.0-nightly (94b0aace1 2014-09-27 23:12:54 +0000) on OS X 10.9.4

@huonw huonw added A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Sep 29, 2014
@erickt
Copy link
Contributor

erickt commented Jan 12, 2015

Looke like this no longer ICE-s:

trait A {
    fn as_A(&self) -> &A {self}
}
impl<T> A for T {}

trait B: A {
    fn as_B(&self) -> &B {self}
}
impl<T> B for T{}

fn main() {
    let i = 5;
    let a: &A = i.as_A();
    let b: &B = a.as_B();

}

Now produces:

bad2.rs:2:27: 2:31 error: the trait `core::marker::Sized` is not implemented for the type `Self`
bad2.rs:2     fn as_A(&self) -> &A {self}
                                    ^~~~
bad2.rs:7:27: 7:31 error: the trait `core::marker::Sized` is not implemented for the type `Self`
bad2.rs:7     fn as_B(&self) -> &B {self}
                                    ^~~~

Which seems like the right error message. Please reopen if you are still having trouble.
Please reopen if you are still

@erickt erickt closed this as completed Jan 12, 2015
lnicola pushed a commit to lnicola/rust that referenced this issue Jul 28, 2024
fix: handle synonymous imports with different renaming in 'merge imports'

fix rust-lang#17602
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 1, 2024
fix: handle synonymous imports with different renaming in 'merge imports'

fix rust-lang#17602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants