Skip to content

ICE on "index out of bounds: the len is 0 but the index is 1" #62881

Description

@dwrensha

When I try to run rustc on this program (found by fuzz-rustc)

fn f() -> isize { fn f() -> isize {} pub f<

it crashes with this error:

error: this file contains an un-closed delimiter
 --> main.rs:1:45
  |
1 | fn f() -> isize { fn f() -> isize {} pub f<
  |                 - un-closed delimiter       ^

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 1', /rustc/273f42b5964c29dda2c5a349dd4655529767b07f/src/libcore/slice/mod.rs:2687:14
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: rustc::util::common::panic_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::continue_panic_fmt
   5: rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::panicking::panic_bounds_check
   8: syntax::parse::parser::Parser::parse_item_
   9: syntax::parse::parser::Parser::parse_stmt_without_recovery
  10: syntax::parse::parser::Parser::parse_full_stmt
  11: syntax::parse::parser::Parser::parse_block_tail
  12: syntax::parse::parser::Parser::parse_inner_attrs_and_block
  13: syntax::parse::parser::Parser::parse_item_fn
  14: syntax::parse::parser::Parser::parse_item_implementation
  15: syntax::parse::parser::Parser::parse_item_
  16: syntax::parse::parser::Parser::parse_item
  17: syntax::parse::parser::Parser::parse_mod_items
  18: syntax::parse::parser::Parser::parse_crate_mod
  19: syntax::parse::parse_crate_from_file
  20: rustc_interface::passes::parse::{{closure}}
  21: rustc::util::common::time
  22: rustc_interface::passes::parse
  23: rustc_interface::queries::Query<T>::compute
  24: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::parse
  25: rustc_interface::interface::run_compiler_in_existing_thread_pool
  26: std::thread::local::LocalKey<T>::with
  27: 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 previous error


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-apple-darwin

The error happens on stable, beta, and nightly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions