Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in std::fs:File read_to_string #33886

Closed
maksimsco opened this issue May 26, 2016 · 1 comment
Closed

Bug in std::fs:File read_to_string #33886

maksimsco opened this issue May 26, 2016 · 1 comment

Comments

@maksimsco
Copy link

I tried this code:

use std::io::prelude::{Read};
use std::fs::File;


fn main() {
  let mut file = File::open("").unwrap();
  let mut temp = Vec::new();
  file.read_to_string(&mut temp).unwrap();
}

https://is.gd/g8Qo3H

I expected to see this happen:

Mismatched type error, stating that expected type is &mut std::string::String, found type &mut std::vec::Vec<_>

Instead, this happened:

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 'index out of bounds: the len is 11 but the index is 13', ../src/libcollections/vec.rs:1167

Meta

rustc 1.10.0-nightly (267cde259 2016-05-25)
binary: rustc
commit-hash: 267cde2598db3b858730cc1f700f740964343828
commit-date: 2016-05-25
host: x86_64-unknown-linux-gnu
release: 1.10.0-nightly

Backtrace:

   1:     0x7f0c3a63f300 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:     0x7f0c3a64cefb - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:     0x7f0c3a64ca9c - std::panicking::default_hook::hc2c969e7453d080c
   4:     0x7f0c3a612508 - std::panicking::rust_panic_with_hook::hfe203e3083c2b544
   5:     0x7f0c3a64d141 - std::panicking::begin_panic::h4889569716505182
   6:     0x7f0c3a6145aa - std::panicking::begin_panic_fmt::h484cd47786497f03
   7:     0x7f0c3a64d0de - rust_begin_unwind
   8:     0x7f0c3a696c0f - core::panicking::panic_fmt::h257ceb0aa351d801
   9:     0x7f0c3a696df2 - core::panicking::panic_bounds_check::h3956fdcea61ff421
  10:     0x7f0c36d5f04d - _<rustc_data_structures..unify..UnificationTable<K>>::get::h8ff555081abcc760
  11:     0x7f0c36d000c0 - rustc::infer::InferCtxt::shallow_resolve::hff438d8ff8173683
  12:     0x7f0c36e67c6b - _<traits..fulfill..FulfillProcessor<'a, 'b, 'gcx, 'tcx> as rustc_data_structures..obligation_forest..ObligationProcessor>::process_obligation::h97a6c04480fde384
  13:     0x7f0c36e671d7 - _<rustc_data_structures..obligation_forest..ObligationForest<O>>::process_obligations::h66b78b3df852f4c4
  14:     0x7f0c36e5f77f - rustc::traits::fulfill::FulfillmentContext::select_where_possible::h8b194aeaf688996f
  15:     0x7f0c393ac995 - rustc_typeck::check::FnCtxt::select_obligations_where_possible::h4d863d3c82f83fa7
  16:     0x7f0c393c0c07 - rustc_typeck::check::FnCtxt::resolve_type_vars_with_obligations::he5b46c6af8ba8c04
  17:     0x7f0c393d5cbe - rustc_typeck::check::demand::_<impl check..FnCtxt<'a, 'gcx, 'tcx>>::demand_coerce::h09ff47efa702d716
  18:     0x7f0c393d36ca - rustc_typeck::check::FnCtxt::check_argument_types::ha1363bf21548e22e
  19:     0x7f0c393d25f7 - rustc_typeck::check::FnCtxt::check_method_argument_types::h2c2345d254cd8031
  20:     0x7f0c393d87a3 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::hf7a336bf3f6d489c
  21:     0x7f0c393d6880 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::hf7a336bf3f6d489c
  22:     0x7f0c3940dc18 - rustc_typeck::check::FnCtxt::check_stmt::h631e2149cd32c75c
  23:     0x7f0c393b2a73 - rustc_typeck::check::FnCtxt::check_block_with_expected::hb3119871f6a1bbfa
  24:     0x7f0c393a9aa8 - rustc_typeck::check::check_fn::h4bb517663c83e412
  25:     0x7f0c393a62de - rustc_typeck::check::check_bare_fn::ha3f2d22e33abb8cf
  26:     0x7f0c393a1d72 - rustc_typeck::check::check_item_body::h7ffec660fc242796
  27:     0x7f0c39398779 - rustc_typeck::check::check_item_bodies::ha729008a2e67410e
  28:     0x7f0c393916b6 - rustc_typeck::check_crate::hab54f1dbb6479f2b
  29:     0x7f0c3ab9b83c - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::he8e0792bce031dff
  30:     0x7f0c3ab9987b - rustc::ty::context::TyCtxt::create_and_enter::h9e0841510a9ae184
  31:     0x7f0c3ab614ec - rustc_driver::driver::compile_input::h0629572e6f316b31
  32:     0x7f0c3ab4c704 - rustc_driver::run_compiler::h8902aebf8b1849a8
  33:     0x7f0c3ab497de - std::panicking::try::call::hb9e578062982aefa
  34:     0x7f0c3a65b69b - __rust_try
  35:     0x7f0c3a65b63e - __rust_maybe_catch_panic
  36:     0x7f0c3ab4a2c4 - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
  37:     0x7f0c3a64b004 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  38:     0x7f0c32316473 - start_thread
  39:     0x7f0c3a2a2acc - clone
  40:                0x0 - <unknown>
@apasel422
Copy link
Contributor

Duplicate of #31964.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants