Skip to content

ICE when type can't be dereferenced in expansion of write! #19164

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

Closed
woehr opened this issue Nov 20, 2014 · 1 comment
Closed

ICE when type can't be dereferenced in expansion of write! #19164

woehr opened this issue Nov 20, 2014 · 1 comment

Comments

@woehr
Copy link
Contributor

woehr commented Nov 20, 2014

Compiler version:

rustc 0.13.0-nightly (399ff259e 2014-11-20 00:27:07 +0000)
binary: rustc
commit-hash: 399ff259e18c1061aa4ea60856fcecb486d36624
commit-date: 2014-11-20 00:27:07 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly

Error with backtrace:

<std macros>:3:24: 10:11 error: type `NullWriter` cannot be dereferenced
<std macros>:3         let dst = &mut *$dst;
<std macros>:4         format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
<std macros>:5     })
<std macros>:6 )
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'index out of bounds: the len is 6 but the index is 6', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/lib.rs:1

stack backtrace:
   1:     0x7f4d33ad19c0 - rt::backtrace::imp::write::h7fe8534f465d0e09y9s
   2:     0x7f4d33ad4b60 - failure::on_fail::h3fe2ecde6aab0bb8rwt
   3:     0x7f4d34277c80 - unwind::begin_unwind_inner::he6bc2073d4eb582enbd
   4:     0x7f4d34277900 - unwind::begin_unwind_fmt::h305b4b28825355b2y8c
   5:     0x7f4d342778c0 - rust_begin_unwind
   6:     0x7f4d342bda70 - panicking::panic_fmt::h9d03fcf6b4c3f8e10Nl
   7:     0x7f4d342c2e60 - panicking::panic_bounds_check::h5c6357fea6530f04yMl
   8:     0x7f4d31946130 - codemap::FileMap::get_line::h8bd7cfe56e6cfd5e1aF
   9:     0x7f4d319749b0 - diagnostic::emit::h2322127ddc0c36debCG
  10:     0x7f4d319713d0 - diagnostic::EmitterWriter.Emitter::emit::hb9a4d5c26c04e1df0xG
  11:     0x7f4d3196fc50 - diagnostic::Handler::emit::ha390aea82acc4940kfG
  12:     0x7f4d31942910 - diagnostic::SpanHandler::span_err::h83b27707d23c7bfej3F
  13:     0x7f4d32d40720 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message_str_with_expected::h72941615d6be270289E
  14:     0x7f4d32c4c840 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message::h3e78576a7aeba36csfF
  15:     0x7f4d32c55f70 - middle::typeck::check::check_expr_with_unifier::h23742768f253d831DLl
  16:     0x7f4d32c55f70 - middle::typeck::check::check_expr_with_unifier::h23742768f253d831DLl
  17:     0x7f4d32ccac40 - middle::typeck::check::check_decl_local::h24893462a5fe4409xSn
  18:     0x7f4d32ccae00 - middle::typeck::check::check_stmt::h1ca15bfe8a7d5a87xUn
  19:     0x7f4d32c04d90 - middle::typeck::check::check_block_with_expected::heebc1a2b04a42760MYn
  20:     0x7f4d32c55f70 - middle::typeck::check::check_expr_with_unifier::h23742768f253d831DLl
  21:     0x7f4d32ccae00 - middle::typeck::check::check_stmt::h1ca15bfe8a7d5a87xUn
  22:     0x7f4d32c04d90 - middle::typeck::check::check_block_with_expected::heebc1a2b04a42760MYn
  23:     0x7f4d32c00810 - middle::typeck::check::check_fn::hd39b1b6b62f22c3fici
  24:     0x7f4d32c00530 - middle::typeck::check::check_bare_fn::h779ff7b2db70ca5bn1h
  25:     0x7f4d32bfc310 - middle::typeck::check::check_item::hde22067b8b575546vli
  26:     0x7f4d32c001c0 - middle::typeck::check::check_item_types::h7118271db2ab8ea8x0h
  27:     0x7f4d32fece10 - util::common::time::h4997555828079517418
  28:     0x7f4d32fec020 - middle::typeck::check_crate::h0949dffd97487b5ejVL
  29:     0x7f4d3477ba10 - driver::driver::phase_3_run_analysis_passes::h7f3610cf195b4c3abfS
  30:     0x7f4d34770830 - driver::driver::compile_input::h13734d451479d6e7VVR
  31:     0x7f4d347f57b0 - driver::run_compiler::h0a1cb9376c105f68pUT
  32:     0x7f4d347f56a0 - driver::run::closure.59745
  33:     0x7f4d34601ee0 - task::TaskBuilder<S>::try_future::closure.39051
  34:     0x7f4d34601cd0 - task::TaskBuilder<S>::spawn_internal::closure.39022
  35:     0x7f4d34b15b90 - task::NativeSpawner.Spawner::spawn::closure.2472
  36:     0x7f4d342d04c0 - rust_try_inner
  37:     0x7f4d342d04b0 - rust_try
  38:     0x7f4d342755e0 - unwind::try::h7c27f4e149aed3f2IZc
  39:     0x7f4d34275470 - task::Task::run::h75863ac7ddab20c0y5b
  40:     0x7f4d34b158d0 - task::NativeSpawner.Spawner::spawn::closure.2398
  41:     0x7f4d34276c90 - thread::thread_start::h7822af80b22f729bEqc
  42:     0x7f4d2eb5b250 - start_thread
  43:     0x7f4d33f4d3b9 - clone
  44:                0x0 - <unknown>

Offending code:

use std::fmt;
struct NullWriter;
impl fmt::FormatWriter for NullWriter {
  fn write(&mut self, bytes: &[u8]) -> fmt::Result {
    Ok(())
  }
}
fn main() {
  let mut n = NullWriter;
  write!(n, "1, 2, {}", 3);
}

If it's of any help, this also happens when using libcore directly (my original use-case) with #![no_std].

@woehr
Copy link
Contributor Author

woehr commented Nov 21, 2014

I just came across #14091, #19142, and #19155 which I think this is a duplicate of so I will close for now.

@woehr woehr closed this as completed Nov 21, 2014
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

1 participant