rust-lang/rust

ICE on "index out of bounds: the len is 3 but the index is 4"

Closed this issue · 0 comments

I'm getting an internal compiler error on the following program (found by fuzz-rustc):

// run-pass

fn v() -> isize {
    mod  _{
        pub fn g() -> isizee {
mod  _{
        pub    g() -> is
   (), w20);
  }

   (), w20);
}
$ RUST_BACKTRACE=1 rustc main.rs
error: expected identifier, found reserved identifier `_`
 --> main.rs:4:10
  |
4 |     mod  _{
  |          ^ expected identifier, found reserved identifier

error: expected identifier, found reserved identifier `_`
 --> main.rs:6:6
  |
6 | mod  _{
  |      ^ expected identifier, found reserved identifier

thread 'rustc' panicked at 'index out of bounds: the len is 3 but the index is 4', /rustc/273f42b5964c29dda2c5a349dd4655529767b07f/src/libcore/slice/mod.rs:2687:14
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:384
   9: rust_begin_unwind
             at src/libstd/panicking.rs:311
  10: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  11: core::panicking::panic_bounds_check
             at src/libcore/panicking.rs:61
  12: syntax::parse::parser::Parser::parse_item_
  13: syntax::parse::parser::Parser::parse_item
  14: syntax::parse::parser::Parser::parse_mod_items
  15: syntax::parse::parser::Parser::parse_item_implementation
  16: syntax::parse::parser::Parser::parse_item_
  17: syntax::parse::parser::Parser::parse_stmt_without_recovery
  18: syntax::parse::parser::Parser::parse_full_stmt
  19: syntax::parse::parser::Parser::parse_block_tail
  20: syntax::parse::parser::Parser::parse_inner_attrs_and_block
  21: syntax::parse::parser::Parser::parse_item_fn
  22: syntax::parse::parser::Parser::parse_item_implementation
  23: syntax::parse::parser::Parser::parse_item_
  24: syntax::parse::parser::Parser::parse_item
  25: syntax::parse::parser::Parser::parse_mod_items
  26: syntax::parse::parser::Parser::parse_item_implementation
  27: syntax::parse::parser::Parser::parse_item_
  28: syntax::parse::parser::Parser::parse_stmt_without_recovery
  29: syntax::parse::parser::Parser::parse_full_stmt
  30: syntax::parse::parser::Parser::parse_block_tail
  31: syntax::parse::parser::Parser::parse_inner_attrs_and_block
  32: syntax::parse::parser::Parser::parse_item_fn
  33: syntax::parse::parser::Parser::parse_item_implementation
  34: syntax::parse::parser::Parser::parse_item_
  35: syntax::parse::parser::Parser::parse_item
  36: syntax::parse::parser::Parser::parse_mod_items
  37: syntax::parse::parser::Parser::parse_crate_mod
  38: syntax::parse::parse_crate_from_file
  39: rustc_interface::passes::parse::{{closure}}
  40: rustc::util::common::time
  41: rustc_interface::passes::parse
  42: rustc_interface::queries::Query<T>::compute
  43: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::parse
  44: rustc_interface::interface::run_compiler_in_existing_thread_pool
  45: std::thread::local::LocalKey<T>::with
  46: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
end of query stack
error: aborting due to 2 previous errors


error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.38.0-nightly (273f42b59 2019-07-21) running on x86_64-unknown-linux-gnu

I'm seeing the error on stable, beta, and nightly. As with #62881, the error occurs on nightly-2018-12-14 (f4a421e) but not on nightly-2018-12-08 (4a45578).

#62887, the proposed fix for #62881, does not fix this error. cc @estebank