Skip to content

internal compiler error: trying to take the sizing type of str, an unsized type #17351

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
mikedilger opened this issue Sep 17, 2014 · 16 comments · Fixed by #19780
Closed

internal compiler error: trying to take the sizing type of str, an unsized type #17351

mikedilger opened this issue Sep 17, 2014 · 16 comments · Fixed by #19780
Labels
A-DSTs Area: Dynamically-sized types (DSTs) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@mikedilger
Copy link
Contributor

I just compiled a project that compiled fine until tonight's nightly (but my previous nightly was up to a week before), and the backtrace looks very similar to #16848 (btw: I don't think the warning at the top is related, because after fixing it I still get the same error).

src/main.rs:85:25: 85:51 warning: use of deprecated item: use into_iter, #[warn(deprecated)] on by default
src/main.rs:85     for serverconfig in config.servers.move_iter() {
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~

error: internal compiler error: trying to take the sizing type of str, 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>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/ast_util.rs:694

stack backtrace:
   1:     0x7f2e84b7eb80 - rt::backtrace::imp::write::hadb95304cd6b59a2iHq
   2:     0x7f2e84b81d40 - failure::on_fail::h88a79ad90b452a8dK2q
   3:     0x7f2e85331f60 - unwind::begin_unwind_inner::hd810389f34a8dc8bMTd
   4:     0x7f2e80f92570 - unwind::begin_unwind::h883036773483107899
   5:     0x7f2e80f92d10 - diagnostic::Handler::bug::ha03a127ac108cb809ND
   6:     0x7f2e85712040 - driver::session::Session::bug::hd8091c59ae3b07effyx
   7:     0x7f2e85af8300 - middle::trans::type_of::sizing_type_of::h12d44c3ad0a509b9NP9
   8:     0x7f2e85b27670 - middle::trans::meth::get_vtable::h71ff864a2270cfc0kOk
   9:     0x7f2e85b27000 - middle::trans::expr::apply_adjustments::unsized_info::h8041c4d8f81d7431Gl3
  10:     0x7f2e85b2a0e0 - middle::trans::expr::apply_adjustments::unsize_expr::closure.124122
  11:     0x7f2e85b2a220 - middle::trans::expr::apply_adjustments::into_fat_ptr::h012bc185249de733Zs3
  12:     0x7f2e85b25db0 - middle::trans::expr::apply_adjustments::apply_autoref::hff612d8b5d90a70cD82
  13:     0x7f2e85b25db0 - middle::trans::expr::apply_adjustments::apply_autoref::hff612d8b5d90a70cD82
  14:     0x7f2e85ae5960 - middle::trans::expr::trans::h139fd41d89b98122RW2
  15:     0x7f2e85ae4420 - middle::trans::expr::trans_into::hffcd0924abd4fea27S2
  16:     0x7f2e85bc9be0 - middle::trans::tvec::write_content::hd73973faa21b5330vPj
  17:     0x7f2e85b2d780 - middle::trans::tvec::trans_slice_vec::h65d0df732c3725d4PEj
  18:     0x7f2e85b21f10 - middle::trans::expr::trans_unadjusted::hb5708bd9b995e003LD3
  19:     0x7f2e85ae5960 - middle::trans::expr::trans::h139fd41d89b98122RW2
  20:     0x7f2e85b1ab20 - middle::trans::callee::trans_args::h40ba956d7101922f4r2
  21:     0x7f2e85aec7c0 - middle::trans::callee::trans_call_inner::hea87a946e0cffa34961
  22:     0x7f2e85b155b0 - middle::trans::callee::trans_method_call::h5a0bf5976bce0583C21
  23:     0x7f2e85b22da0 - middle::trans::expr::trans_rvalue_dps_unadjusted::h6f9547e6400812f9Sc4
  24:     0x7f2e85b21f10 - middle::trans::expr::trans_unadjusted::hb5708bd9b995e003LD3
  25:     0x7f2e85ae5960 - middle::trans::expr::trans::h139fd41d89b98122RW2
  26:     0x7f2e85b1ab20 - middle::trans::callee::trans_args::h40ba956d7101922f4r2
  27:     0x7f2e85aec7c0 - middle::trans::callee::trans_call_inner::hea87a946e0cffa34961
  28:     0x7f2e85b155b0 - middle::trans::callee::trans_method_call::h5a0bf5976bce0583C21
  29:     0x7f2e85b22da0 - middle::trans::expr::trans_rvalue_dps_unadjusted::h6f9547e6400812f9Sc4
  30:     0x7f2e85b21f10 - middle::trans::expr::trans_unadjusted::hb5708bd9b995e003LD3
  31:     0x7f2e85ae5960 - middle::trans::expr::trans::h139fd41d89b98122RW2
  32:     0x7f2e85b1ab20 - middle::trans::callee::trans_args::h40ba956d7101922f4r2
  33:     0x7f2e85aec7c0 - middle::trans::callee::trans_call_inner::hea87a946e0cffa34961
  34:     0x7f2e85b155b0 - middle::trans::callee::trans_method_call::h5a0bf5976bce0583C21
  35:     0x7f2e85b22da0 - middle::trans::expr::trans_rvalue_dps_unadjusted::h6f9547e6400812f9Sc4
  36:     0x7f2e85b21f10 - middle::trans::expr::trans_unadjusted::hb5708bd9b995e003LD3
  37:     0x7f2e85ae5960 - middle::trans::expr::trans::h139fd41d89b98122RW2
  38:     0x7f2e85b2c9c0 - middle::trans::expr::trans_binary::h5983843557b2865dyf5
  39:     0x7f2e85b21f10 - middle::trans::expr::trans_unadjusted::hb5708bd9b995e003LD3
  40:     0x7f2e85ae4420 - middle::trans::expr::trans_into::hffcd0924abd4fea27S2
  41:     0x7f2e85ae4900 - middle::trans::controlflow::trans_block::h697fa29e838af1025ZY
  42:     0x7f2e85b92810 - middle::trans::base::trans_closure::hf5f648fb424f9c93r1e
  43:     0x7f2e85ad6b60 - middle::trans::base::trans_fn::h17dae15f71272d8eEcf
  44:     0x7f2e85b96490 - middle::trans::meth::trans_impl::h5b1ebd2bcbfeba03Xck
  45:     0x7f2e85ad3780 - middle::trans::base::trans_item::h7f0dc64cc8095e95Nvf
  46:     0x7f2e85ad3780 - middle::trans::base::trans_item::h7f0dc64cc8095e95Nvf
  47:     0x7f2e85ad3780 - middle::trans::base::trans_item::h7f0dc64cc8095e95Nvf
  48:     0x7f2e85b9e780 - middle::trans::base::trans_crate::h40ab1d2d17a4f286Gtg
  49:     0x7f2e85f98330 - driver::driver::phase_4_translate_to_llvm::h9eab234cedcf7a6b7Yw
  50:     0x7f2e85f8f590 - driver::driver::compile_input::h06caa00e975ed0209ww
  51:     0x7f2e860126b0 - driver::run_compiler::h30663c3fdd061b12FnA
  52:     0x7f2e86012590 - driver::main_args::closure.146245
  53:     0x7f2e85740740 - task::TaskBuilder<S>::try_future::closure.101946
  54:     0x7f2e85740530 - task::TaskBuilder<S>::spawn_internal::closure.101917
  55:     0x7f2e8691e590 - task::spawn_opts::closure.8444
  56:     0x7f2e85389480 - rust_try_inner
  57:     0x7f2e85389470 - rust_try
  58:     0x7f2e8532f560 - unwind::try::h985905ef4937434euId
  59:     0x7f2e8532f3c0 - task::Task::run::h3a7021021ab3297dfYc
  60:     0x7f2e8691e300 - task::spawn_opts::closure.8384
  61:     0x7f2e85330fb0 - thread::thread_start::h67b84fc708de7e36rid
  62:     0x7f2e84645100 - start_thread
  63:     0x7f2e8500c929 - clone
  64:                0x0 - <unknown>
@nrc nrc added the A-DSTs Area: Dynamically-sized types (DSTs) label Sep 17, 2014
@nrc
Copy link
Member

nrc commented Sep 17, 2014

cc me

@mikedilger
Copy link
Contributor Author

@nick29581

@nrc
Copy link
Member

nrc commented Sep 18, 2014

@mikedilger could you paste the code that gave the error here please?

@mikedilger
Copy link
Contributor Author

I have narrowed it down to the last statement of this function:

fn check_user(&self, username: &str) -> bool
{
    let conn = self.superconn.as_ref().unwrap();

    let stmt = conn.prepare(
        "SELECT 1 FROM pg_roles WHERE rolname=$1" )
        .unwrap_or_else(|e| {
            fail!("Could not check if database role {} exists (prepare): {}",username,e)
        });

    stmt.query(&[&username])
        .unwrap_or_else(|e| {
            fail!("Could not check if database role {} exists (query): {}",username,e)
        })
        .count() > 0;
}

It might be triggered by the &[&username] with username being an &str (involving rust-postgres ToSql). @sfackler might have more insight on that

This compiled fine on a recent nightly from commit 21d1f4d

@vhbit
Copy link
Contributor

vhbit commented Sep 18, 2014

Same issue. Haven't yet tried to minimize the case.
Full code

I believe it started after trait reform landed (e86c87a).

@sfackler
Copy link
Member

@nick29581 super minimal example:

fn main() {
    let _: &[&Clone] = &[&"hi"];
}
error: internal compiler error: trying to take the sizing type of str, 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>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/ast_util.rs:694

stack backtrace:
   1:     0x7f9a5d8f0b80 - rt::backtrace::imp::write::hadb95304cd6b59a2iHq
   2:     0x7f9a5d8f3d40 - failure::on_fail::h88a79ad90b452a8dK2q
   3:     0x7f9a5e0a0f60 - unwind::begin_unwind_inner::hd810389f34a8dc8bMTd
   4:     0x7f9a59d06570 - unwind::begin_unwind::h883036773483107899
   5:     0x7f9a59d06d10 - diagnostic::Handler::bug::ha03a127ac108cb809ND
   6:     0x7f9a5e481040 - driver::session::Session::bug::hd8091c59ae3b07effyx
   7:     0x7f9a5e867300 - middle::trans::type_of::sizing_type_of::h12d44c3ad0a509b9NP9
   8:     0x7f9a5e896670 - middle::trans::meth::get_vtable::h71ff864a2270cfc0kOk
   9:     0x7f9a5e896000 - middle::trans::expr::apply_adjustments::unsized_info::h8041c4d8f81d7431Gl3
  10:     0x7f9a5e8990e0 - middle::trans::expr::apply_adjustments::unsize_expr::closure.124122
  11:     0x7f9a5e899220 - middle::trans::expr::apply_adjustments::into_fat_ptr::h012bc185249de733Zs3
  12:     0x7f9a5e894db0 - middle::trans::expr::apply_adjustments::apply_autoref::hff612d8b5d90a70cD82
  13:     0x7f9a5e894db0 - middle::trans::expr::apply_adjustments::apply_autoref::hff612d8b5d90a70cD82
  14:     0x7f9a5e854960 - middle::trans::expr::trans::h139fd41d89b98122RW2
  15:     0x7f9a5e853420 - middle::trans::expr::trans_into::hffcd0924abd4fea27S2
  16:     0x7f9a5e938be0 - middle::trans::tvec::write_content::hd73973faa21b5330vPj
  17:     0x7f9a5e89c780 - middle::trans::tvec::trans_slice_vec::h65d0df732c3725d4PEj
  18:     0x7f9a5e890f10 - middle::trans::expr::trans_unadjusted::hb5708bd9b995e003LD3
  19:     0x7f9a5e854960 - middle::trans::expr::trans::h139fd41d89b98122RW2
  20:     0x7f9a5e8f9ce0 - middle::trans::_match::store_local::hbfa7bf297960a9f5jni
  21:     0x7f9a5e852a20 - middle::trans::base::init_local::h122a5d8fb0284157dae
  22:     0x7f9a5e851f80 - middle::trans::controlflow::trans_stmt::hfd63a5c43efa1d1f9UY
  23:     0x7f9a5e853900 - middle::trans::controlflow::trans_block::h697fa29e838af1025ZY
  24:     0x7f9a5e901810 - middle::trans::base::trans_closure::hf5f648fb424f9c93r1e
  25:     0x7f9a5e845b60 - middle::trans::base::trans_fn::h17dae15f71272d8eEcf
  26:     0x7f9a5e842780 - middle::trans::base::trans_item::h7f0dc64cc8095e95Nvf
  27:     0x7f9a5e90d780 - middle::trans::base::trans_crate::h40ab1d2d17a4f286Gtg
  28:     0x7f9a5ed07330 - driver::driver::phase_4_translate_to_llvm::h9eab234cedcf7a6b7Yw
  29:     0x7f9a5ecfe590 - driver::driver::compile_input::h06caa00e975ed0209ww
  30:     0x7f9a5ed816b0 - driver::run_compiler::h30663c3fdd061b12FnA
  31:     0x7f9a5ed81590 - driver::main_args::closure.146245
  32:     0x7f9a5e4af740 - task::TaskBuilder<S>::try_future::closure.101946
  33:     0x7f9a5e4af530 - task::TaskBuilder<S>::spawn_internal::closure.101917
  34:     0x7f9a5f68d590 - task::spawn_opts::closure.8444
  35:     0x7f9a5e0f8480 - rust_try_inner
  36:     0x7f9a5e0f8470 - rust_try
  37:     0x7f9a5e09e560 - unwind::try::h985905ef4937434euId
  38:     0x7f9a5e09e3c0 - task::Task::run::h3a7021021ab3297dfYc
  39:     0x7f9a5f68d300 - task::spawn_opts::closure.8384
  40:     0x7f9a5e09ffb0 - thread::thread_start::h67b84fc708de7e36rid
  41:     0x7f9a5d3b7250 - start_thread
  42:     0x7f9a5dd793b9 - clone
  43:                0x0 - <unknown>

@nrc
Copy link
Member

nrc commented Sep 18, 2014

cc @nikomatsakis another trait reform regression maybe? (from comment #17351 (comment))

@vhbit
Copy link
Contributor

vhbit commented Sep 18, 2014

Checked again, it started with 946654a

@nikomatsakis
Copy link
Contributor

cc me, probably a dup of #17322

@nodakai
Copy link
Contributor

nodakai commented Sep 26, 2014

Another instance of this bug I encountered today. It compiles fine with 0.11.0 on playpen.

fn main() {
    let _: &Str = &"x";
}
$ RUST_BACKTRACE=1 rustc ref-ice.rs
error: internal compiler error: trying to take the sizing type of str, 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>', /home/nodakai/src/rust-HEAD/src/libsyntax/diagnostic.rs:169

stack backtrace:
   1:     0x7f7ce2a896d0 - rt::backtrace::imp::write::hbe598dccc42c44bcvUq
   2:     0x7f7ce2a8c890 - failure::on_fail::hf35317f400fdba2fXfr
   3:     0x7f7ce704ac80 - unwind::begin_unwind_inner::h6f8b2a1fb914a9f1MTd
   4:     0x7f7ce59fcb20 - unwind::begin_unwind::h4350470456619517975
   5:     0x7f7ce59fd290 - diagnostic::Handler::bug::h5d9ce6fca7ccfb68OnF
   6:     0x7f7ce769b3c0 - driver::session::Session::bug::h9fb96e7547adf908Rix
   7:     0x7f7ce7a53510 - middle::trans::type_of::sizing_type_of::hed2e082010dc4455yI9
   8:     0x7f7ce7a831a0 - middle::trans::meth::get_vtable::hf8260e145d4c1737GIk
   9:     0x7f7ce7a82ae0 - middle::trans::expr::apply_adjustments::unsized_info::hdd775491ae0bafb9yb3
  10:     0x7f7ce7a85a80 - middle::trans::expr::apply_adjustments::unsize_expr::closure.123436
  11:     0x7f7ce7a85bc0 - middle::trans::expr::apply_adjustments::into_fat_ptr::h413a152fb7576cbbRi3
  12:     0x7f7ce7a818c0 - middle::trans::expr::apply_adjustments::apply_autoref::h3fa9af8370a776a9vY2
  13:     0x7f7ce7a818c0 - middle::trans::expr::apply_adjustments::apply_autoref::h3fa9af8370a776a9vY2
  14:     0x7f7ce7a41ff0 - middle::trans::expr::trans::h7de3de0790dc0c2bJM2
  15:     0x7f7ce7ae50d0 - middle::trans::_match::store_local::h770d8827c10345ba4hi
  16:     0x7f7ce7a400a0 - middle::trans::base::init_local::hc4ffd72108fbdbe9G2d
  17:     0x7f7ce7a3f5d0 - middle::trans::controlflow::trans_stmt::hf5c2949442fd16f3HMY
  18:     0x7f7ce7a40f80 - middle::trans::controlflow::trans_block::h58e1b3f21ebc3e6eDRY
  19:     0x7f7ce7aec250 - middle::trans::base::trans_closure::h649c196adecff5986Te
  20:     0x7f7ce7a33440 - middle::trans::base::trans_fn::h604a3d28a1b59852j5e
  21:     0x7f7ce7a30640 - middle::trans::base::trans_item::h73aa5253eb5d70eesof
  22:     0x7f7ce7af7450 - middle::trans::base::trans_crate::h9bc711dea61e7bf4Iog
  23:     0x7f7ce7f168e0 - driver::driver::phase_4_translate_to_llvm::h647b738894006b4fPJw
  24:     0x7f7ce7f0e0b0 - driver::driver::compile_input::hacecb9271bb5449eJgw
  25:     0x7f7ce7f90580 - driver::run_compiler::h5197019ba5ec6a85N6z
  26:     0x7f7ce7f90460 - driver::main_args::closure.146094
  27:     0x7f7ce76c9c40 - task::TaskBuilder<S>::try_future::closure.101461
  28:     0x7f7ce76c9a30 - task::TaskBuilder<S>::spawn_internal::closure.101432
  29:     0x7f7ce7399c40 - task::spawn_opts::closure.8485
  30:     0x7f7ce70a0e30 - rust_try_inner
  31:     0x7f7ce70a0e20 - rust_try
  32:     0x7f7ce70482c0 - unwind::try::h981c354b14bfedbduId
  33:     0x7f7ce7048120 - task::Task::run::hf1703086af82fbbacYc
  34:     0x7f7ce73999b0 - task::spawn_opts::closure.8425
  35:     0x7f7ce7049d10 - thread::thread_start::h1064d7802b5351b6rid
  36:     0x7f7ce1e3adc0 - start_thread
  37:                0x0 - <unknown>

$ rustc -v
rustc 0.12.0-pre (375fe1721 2014-09-25 12:02:52 +0000)

@codyps
Copy link
Contributor

codyps commented Oct 6, 2014

Is there a workaround for this? (I'm running into the same thing while attempting to use rust-postgres)

Edit: it appears replacing &[&username] with &[&String::from_str(username)] bypasses the ICE (for anyone else running into this).

@emberian
Copy link
Member

@jmesmon thanks, I hit this for the same reason.

@nodakai
Copy link
Contributor

nodakai commented Nov 28, 2014

My test case compiles fine now.

fn main() {
    let _: &Str = &"x";
}

One by @sfackler was rejected by the compiler instead of ICE:

ice0.rs:2:26: 2:31 error: cannot convert to a trait object because trait `core::clone::Clone` is not object-safe [E0038]
ice0.rs:2     let _: &[&Clone] = &[&"hi"];
                                   ^~~~~
note: cannot call a method (`clone`) whose type contains a self-type (`<generic #0>`) through a trait object
note: cannot call a method (`clone_from`) whose type contains a self-type (`&<generic #0>`) through a trait object
error: aborting due to previous error

But &[&"hi"] itself compiles fine.

Perhaps we can close this issue now?

@mikedilger
Copy link
Contributor Author

I vote to close

@emberian emberian added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Nov 29, 2014
@emberian
Copy link
Member

@nick29581 did you fix this recently, and is there a testcase?

@nrc
Copy link
Member

nrc commented Nov 29, 2014

I think @nikomatsakis might have fixed it, possibly in #18746. There is a test case there but I don't think it corresponds to the examples in this issue.

bors added a commit that referenced this issue Dec 18, 2014
Closes #5988.
Closes #10176.
Closes #10456.
Closes #12744.
Closes #13264.
Closes #13324.
Closes #14182.
Closes #15381.
Closes #15444.
Closes #15480.
Closes #15756.
Closes #16822.
Closes #16966.
Closes #17351.
Closes #17503.
Closes #17545.
Closes #17771.
Closes #17816.
Closes #17897.
Closes #17905.
Closes #18188.
Closes #18232.
Closes #18345.
Closes #18389.
Closes #18400.
Closes #18502.
Closes #18611.
Closes #18783.
Closes #19009.
Closes #19081.
Closes #19098.
Closes #19127.
Closes #19135.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants