Skip to content

ICE with assert! misusage #14261

Closed
Closed
@youknowone

Description

@youknowone

rust version: edae0bdabf75b6acf4f0f0eb5bc2bd3b29d58b81

minimal case:

#![feature(macro_rules)]










pub fn main() {
    assert!('a', 'x');
}

error session:

$ RUST_BACKTRACE=1 rustc bug.rs
<std macros>:8:12: 13:16 error: cannot apply unary operator `!` to type `char`
<std macros>:8         if !$cond {
<std macros>:9             fail!($($arg),+)
<std macros>:10         }
<std macros>:11     );
<std macros>:12 )
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'index out of bounds: the len is 12 but the index is 12', /Users/youknowone/Projects/rust/src/libsyntax/lib.rs:1
stack backtrace:
   1:        0x10fcd66d5 - rt::backtrace::imp::write::h323721627b2b1225X7F::v0.11.pre
   2:        0x10fc4288d - rt::unwind::begin_unwind_inner::h60760c64743357011HF::v0.11.pre
   3:        0x10fcd6180 - rt::unwind::begin_unwind::h6020163020384298928::v0.11.pre
   4:        0x10fcd60cd - rust_fail_bounds_check
   5:        0x10fce82de - failure::fail_bounds_check::h7f0a2bd1d0f5f720IuF::v0.11.pre
   6:        0x10f311589 - codemap::FileMap::get_line::h9336c90a9f16f513Crd::v0.11.pre
   7:        0x10f30e7b6 - diagnostic::emit::h959dada577311038Igc::v0.11.pre
   8:        0x10f306348 - diagnostic::EmitterWriter.Emitter::emit::h3237aef84ed976e5Pcc::v0.11.pre
   9:        0x10f3032b4 - diagnostic::Handler::emit::h8571242cc72ee46cU0b::v0.11.pre
  10:        0x10f3021e1 - diagnostic::SpanHandler::span_err::h5d7dc5dae491f8232Sb::v0.11.pre
  11:        0x10d18f720 - middle::typeck::infer::InferCtxt<'a>::type_error_message_str_with_expected::hb3ac5fd44a2425f9HJq::v0.11.pre
  12:        0x10d22ce5a - middle::typeck::infer::InferCtxt<'a>::type_error_message::hb39509a45c2ca49dpRq::v0.11.pre
  13:        0x10d23b06a - middle::typeck::check::check_expr_with_unifier::check_user_unop::closure.69252
  14:        0x10d238b91 - middle::typeck::check::check_expr_with_unifier::lookup_op_method::hda7bc63cc77f2cb5Yhb::v0.11.pre
  15:        0x10d23ae30 - middle::typeck::check::check_expr_with_unifier::check_user_unop::h2c5b8ba19a387c68Qwb::v0.11.pre
  16:        0x10d234e0d - middle::typeck::check::check_expr_with_unifier::hda4aceb5d627d37dDIa::v0.11.pre
  17:        0x10d22f7b2 - middle::typeck::check::check_expr_with_unifier::hda4aceb5d627d37dDIa::v0.11.pre
  18:        0x10d24a6f3 - middle::typeck::check::check_stmt::h3ef4296b6235d3a5F3c::v0.11.pre
  19:        0x10d20e98a - middle::typeck::check::check_block_with_expected::h38d53dd50936aaf9C7c::v0.11.pre
  20:        0x10d20a17a - middle::typeck::check::check_fn::h6e445ad5ae361babHv8::v0.11.pre
  21:        0x10d20999a - middle::typeck::check::check_bare_fn::h04b771654cb10f90el8::v0.11.pre
  22:        0x10d2018cf - middle::typeck::check::check_item::he9ac829b3c2e5150iS8::v0.11.pre
  23:        0x10d20971d - middle::typeck::check::check_item_types::h10914accf6220219wk8::v0.11.pre
  24:        0x10d3490e6 - util::common::time::h16118557760602876446::v0.11.pre
  25:        0x10d34811d - middle::typeck::check_crate::h2ec4c444fa31334a8gw::v0.11.pre
  26:        0x10d70a36d - driver::driver::phase_3_run_analysis_passes::h921ebf4905d02d63Wci::v0.11.pre
  27:        0x10d703b33 - driver::driver::compile_input::hea625012341a5a6dt2h::v0.11.pre
  28:        0x10d7a12dd - driver::main_args::closure.92564
  29:        0x10d7b52a7 - driver::monitor::closure.93739
  30:        0x10d7afaab - task::TaskBuilder::try::closure.93506
  31:        0x10cf0178c - task::spawn_opts::closure.7440
  32:        0x10fccd3e8 - rt::task::Task::run::closure.28473
  33:        0x10fceefec - rust_try
  34:        0x10fccd267 - rt::task::Task::run::h5ae656a629cc94b6gxD::v0.11.pre
  35:        0x10cf015ef - task::spawn_opts::closure.7412
  36:        0x10fcd4f06 - rt::thread::thread_start::hea60fb28b6673887rfE::v0.11.pre
  37:     0x7fff870d6899 - _pthread_body
  38:     0x7fff870d672a - _pthread_struct_init

required condition:

  • mistyped usage in assert! - any 2 char type arguments make this error
  • specific lines before assert! code - if you remove blank lines, it start working correctly

I have no idea to reduce this code anymore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions