Skip to content

ICE on questionable use of trait #19208

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
mitsuhiko opened this issue Nov 22, 2014 · 3 comments
Closed

ICE on questionable use of trait #19208

mitsuhiko opened this issue Nov 22, 2014 · 3 comments

Comments

@mitsuhiko
Copy link
Contributor

This code:

#![feature(if_let, while_let)]

use std::io;

pub struct Test<W: Writer> {
    writer: W,
}

impl<W: Writer> Test<W> {

    pub fn new(writer: W) -> Test<W> {
        Test {
            writer: writer,
        }
    }

    pub fn write_something(&mut self) -> io::IoResult<()> {
        try!(writeln!(self.writer, ""));
        Ok(())
    }
}

Produces this very hard to understand error:

<std macros>:3:24: 18:34 error: type `W` 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', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/lib.rs:1

stack backtrace:
   1:        0x10e61aba2 - rt::backtrace::imp::write::h90a8813e205226e59it
   2:        0x10e61dd3d - failure::on_fail::h02cd561a89cb7027gBt
   3:        0x10e88df65 - unwind::begin_unwind_inner::h4bc3350c0517820112c
   4:        0x10e88dbaf - unwind::begin_unwind_fmt::hd106a62827b11c87c0c
   5:        0x10e88d952 - rust_begin_unwind
   6:        0x10e8d8fec - panicking::panic_fmt::h17addcbe3c55edecaOl
   7:        0x10e8e15b1 - panicking::panic_bounds_check::he446012f6f64f624IMl
   8:        0x10c59c015 - codemap::FileMap::get_line::h765ba394c07c5a54m4E
   9:        0x10c5ca703 - diagnostic::emit::hb066201a777f2165wvG
  10:        0x10c5c6f98 - diagnostic::EmitterWriter.Emitter::emit::h165058475e3b3ec5lrG
  11:        0x10c5c5785 - diagnostic::Handler::emit::hde0ac2d5b40efe25F8F
  12:        0x10c5981ab - diagnostic::SpanHandler::span_err::h2eaa3c8ca5c5b97cEWF
  13:        0x10b9df920 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message_str_with_expected::h6ee55cab43056003TKF
  14:        0x10b92f921 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message::h3d8733aff7464519dQF
  15:        0x10b940539 - middle::typeck::check::check_expr_with_unifier::h40fb1c6e261626f5Nzm
  16:        0x10b93e934 - middle::typeck::check::check_expr_with_unifier::h40fb1c6e261626f5Nzm
  17:        0x10b96d0b3 - middle::typeck::check::check_decl_local::hfecf573d1629e05egto
  18:        0x10b96d2a3 - middle::typeck::check::check_stmt::h837abcc8fc4466f6gvo
  19:        0x10b8f41e8 - middle::typeck::check::check_block_with_expected::hb5675eefe857af90vzo
  20:        0x10b93a760 - middle::typeck::check::check_expr_with_unifier::h40fb1c6e261626f5Nzm
  21:        0x10b82e2db - middle::typeck::check::_match::check_match::h3caf386ed888768e5P8
  22:        0x10b93a683 - middle::typeck::check::check_expr_with_unifier::h40fb1c6e261626f5Nzm
  23:        0x10b8f4522 - middle::typeck::check::check_block_with_expected::hb5675eefe857af90vzo
  24:        0x10b93a760 - middle::typeck::check::check_expr_with_unifier::h40fb1c6e261626f5Nzm
  25:        0x10b96d2fa - middle::typeck::check::check_stmt::h837abcc8fc4466f6gvo
  26:        0x10b8f41e8 - middle::typeck::check::check_block_with_expected::hb5675eefe857af90vzo
  27:        0x10b8cdf00 - middle::typeck::check::check_fn::hd44de11a490be98ce0i
  28:        0x10b8f0aae - middle::typeck::check::check_bare_fn::h3c7a1f5d35e30589jPi
  29:        0x10b8f754f - middle::typeck::check::check_method_body::he0c86eb88bb45c1blkj
  30:        0x10b8edb88 - middle::typeck::check::check_item::h4ddfa2a018f36791t9i
  31:        0x10b8f07d0 - middle::typeck::check::check_item_types::h1ade2b1cc61bf6batOi
  32:        0x10bc74826 - util::common::time::h8028586279873844585
  33:        0x10bc73ca4 - middle::typeck::check_crate::h3a5b374f87cce2eecwM
  34:        0x10b265393 - driver::driver::phase_3_run_analysis_passes::hdc8c835c5059844etfS
  35:        0x10b2598bc - driver::driver::compile_input::h1998d439bb2aa565dWR
  36:        0x10b2d7bc5 - driver::run_compiler::h8a3c490c622774caHUT
  37:        0x10b2d639e - driver::run::closure.59807
  38:        0x10b0edc5b - task::TaskBuilder<S>::try_future::closure.39061
  39:        0x10b0edb53 - task::TaskBuilder<S>::spawn_internal::closure.39032
  40:        0x10b0b17bd - task::NativeSpawner.Spawner::spawn::closure.2475
  41:        0x10e8f082c - rust_try_inner
  42:        0x10e8f0816 - rust_try
  43:        0x10e88b707 - unwind::try::h9549aa28335b576amRc
  44:        0x10e88b59c - task::Task::run::h7f22cfdcfa218bd192b
  45:        0x10b0b15e3 - task::NativeSpawner.Spawner::spawn::closure.2399
  46:        0x10e88cdd7 - thread::thread_start::h08cb83a10e608715foc
  47:     0x7fff9260c2fc - _pthread_body
  48:     0x7fff9260c279 - _pthread_body
@huonw
Copy link
Member

huonw commented Nov 22, 2014

Dupe of #14091; thanks for filing.

@huonw huonw closed this as completed Nov 22, 2014
@mitsuhiko
Copy link
Contributor Author

I don't think it's a duplicate. The code worked on a rustc from ~three days ago or so, it regressed very recently. Also the error message looks a bit different.

@huonw
Copy link
Member

huonw commented Nov 22, 2014

This is caused by the compiler indexing out of bounds while trying to print lines for diagnostics and is heavily dependent on the precise structure of which macros are used, their internals and the offsets/spacing in the main file. As such ever instance is subtly different and it can appear/disappear as the macros change slightly, but they all have the common threads of macros and previous diagnostics.

There's quite a few other dupes of #14091 linked on that bug, some of which are closer to this. There's so currently a PR open that apparently fixes these bugs. (I'm on my phone so cannot easily find them myself right now.)

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