Skip to content

error: cannot apply unary operator ! to type `collections::vec::Vec<int> (compiler error) #19259

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
ghost opened this issue Nov 24, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 24, 2014

Seems like I caused this by passing two arguments to assert!, mistaking it for assert_eq!. Also seems to be related to one of them being a vector.

The specific line that blew everything up:

assert!(slide_iter.next().unwrap(), vec![1, 2, 3, 4, 5])

Version:

ᐷ rustc --version=verbose
rustc 0.13.0-nightly (2274996a1 2014-11-23 00:36:43 +0000)
binary: rustc
commit-hash: 2274996a1d1092d513ac5df74524b30cb8928961
commit-date: 2014-11-23 00:36:43 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly

Full backtrace:

ᐷ env RUST_BACKTRACE=1 cargo test --verbose
   Compiling iter-slide v0.0.1 (file:///Users/slapresta/Code/rust-iter-slide)
     Running `rustc /Users/slapresta/Code/rust-iter-slide/src/lib.rs --crate-name iter-slide --crate-type lib -g --test -C metadata=373c7667269f0c6b -C extra-filename=-373c7667269f0c6b --out-dir /Users/slapresta/Code/rust-iter-slide/target --dep-info /Users/slapresta/Code/rust-iter-slide/target/.fingerprint/iter-slide-c47d984372a1aff1/dep-test-lib-iter-slide -L /Users/slapresta/Code/rust-iter-slide/target -L /Users/slapresta/Code/rust-iter-slide/target/deps`
<std macros>:8:12: 74:37 error: cannot apply unary operator `!` to type `collections::vec::Vec<int>`
<std macros>:8         if !$cond {
<std macros>:9             panic!($($arg),+)
<std macros>:10         }
<std macros>:11     );
<std macros>:12 )
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 12 but the index is 12', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/lib.rs:1

stack backtrace:
   1:        0x1067225f2 - rt::backtrace::imp::write::he31e36fe59b39292ugt
   2:        0x1067256ad - failure::on_fail::h7c2689f722982652nCt
   3:        0x10698a575 - unwind::begin_unwind_inner::h09866e00e97d31fbI2c
   4:        0x10698a1bf - unwind::begin_unwind_fmt::h443e47d11b48984fTZc
   5:        0x106989f62 - rust_begin_unwind
   6:        0x1069d4bfc - panicking::panic_fmt::h3455617902fba541RQl
   7:        0x1069dd341 - panicking::panic_bounds_check::h900aab84d3ecc6b2pPl
   8:        0x1046f31a5 - codemap::FileMap::get_line::hc52e50d9979bf308m4E
   9:        0x1047215a3 - diagnostic::emit::h08e4b4b1eedac8ebwvG
  10:        0x10471de38 - diagnostic::EmitterWriter.Emitter::emit::h7bd93d33c667684clrG
  11:        0x10471c625 - diagnostic::Handler::emit::hfe59640b83e1f80fF8F
  12:        0x1046ef33b - diagnostic::SpanHandler::span_err::h21457c03dc6c206aEWF
  13:        0x103aed9e0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message_str_with_expected::h39aade6f795bf9cfTKF
  14:        0x103a3da91 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message::h15876ab7b8cb5941dQF
  15:        0x103a7854d - middle::typeck::check::check_expr_with_unifier::check_user_unop::closure.111450
  16:        0x103a76ebf - middle::typeck::check::check_expr_with_unifier::lookup_op_method::h9972570c626588404Km
  17:        0x103a514a6 - middle::typeck::check::check_expr_with_unifier::check_user_unop::h4c01d263bce10250u2m
  18:        0x103a4cf7f - middle::typeck::check::check_expr_with_unifier::h87e20b2411356f4dNzm
  19:        0x103a48542 - middle::typeck::check::check_expr_with_unifier::h87e20b2411356f4dNzm
  20:        0x103a7b3fe - middle::typeck::check::check_stmt::h5cddc3b61911fb8fgvo
  21:        0x103a02358 - middle::typeck::check::check_block_with_expected::h7a5c044377af18bdvzo
  22:        0x1039dc070 - middle::typeck::check::check_fn::h4e87d70252938451e0i
  23:        0x1039fec1e - middle::typeck::check::check_bare_fn::hef225d6ec06d4469jPi
  24:        0x1039fabd1 - middle::typeck::check::check_item::h77ca958dbe883a3dt9i
  25:        0x1039fe940 - middle::typeck::check::check_item_types::hd8daa0849ee11a40tOi
  26:        0x103d828e6 - util::common::time::h15524079834469819921
  27:        0x103d81d64 - middle::typeck::check_crate::h4e1efee8578d0a1ccwM
  28:        0x1033737d3 - driver::driver::phase_3_run_analysis_passes::hacbc87f3f7b031842eS
  29:        0x103367cfc - driver::driver::compile_input::h70341d8b5b6083248VR
  30:        0x1033e5e25 - driver::run_compiler::h1f300b2db92b2477gUT
  31:        0x1033e45fe - driver::run::closure.59667
  32:        0x1031fc3ce - task::TaskBuilder::try_future::closure.38920
  33:        0x1066b02e4 - task::TaskBuilder::spawn_internal::closure.24355
  34:        0x106987ddd - task::Task::spawn::closure.5917
  35:        0x1069ec6ac - rust_try_inner
  36:        0x1069ec696 - rust_try
  37:        0x106987eb7 - unwind::try::h207282f5be16daac3Qc
  38:        0x106987c8c - task::Task::run::h7eee475ba5444e2993b
  39:        0x10698798f - task::Task::spawn::closure.5893
  40:        0x106989627 - thread::thread_start::hc58864c152053492Wnc
  41:     0x7fff96e372fc - _pthread_body
  42:     0x7fff96e37279 - _pthread_body

Could not compile `iter-slide`.

Caused by:
  Process didn't exit successfully: `rustc /Users/slapresta/Code/rust-iter-slide/src/lib.rs --crate-name iter-slide --crate-type lib -g --test -C metadata=373c7667269f0c6b -C extra-filename=-373c7667269f0c6b --out-dir /Users/slapresta/Code/rust-iter-slide/target --dep-info /Users/slapresta/Code/rust-iter-slide/target/.fingerprint/iter-slide-c47d984372a1aff1/dep-test-lib-iter-slide -L /Users/slapresta/Code/rust-iter-slide/target -L /Users/slapresta/Code/rust-iter-slide/target/deps` (status=101)
@alexcrichton
Copy link
Member

This is a dupe of #14091 which was fixed in #19158, but thanks for the report!

@ghost
Copy link
Author

ghost commented Nov 24, 2014

Welp, time to run rustup. Thanks for the quick response!

lnicola pushed a commit to lnicola/rust that referenced this issue Mar 3, 2025
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