Skip to content

rustc panicked at byte index 4 is out of bounds of #41652

@messense

Description

@messense
Contributor

I tried this code:

sozu-proxy/sozu#173

rustc --version --verbose:

rustc 1.19.0-nightly (afa1240e5 2017-04-29)
binary: rustc
commit-hash: afa1240e57330d85a372db4e28cd8bc8fa528ccb
commit-date: 2017-04-29
host: x86_64-apple-darwin
release: 1.19.0-nightly
LLVM version: 4.0

Backtrace:

   Compiling sozu-lib v0.2.0 (file:///Users/messense/Projects/sozu/lib)
error: no method named `deserialize` found for type `D` in the current scope
   --> lib/src/messages.rs:208:18
    |
208 |     deserializer.deserialize(OrderFieldVisitor)
    |                  ^^^^^^^^^^^
    |
    = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'byte index 4 is out of bounds of ``', src/libcore/str/mod.rs:2162
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: std::panicking::begin_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::str::slice_error_fail
   9: rustc_errors::emitter::EmitterWriter::emit_message_default
  10: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit
  11: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  12: rustc_typeck::check::method::suggest::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::report_method_error
  13: rustc_typeck::check::FnCtxt::check_expr_kind
  14: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  15: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  16: rustc_typeck::check::FnCtxt::check_block_with_expected
  17: rustc_typeck::check::FnCtxt::check_expr_kind
  18: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  19: rustc_typeck::check::FnCtxt::check_return_expr
  20: rustc_typeck::check::check_fn
  21: rustc_typeck::check::typeck_tables_of
  22: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  23: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  24: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  25: rustc_typeck::check::typeck_item_bodies
  26: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  27: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  28: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  29: rustc_typeck::check_crate
  30: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  31: rustc_driver::driver::phase_3_run_analysis_passes
  32: rustc_driver::driver::compile_input
  33: rustc_driver::run_compiler
  34: std::panicking::try::do_call
  35: __rust_maybe_catch_panic
  36: <F as alloc::boxed::FnBox<A>>::call_box
  37: std::sys::imp::thread::Thread::new::thread_start
  38: _pthread_body
  39: _pthread_start

error: Could not compile `sozu-lib`.

To learn more, run the command again with --verbose.

Activity

added
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
on Apr 30, 2017
kennytm

kennytm commented on Apr 30, 2017

@kennytm
Member

Reduced test case:

Crate a:

extern crate b;
struct S;
impl b::Tr for S {
    fn f() {
        3.f()
    }
}

Crate b:

pub trait Tr {
    fn f() // <-- new line is needed to trigger the ICE
        where Self: Sized;
}

Output:

error: no method named `f` found for type `{integer}` in the current scope
 --> src/lib.rs:5:11
  |
5 |         3.f()
  |           ^
  |
  = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
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

thread 'rustc' panicked at 'byte index 4 is out of bounds of ``', src/libcore/str/mod.rs:2162
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `a`.

Rust stable (1.17.0) doesn't ICE, but produces a span that refers to no source code.

error: no method named `f` found for type `{integer}` in the current scope
 --> src/lib.rs:5:11
  |
5 |         3.f()
  |           ^
  |
  = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: candidate #1 is defined in the trait `b::Tr`
 --> b/src/lib.rs:2:5
  |
2 | 
  |  _____^ starting here...
3 | |
  | |__________________________^ ...ending here
  = help: to disambiguate the method call, write `b::Tr::f(3)` instead

error: aborting due to previous error

error: Could not compile `a`.

To learn more, run the command again with --verbose.

(BTW your code is wrong anyway, there are no Deserializer::deserialize methods in serde 1.0)

messense

messense commented on May 1, 2017

@messense
ContributorAuthor

@kennytm I know the code is wrong, I was trying to let the compiler guide me through the upgrading process then it panicked.

added a commit that references this issue on May 7, 2017
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

    I-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

        Participants

        @kennytm@sfackler@messense

        Issue actions

          rustc panicked at byte index 4 is out of bounds of · Issue #41652 · rust-lang/rust