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

internal compiler error: borrow-vec associated with bad sty: &ty_err #15730

Closed
yellowhat5 opened this issue Jul 17, 2014 · 6 comments · Fixed by #17199
Closed

internal compiler error: borrow-vec associated with bad sty: &ty_err #15730

yellowhat5 opened this issue Jul 17, 2014 · 6 comments · Fixed by #17199
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@yellowhat5
Copy link

Here is the error

main.rs:4:21: 4:26 error: internal compiler error: borrow-vec associated with bad sty: &ty_err
main.rs:4     let pie_slice = array.slice(1, 2);
                              ^~~~~
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/diagnostic.rs:115

stack backtrace:
   1:     0x7fde1a0f5620 - rt::backtrace::imp::write::h0fea79425673725266p
   2:     0x7fde1a0f8e80 - failure::on_fail::h9aabe19bffc3104alsq
   3:     0x7fde1a8bbff0 - unwind::begin_unwind_inner::h9b55d31cfec63a9e40d
   4:     0x7fde18d72a90 - unwind::begin_unwind::h1183448402907672069
   5:     0x7fde18d729c0 - diagnostic::SpanHandler::span_bug::h5b8de884ef10a1cbUdy
   6:     0x7fde1ad239c0 - driver::session::Session::span_bug::hf691bf888bfdb422Znt
   7:     0x7fde1ae92610 - middle::ty::adjust_ty::borrow_vec::h6f1dca784386e59eDZT
   8:     0x7fde1ae8fa00 - middle::ty::adjust_ty::hcb1fa49e78b9b840LST
   9:     0x7fde1af8b380 - middle::typeck::check::regionck::constrain_regions_in_type_of_node::h87665c249e125f57NWc
  10:     0x7fde1af86050 - middle::typeck::check::regionck::visit_expr::h73423e7aa5968300D7b
  11:     0x7fde1af8d470 - visit::walk_expr::h17493730021457087419
  12:     0x7fde1af86050 - middle::typeck::check::regionck::visit_expr::h73423e7aa5968300D7b
  13:     0x7fde1af8a160 - middle::typeck::check::regionck::visit_local::h763740eedaeb1379i4b
  14:     0x7fde1af8a3d0 - visit::walk_block::h12723599008176341713
  15:     0x7fde1afcee00 - middle::typeck::check::check_bare_fn::haf584d83c0be5c3bwBg
  16:     0x7fde1afc7e60 - middle::typeck::check::check_item::h08679946a56c7e5fcah
  17:     0x7fde1afcec00 - middle::typeck::check::check_item_types::hfa0d60d09ac306bcOAg
  18:     0x7fde1b140a50 - middle::typeck::check_crate::h59523a23ed9761e6GhH
  19:     0x7fde1b4c9d20 - driver::driver::phase_3_run_analysis_passes::h47669ed167b54bdezhs
  20:     0x7fde1b4c55c0 - driver::driver::compile_input::h539bec547706263dA3r
  21:     0x7fde1b57e050 - driver::run_compiler::h9cb91406a88d027059u
  22:     0x7fde1b57df60 - driver::main_args::closure.$x22closure$x22$LP$133605$RP$
  23:     0x7fde1b591ab0 - task::TaskBuilder<S>::try_future::closure.$x22closure$x22$LP$134754$RP$
  24:     0x7fde1b591840 - task::TaskBuilder<S>::spawn_internal::closure.$x22closure$x22$LP$134731$RP$
  25:     0x7fde1bf35df0 - task::spawn_opts::closure.$x22closure$x22$LP$8163$RP$
  26:     0x7fde1a9137b0 - rust_try
  27:     0x7fde1a8b9080 - unwind::try::hc59e8203d98cfea8tPd
  28:     0x7fde1a8b8de0 - task::Task::run::hc5aad491de06c5bcP0c
  29:     0x7fde1bf35be0 - task::spawn_opts::closure.$x22closure$x22$LP$8109$RP$
  30:     0x7fde1a8bb060 - thread::thread_start::h597549996b7dcb76nnd
  31:     0x7fde19b75060 - start_thread
  32:     0x7fde1a583489 - __clone
  33:                0x0 - <unknown>

Here is the code that generates the error

fn main()
{
    let mut array = [1, 2, 3];
    let pie_slice = array.slice(1, 2);
}

My system is x86_64 archlinux. The rust compiler version is

rustc -v
rustc 0.12.0-pre-nightly (afbcbbc77ffc6b10053bc543daf7d2e05d68cc01 2014-07-16 00:31:15 +0000)

Let me know if you guys need anything else.

(The code is really short so it shouldn't be hard to just type it in to duplicate the bug)

@huonw huonw added the I-ICE label Jul 17, 2014
@yellowhat5 yellowhat5 changed the title error: internal compiler error: borrow-vec associated with bad sty: &ty_err these 2 line of code trigger a compiler error Jul 17, 2014
@sinistersnare
Copy link
Contributor

It only needs one line for me

fn main() {
    let array = [1, 2, 3].slice(1,2);
}

playpen link

@pnkfelix
Copy link
Member

Workaround (in the sense that the compiler no longer ICE's):

fn main()
{
    let array = [1i, 2i, 3i].slice(1,2); // (you only need one `i` actually)
}

I think there is some unfortunate interaction here with the way we attempt to infer which kind of numeric literals are in the array (i32, i64, etc) and other code not being prepared to handle the ty_err that results when you don't have that information available.

@huonw huonw changed the title these 2 line of code trigger a compiler error internal compiler error: borrow-vec associated with bad sty: &ty_err Jul 17, 2014
@huonw
Copy link
Member

huonw commented Jul 17, 2014

This is almost certainly a duplicate of #7813 (but maybe the integer inference codepath is slightly different?).

@mrmonday
Copy link
Contributor

This also causes the same ICE - http://is.gd/fD2WVy

fn main() {
    struct Foo;
    let _ = [0, ..4].as_mut_ptr() as *mut Foo;
}

@FranklinChen
Copy link
Contributor

Similarly:

fn main() {
    [].iter();
}

@ghost
Copy link

ghost commented Sep 11, 2014

Looks like it's been fixed.

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 11, 2014
bors added a commit that referenced this issue Sep 15, 2014
…hton

Closes #7813.
Closes #10902.
Closes #11374.
Closes #11714.
Closes #12920.
Closes #13202.
Closes #13624.
Closes #14039.
Closes #15730.
Closes #15783.
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Feb 5, 2024
Add postfix completion for let else

Adds a postfix completion for let else syntax, similar to the if let postfix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants