Skip to content

ICE for assert!() misuse #15901

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
Ryman opened this issue Jul 22, 2014 · 4 comments
Closed

ICE for assert!() misuse #15901

Ryman opened this issue Jul 22, 2014 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Ryman
Copy link
Contributor

Ryman commented Jul 22, 2014

fn main() {
    let s = "x";
    assert!(s, "x")
}

According to IRC and rusti this isn't repro on builds from 2days ago, it's repro on master from today: rustc 0.12.0-pre (2ffccb76c 2014-07-22 16:11:14 +0000)

<std macros>:8:12: 836:14 error: cannot apply unary operator `!` to type `&'static str`
<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://doc.rust-lang.org/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', /<snip>/rust/src/libsyntax/lib.rs:1

stack backtrace:
   1:        0x10a7e3aa0 - rt::backtrace::imp::write::hd7d4c392a36e3b9e3fq
   2:        0x10a7e7025 - failure::on_fail::h8404f3cd3c77692bmwq
   3:        0x10aa80e09 - unwind::begin_unwind_inner::h8c77354846a1c41cYXd
   4:        0x10aa80979 - unwind::begin_unwind_fmt::h4765609ebe25027d7Ud
   5:        0x10aa80781 - rust_begin_unwind
   6:        0x10aacebbe - failure::begin_unwind::h193e3d158c8de7d0Esj
   7:        0x10aad5639 - failure::fail_bounds_check::hda72a0433634cad2Qqj
   8:        0x108b460ac - codemap::FileMap::get_line::hc76ee3b96dcc58be49B
   9:        0x108b51d56 - diagnostic::emit::h2ef32dd5a1fa2162rxD
  10:        0x108b4e018 - diagnostic::EmitterWriter.Emitter::emit::h3363f5fc98fed7f3qtD
  11:        0x108b4bf7e - diagnostic::Handler::emit::hb7f53138b989e30fdbD
  12:        0x108b44025 - diagnostic::SpanHandler::span_err::h558d1077eaa5eb2du0C
  13:        0x107c2f3d7 - middle::typeck::infer::InferCtxt<'a>::type_error_message_str_with_expected::hf3a5ea93ee8e997aRqb
  14:        0x107cd77a0 - middle::typeck::infer::InferCtxt<'a>::type_error_message::h2ef5e1f7d553609ezyb
  15:        0x107ce7f10 - middle::typeck::check::check_expr_with_unifier::check_user_unop::closure.$x22closure$x22$LP$124870$RP$
  16:        0x107ce5e86 - middle::typeck::check::check_expr_with_unifier::lookup_op_method::hf7437403612d6c05pDT
  17:        0x107ce7ceb - middle::typeck::check::check_expr_with_unifier::check_user_unop::he2a51680c0a9174dgST
  18:        0x107ce01b2 - middle::typeck::check::check_expr_with_unifier::he7bd243d8859f79bEpT
  19:        0x107cdd0e2 - middle::typeck::check::check_expr_with_unifier::he7bd243d8859f79bEpT
  20:        0x107ca8216 - middle::typeck::check::check_block_with_expected::hb08cd2b6ca38b5a4GuV
  21:        0x107ca399d - middle::typeck::check::check_fn::h0e1de9cd6b78a7a6CGQ
  22:        0x107ca3332 - middle::typeck::check::check_bare_fn::h5b346f297b024120dwQ
  23:        0x107c9c402 - middle::typeck::check::check_item::h5e573131626cb5caQ4Q
  24:        0x107ca30ad - middle::typeck::check::check_item_types::he3cf518bb025f812vvQ
  25:        0x107e8eb2c - middle::typeck::check_crate::h0f410da8d6c496badOh
  26:        0x107f62e49 - driver::driver::phase_3_run_analysis_passes::hba3c6c5b504fe218Lkw
  27:        0x107f5dc16 - driver::driver::compile_input::h172f40afa8c5e7d6q6v
  28:        0x108005f83 - driver::run_compiler::h11c19b472aaa0f08Dgz
  29:        0x1080038a6 - driver::main_args::closure.$x22closure$x22$LP$138131$RP$
  30:        0x1080163db - task::TaskBuilder<S>::try_future::closure.$x22closure$x22$LP$139275$RP$
  31:        0x1080162c6 - task::TaskBuilder<S>::spawn_internal::closure.$x22closure$x22$LP$139252$RP$
  32:        0x10767987c - task::spawn_opts::closure.$x22closure$x22$LP$8299$RP$
  33:        0x10aae5d8c - rust_try
  34:        0x10aa7db4b - unwind::try::hcf31d7fcff740d283Ld
  35:        0x10aa7d8b3 - task::Task::run::h1882bc75d327db00VXc
  36:        0x107679711 - task::spawn_opts::closure.$x22closure$x22$LP$8244$RP$
  37:        0x10aa7fba6 - thread::thread_start::haae59359e4020c83tkd
  38:     0x7fff8e190899 - _pthread_body
  39:     0x7fff8e19072a - _pthread_struct_init
@treeman
Copy link
Contributor

treeman commented Jul 24, 2014

Here are some other tests:

// error: cannot apply unary operator `!` to type `core::option::Option<<generic #0>>`
// error: internal compiler error: unexpected failure
assert!(None, None);

// error: mismatched types: expected `bool` but found `<generic integer #0>`
// error: internal compiler error: unexpected failure
assert!(1, 1);

// error: cannot apply unary operator `!` to type `core::option::Option<<generic #5>>`
// but no internal compiler error
assert!(None);

// Works
assert!(true, 1i);

@opp11
Copy link

opp11 commented Aug 9, 2014

I've also run into this bug. Here is my info:

$ uname -a
Linux crunchbang 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u3 i686 GNU/Linux

$ cargo --version
cargo 0.0.1-pre-nightly (fab4ae7 2014-08-04 03:25:05 +0000)

$ rustc --version
rustc 0.12.0-pre-nightly (25741603f 2014-08-03 23:46:10 +0000)

Getting this backtrace:

$ RUST_BACKTRACE=1 cargo test
   Compiling calcr v0.0.1 (file:/home/patrick/Dropbox/projects/calcr)
<std macros>:8:12: 107:46 error: cannot apply unary operator `!` to type `core::result::Result<(),&'static str>`
<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://doc.rust-lang.org/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', /home/rustbuild/src/rust-    buildbot/slave/nightly-linux/build/src/libsyntax/lib.rs:1

 stack backtrace:
   1: 0xb3e452c0 - rt::backtrace::imp::write::ha1c450b4915eb143gcq
   2: 0xb3e48310 - failure::on_fail::h9ff118121a195e26rxq
   3: 0xb64c9ef0 - unwind::begin_unwind_inner::h3a14f8fa4197b75aB8d
   4: 0xb64c9bc0 - unwind::begin_unwind_fmt::h2a42796a19e436e865d
   5: 0xb64c9b60 - rust_begin_unwind
   6: 0xb6513330 - failure::begin_unwind::h71b3c90806f8db38c0j
   7: 0xb6517420 - failure::fail_bounds_check::hf6a2343a99d2624fpYj
   8: 0xb5c94fb0 - codemap::FileMap::get_line::hbaafa5c76d06d454NiC
   9: 0xb5c9f5e0 - diagnostic::emit::h1207110484c28756WHD
  10: 0xb5c9c410 - diagnostic::EmitterWriter.Emitter::emit::h861c31368d14acf9xDD
  11: 0xb5c9a850 - diagnostic::Handler::emit::h3542b2b846a8b13dklD
  12: 0xb5c937d0 - diagnostic::SpanHandler::span_err::hcdfb6f94e1cfbe0eV9C
  13: 0xb6c02d20 -  middle::typeck::infer::InferCtxt<'a>::type_error_message_str_with_expected::h110dc04b6ee80582L8a
  14: 0xb6cb1b20 - middle::typeck::infer::InferCtxt<'a>::type_error_message::hbd6bb41bf684d94ebgb
  15: 0xb6cc6300 - middle::typeck::check::check_expr_with_unifier::check_user_unop::closure.121224
  16: 0xb6cc3e40 - middle::typeck::check::check_expr_with_unifier::lookup_op_method::h5ba548b428edda80MkT
  17: 0xb6cc5f00 - middle::typeck::check::check_expr_with_unifier::check_user_unop::hc81e6082c69f0039DzT
  18: 0xb6cb4990 - middle::typeck::check::check_expr_with_unifier::he69a3f50b075640416S
  19: 0xb6cb4990 - middle::typeck::check::check_expr_with_unifier::he69a3f50b075640416S
  20: 0xb6d17f90 - middle::typeck::check::check_stmt::hfe0c02bad49756f2MaV
  21: 0xb6c7ee70 - middle::typeck::check::check_block_with_expected::heb620c3431a8c912XeV
  22: 0xb6c7ae70 - middle::typeck::check::check_fn::hac63a018f2d6076fqpQ
  23: 0xb6c7ab90 - middle::typeck::check::check_bare_fn::hcec58f2bb6d2b9eegeQ
  24: 0xb6c74360 - middle::typeck::check::check_item::hefceed674604ae234MQ
  25: 0xb6c75f30 - visit::walk_item::h8881549312631385631
  26: 0xb6c75f30 - visit::walk_item::h8881549312631385631
  27: 0xb6c7a990 - middle::typeck::check::check_item_types::h7fc9f56244aa6515ydQ
  28: 0xb6e90990 - middle::typeck::check_crate::closure.126402
  29: 0xb66cbe00 - util::common::time::h5960456725657221026
  30: 0xb6e8f540 - middle::typeck::check_crate::hf8afaae1cb1a8e05Juh
  31: 0xb6f5eeb0 - driver::driver::phase_3_run_analysis_passes::hc41db9e0e1edb3ebLWv
  32: 0xb6f5a1c0 - driver::driver::compile_input::hf7082c9a93eed0120Iv
  33: 0xb6ff8b30 - driver::run_compiler::h95110376e75ff237INy
  34: 0xb6ff8a30 - driver::main_args::closure.134677
  35: 0xb700a1b0 - task::TaskBuilder<S>::try_future::closure.135824
  36: 0xb7009fa0 - task::TaskBuilder<S>::spawn_internal::closure.135801
  37: 0xb66134a0 - task::spawn_opts::closure.8299
  38: 0xb64c9960 - unwind::try::try_fn::h5b6a70a8d3115d40nZd
  39: 0xb6526f90 - rust_try
  40: 0xb64c75d0 - unwind::try::hfdf393c0a0edfa750Wd
  41: 0xb64c7390 - task::Task::run::ha7e1b260e3ee789eC4c
  42: 0xb6613270 - task::spawn_opts::closure.8242
  43: 0xb64c90a0 - thread::thread_start::he601f6c86aee42ccMsd
  44:        0x0 - <unknown>

Could not compile `calcr`.

@thehydroimpulse
Copy link
Contributor

Also hit this recently with &str

@alexcrichton
Copy link
Member

Closing as a dupe of #14091

bors added a commit to rust-lang-ci/rust that referenced this issue Nov 16, 2023
fix: Diagnose everything in nested items, not just def diagnostics

Turns out we only calculated def diagnostics for these before (was wondering why I wasn't getting any type mismatches)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants