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: Explicit index of non-index type [u8] #15381

Closed
nwin opened this issue Jul 3, 2014 · 4 comments · Fixed by #19780
Closed

internal compiler error: Explicit index of non-index type [u8] #15381

nwin opened this issue Jul 3, 2014 · 4 comments · Fixed by #19780
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

@nwin
Copy link
Contributor

nwin commented Jul 3, 2014

The following code

struct Wrapper<'a> {
    slice: &'a [u8]
}

fn main() {
    let foo = Some(b"Hello World!");
    let bar: Option<Wrapper<'static>> = foo.map(|&x| Wrapper { slice: x });


}

triggers a compiler bug:

$ RUST_BACKTRACE=1 rustc test.rs 
test.rs:7:71: 7:72 error: internal compiler error: Explicit index of non-index type `[u8]`
test.rs:7     let bar: Option<Wrapper<'static>> = foo.map(|&x| Wrapper { slice: x });
                                                                                ^
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:107

stack backtrace:
   1:        0x10753a635 - rt::backtrace::imp::write::hbede6c694eb9f2cbIQp::v0.11.0.pre
   2:        0x107540bd7 - failure::on_fail::h30a7f46ec21fe35516p::v0.11.0.pre
   3:        0x1077eb249 - unwind::begin_unwind_inner::h6c751dc42f0f7f17IVd::v0.11.0.pre
   4:        0x106c51e25 - unwind::begin_unwind::h16840659320017284217::v0.11.0.pre
   5:        0x106c51dad - diagnostic::SpanHandler::span_bug::hb5a406cf5dd1450cWac::v0.11.0.pre
   6:        0x1045047e5 - driver::session::Session::span_bug::hc60df83bd7dbe984Trr::v0.11.0.pre
   7:        0x10478c506 - middle::mem_categorization::MemCategorizationContext<'t, TYPER>::cat_index::h11027325414672250850::v0.11.0.pre
   8:        0x10476be2b - middle::typeck::check::regionck::visit_expr::h8ad96e881d8c059afH8::v0.11.0.pre
   9:        0x104770542 - visit::walk_expr::h7092108895728945809::v0.11.0.pre
  10:        0x10476b2a0 - middle::typeck::check::regionck::visit_expr::h8ad96e881d8c059afH8::v0.11.0.pre
  11:        0x10476cf8e - visit::walk_block::h6655035168579021138::v0.11.0.pre
  12:        0x104770936 - visit::walk_fn::h7111590603532843168::v0.11.0.pre
  13:        0x10476b865 - middle::typeck::check::regionck::visit_expr::h8ad96e881d8c059afH8::v0.11.0.pre
  14:        0x104770113 - visit::walk_expr::h7092108895728945809::v0.11.0.pre
  15:        0x10476b2a0 - middle::typeck::check::regionck::visit_expr::h8ad96e881d8c059afH8::v0.11.0.pre
  16:        0x10476ce12 - middle::typeck::check::regionck::visit_local::ha0697ea4d5b15fbeUD8::v0.11.0.pre
  17:        0x10476cf6a - visit::walk_block::h6655035168579021138::v0.11.0.pre
  18:        0x1047afc0e - middle::typeck::check::check_bare_fn::hcd02e3ea22711cdcA2c::v0.11.0.pre
  19:        0x1047a98ce - middle::typeck::check::check_item::h066c89136b0abe5fOzd::v0.11.0.pre
  20:        0x1047af98d - middle::typeck::check::check_item_types::ha45c368daeab74efS1c::v0.11.0.pre
  21:        0x10492161e - middle::typeck::check_crate::hae37e3b7b5c6e1b3Q3C::v0.11.0.pre
  22:        0x104d75878 - driver::driver::phase_3_run_analysis_passes::hfbfa07100b0674bdFrq::v0.11.0.pre
  23:        0x104d708c5 - driver::driver::compile_input::hf1aa489ba45a9efcDeq::v0.11.0.pre
  24:        0x104e3709b - driver::run_compiler::h9c79a8fc68073767b0s::v0.11.0.pre
  25:        0x104e348b6 - driver::main_args::closure.117540
  26:        0x104e48f8b - task::TaskBuilder<S>::try_future::closure.118681
  27:        0x104e48e24 - task::TaskBuilder<S>::spawn_internal::closure.118658
  28:        0x10444395c - task::spawn_opts::closure.7563
  29:        0x107850dac - rust_try
  30:        0x1077e76ea - unwind::try::h7f3fc3b0329b49ea7Jd::v0.11.0.pre
  31:        0x1077e73ec - task::Task::run::h4a0e5408354628dfZVc::v0.11.0.pre
  32:        0x1044437eb - task::spawn_opts::closure.7508
  33:        0x1077e9f59 - thread::thread_start::h5aa600706e7c5c88xid::v0.11.0.pre
  34:     0x7fff973fd899 - _pthread_body
  35:     0x7fff973fd72a - _pthread_struct_init
@alexcrichton
Copy link
Member

cc @nick29581, this seems to be triggering DST which I didn't think was enabled...

@zsparal
Copy link

zsparal commented Jul 9, 2014

The following code:

pub struct Matrix {
    data: [[int, ..2], ..2]
}

impl Index<uint, [int, ..2]> for Matrix {
    fn index<'a>(&'a self, index: &uint) -> &'a [int, ..2] {
        &self.data[*index]
    }
}

fn main() {
    let m = Matrix {data: [[1, 0], [0, 1]]};
    let e = m[0][0];    
}

Also triggers a similar compiler error:

rust_error.rs:13:13: 13:20 error: internal compiler error: Explicit index of non-index type `&Matrix`
rust_error.rs:13     let e = m[0][0];
                             ^~~~~~~
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>', C:\bot\slave\nightly-win\build\src\libsyntax\diagnostic.rs:107

Unfortunately, I could not get the stack backtrace to print anything meaningful on Windows 8.1, if ran with RUST_BACKTRACE=1 the compiler outputs the following backtrace:

stack backtrace:
   1: 0x6a18242a
   2: 0x61f8893c
   3:   0x6e28da
   4:   0x6e2860
   5: 0x70f7255a
   6: 0x711eb8c5
   7: 0x711ea8fe
   8: 0x711d724b
Platform: Windows 8.1

$ rustc -v
rustc 0.11.0-nightly (1c711db551b9a5e56ba76e002e287dcfbb2cff3c 2014-07-09 00:36:40 +0000)

@flodiebold
Copy link
Member

I've also encountered this error message, with the following (simplified) code:

pub struct It;

impl Iterator<[uint, ..3]> for It {
    fn next(&mut self) -> Option<[uint, ..3]> {
        None
    }
}

fn main() {
    for [x, y, z] in It {
    }
}

Resulting in:

~/Projekte$ RUST_BACKTRACE=1 rustc rust-bug.rs                                                              101 ↵ 
rust-bug.rs:10:9: 10:18 error: internal compiler error: Explicit index of non-index type `It`
rust-bug.rs:10     for [x, y, z] in It {
                       ^~~~~~~~~
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:113

stack backtrace:
   1:     0x7fc16f9208d0 - rt::backtrace::imp::write::h9a97349a494f89bePUq
   2:     0x7fc16f923a90 - failure::on_fail::hb11547504289a1ffhgr
   3:     0x7fc1700f22d0 - unwind::begin_unwind_inner::h5df2dc6f14b19f71MTd
   4:     0x7fc16e3b8620 - unwind::begin_unwind::h1365354703164647196
   5:     0x7fc16e3b85a0 - diagnostic::SpanHandler::span_bug::h810a8fac103d8c1cMhF
   6:     0x7fc170697460 - driver::session::Session::span_bug::h976022b1a0303ee7m8w
   7:     0x7fc170a13d20 - middle::mem_categorization::MemCategorizationContext<'t, TYPER>::cat_index::h6849561118867022794
   8:     0x7fc170a12100 - middle::mem_categorization::MemCategorizationContext<'t, TYPER>::cat_pattern::h3339052091073497715
   9:     0x7fc1709fa8e0 - middle::typeck::check::regionck::visit_expr::hd3c8b825c2773d621PM
  10:     0x7fc1709f7a80 - middle::typeck::check::regionck::Rcx<'a, 'tcx>::visit_fn_body::hc777c8ab8612eedbyqM
  11:     0x7fc1709f7990 - middle::typeck::check::regionck::regionck_fn::h83e3b6c2d3d53709tjM
  12:     0x7fc170a3a130 - middle::typeck::check::check_bare_fn::hfebc4617d948ec12E8R
  13:     0x7fc170a35ec0 - middle::typeck::check::check_item::h77a7f21c8a144855HAS
  14:     0x7fc170a39be0 - middle::typeck::check::check_item_types::h697321cef90212deO7R
  15:     0x7fc1704e85d0 - util::common::time::h18398786739644959194
  16:     0x7fc170ce1010 - middle::typeck::check_crate::h63bb01e16b1996cd4Uj
  17:     0x7fc170d4ab40 - driver::driver::phase_3_run_analysis_passes::h57b76357b4c15009Opw
  18:     0x7fc170d46290 - driver::driver::compile_input::hc03497de7e6c909eL6v
  19:     0x7fc170dc8360 - driver::run_compiler::h24a8daf18bbc3b70DWz
  20:     0x7fc170dc8240 - driver::main_args::closure.146005
  21:     0x7fc170501710 - task::TaskBuilder<S>::try_future::closure.101291
  22:     0x7fc170501500 - task::TaskBuilder<S>::spawn_internal::closure.101262
  23:     0x7fc1716d8650 - task::spawn_opts::closure.8491
  24:     0x7fc170148480 - rust_try_inner
  25:     0x7fc170148470 - rust_try
  26:     0x7fc1700ef910 - unwind::try::h8c8d3e6eb0ca16a6uId
  27:     0x7fc1700ef770 - task::Task::run::hfb873359c59e1424cYc
  28:     0x7fc1716d83c0 - task::spawn_opts::closure.8431
  29:     0x7fc1700f1360 - thread::thread_start::h2b0150e66287e12frid
  30:     0x7fc16f3e7e70 - start_thread
  31:     0x7fc16fdbac09 - clone
  32:                0x0 - <unknown>

Doing the destructuring inside the for loop avoids the error.
This is on x86_64 Linux.

~/Projekte$ rustc -v                                                                                              
rustc 0.12.0-nightly (d64b4103d 2014-09-26 21:47:47 +0000)

@kubkon
Copy link
Contributor

kubkon commented Oct 7, 2014

I've encountered a similar error as well. The code:

let values: Vec<u8> = vec![1,2,3,4,5,6,7,8];

for [x,y,z] in values.as_slice().chunks(3).filter(|&xs| xs.len() == 3) {
    println!("y={}", y);
}

The error message with the backtrace:

slice_match.rs:4:9: 4:16 error: internal compiler error: Explicit index of non-index type `core::iter::Filter<'_,&[u8],core::slice::Chunks<'_,u8>>`
slice_match.rs:4     for [x,y,z] in values.as_slice().chunks(3).filter(|&xs| xs.len() == 3) {
                         ^~~~~~~
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:113

stack backtrace:
   1:        0x111c73269 - rt::backtrace::imp::write::he06af82d7d9ee38ecJq
   2:        0x111c765a1 - failure::on_fail::h9e3a39356479ba70QZq
   3:        0x111ef48e5 - unwind::begin_unwind_inner::h756181834df20b6dLud
   4:        0x1113e3b97 - unwind::begin_unwind::h18322048352354653950
   5:        0x1113e3b30 - unwind::begin_unwind::h18322048352354653950
   6:        0x10ea73b6d - driver::session::Session::span_bug::h2c0f6016b5fa651cwtx
   7:        0x10ede89fa - middle::mem_categorization::MemCategorizationContext<'t, TYPER>::cat_index::h13791422843569837526
   8:        0x10ede728d - middle::mem_categorization::MemCategorizationContext<'t, TYPER>::cat_pattern::h13679513847658926920
   9:        0x10edd10e8 - middle::typeck::check::regionck::visit_expr::h82e747716217ebf1GUM
  10:        0x10edcc884 - middle::typeck::check::regionck::Rcx<'a, 'tcx>::visit_fn_body::h3ac342a98dca80f6dvM
  11:        0x10edcbccd - middle::typeck::check::regionck::regionck_fn::h34dea5a76c44f2e38nM
  12:        0x10ee0f292 - middle::typeck::check::check_bare_fn::h6db665b3affe0759ZhS
  13:        0x10ee0b0b8 - middle::typeck::check::check_item::h82af91f6696c38872JS
  14:        0x10ee0f0df - middle::typeck::check::check_item_types::h55796e1a31aa1c3c9gS
  15:        0x10e8cc4b6 - util::common::time::h10131786875316863222
  16:        0x10f0bfb6e - middle::typeck::check_crate::h95db7480b8900497Edk
  17:        0x10f12967f - driver::driver::phase_3_run_analysis_passes::h8decd58d8d4c066eEKw
  18:        0x10f124558 - driver::driver::compile_input::heb0d35abb1543609qrw
  19:        0x10f1a3584 - driver::run_compiler::h420de67eacbe487cHhA
  20:        0x10f1a1726 - driver::run::closure.146515
  21:        0x10e8e4bfb - task::TaskBuilder<S>::try_future::closure.101324
  22:        0x10e8e4af3 - task::TaskBuilder<S>::spawn_internal::closure.101295
  23:        0x10e8616bd - task::spawn_opts::closure.8536
  24:        0x111f579ec - rust_try_inner
  25:        0x111f579d6 - rust_try
  26:        0x111ef2157 - unwind::try::h6df6339e56c18041tjd
  27:        0x111ef1fec - task::Task::run::hf7474df0e760efdfEzc
  28:        0x10e861512 - task::spawn_opts::closure.8475
  29:        0x111ef383a - thread::thread_start::h960eee62f4c643ffPTc
  30:     0x7fff8e93a899 - _pthread_body
  31:     0x7fff8e93a72a - _pthread_struct_init

I'm running OSX 10.9.5 with x86_64 architecture.

Rust version:

rustc 0.12.0-nightly (dc987adfc 2014-10-04 23:42:07 +0000)

@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 28, 2014
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.
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 18, 2024
Substitute $saved_file in custom check commands

If the custom command has a $saved_file placeholder, and we know the file being saved, replace the placeholder and run a check command.

If there's a placeholder and we don't know the saved file, do nothing.

This is a simplified version of rust-lang#15381, which I hope is easier to review.
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.

5 participants