Closed nwin closed 9 years ago
cc @nick29581, this seems to be triggering DST which I didn't think was enabled...
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)
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)
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)
The following code
triggers a compiler bug: