Skip to content

ICE on "byte index 1 is out of bounds of ``" #62973

Closed

Description

@dwrensha

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

fn p() { match s { v, E { [) {) }

(EDIT: the trailing newlines are important)

error: this file contains an un-closed delimiter
 --> main.rs:2:2
  |
1 | fn p() { match s { v, E { [) {) }
  |        -         - un-closed delimiter
  |        |
  |        un-closed delimiter
2 | 
  |  ^

error: expected one of `,` or `}`, found `{`
 --> main.rs:1:25
  |
1 | fn p() { match s { v, E { [) {) }
  |                -        ^ expected one of `,` or `}` here
  |                |
  |                while parsing this struct

error: struct literals are not allowed here
 --> main.rs:1:16
  |
1 |   fn p() { match s { v, E { [) {) }
  |  ________________^
2 | |
  | |_^
thread 'rustc' panicked at 'byte index 1 is out of bounds of ``', src/libcore/str/mod.rs:2019:9
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::str::slice_error_fail
   8: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeTo<usize>>::index::{{closure}}
   9: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  10: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  11: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
  12: rustc_errors::Handler::emit_db
  13: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  14: syntax::parse::parser::Parser::parse_bottom_expr
  15: syntax::parse::parser::Parser::parse_dot_or_call_expr
  16: syntax::parse::parser::Parser::parse_prefix_expr
  17: syntax::parse::parser::Parser::parse_assoc_expr_with
  18: syntax::parse::parser::Parser::parse_bottom_expr
  19: syntax::parse::parser::Parser::parse_dot_or_call_expr
  20: syntax::parse::parser::Parser::parse_prefix_expr
  21: syntax::parse::parser::Parser::parse_assoc_expr_with
  22: syntax::parse::parser::Parser::parse_stmt_without_recovery
  23: syntax::parse::parser::Parser::parse_full_stmt
  24: syntax::parse::parser::Parser::parse_block_tail
  25: syntax::parse::parser::Parser::parse_inner_attrs_and_block
  26: syntax::parse::parser::Parser::parse_item_fn
  27: syntax::parse::parser::Parser::parse_item_implementation
  28: syntax::parse::parser::Parser::parse_item_
  29: syntax::parse::parser::Parser::parse_item
  30: syntax::parse::parser::Parser::parse_mod_items
  31: syntax::parse::parser::Parser::parse_crate_mod
  32: syntax::parse::parse_crate_from_file
  33: rustc_interface::passes::parse::{{closure}}
  34: rustc::util::common::time
  35: rustc_interface::passes::parse
  36: rustc_interface::queries::Query<T>::compute
  37: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::parse
  38: rustc_interface::interface::run_compiler_in_existing_thread_pool
  39: std::thread::local::LocalKey<T>::with
  40: scoped_tls::ScopedKey<T>::set
  41: 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: incorrect close delimiter: `)`
 --> main.rs:1:28
  |
1 | fn p() { match s { v, E { [) {) }
  |                           -^ incorrect close delimiter
  |                           |
  |                           un-closed delimiter

error: incorrect close delimiter: `)`
 --> main.rs:1:31
  |
1 | fn p() { match s { v, E { [) {) }
  |                              -^ incorrect close delimiter
  |                              |
  |                              un-closed delimiter

error: aborting due to 4 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 (03f19f7ff 2019-07-24) running on x86_64-apple-darwin

The error happens on stable, beta, and nightly.

Activity

  1. Mark-Simulacrum commented on Jul 25, 2019

    @Mark-Simulacrum
    Member
  2. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    A-parserArea: The lexing & parsing of Rust source code to an AST
    on Jul 25, 2019
  3. estebank commented on Jul 25, 2019

    @estebank
    Contributor

    I haven't been able to reproduce :-/

  4. dwrensha commented on Jul 25, 2019

    @dwrensha
    ContributorAuthor
  5. dwrensha commented on Jul 25, 2019

    @dwrensha
    ContributorAuthor
  6. added a commit that references this issue on Jul 28, 2019
    a3cae57
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 ASTI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions