Skip to content

Compiler panic with unknown identifier followed by function call in if statement #34217

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
NoraCodes opened this issue Jun 11, 2016 · 2 comments

Comments

@NoraCodes
Copy link
Contributor

NoraCodes commented Jun 11, 2016

I wrote an if statement with not in it, as if I were in Python, and left in the match statement syntax, and the compiler panicked.

The code was truly a mangled mess:

if not  is_command_valid(&arg0) {

    false => return Err(String::from("Invalid command ") + &arg0);

}

I would expect this to complain about either syntax or about not not being a known identifier.

Instead, the compiler error was:

src/commands.rs:60:17: 60:33 error: expected `{`, found `is_command_valid`
src/commands.rs:60         if not  is_command_valid(&arg0) {
                                   ^~~~~~~~~~~~~~~~
src/commands.rs:60:17: 60:33 help: place this code inside a block
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 0 }', ../src/libcore/result.rs:746

The backtrace was:

stack backtrace:
   1:     0x7fee3be27570 - std::sys::backtrace::tracing::imp::write::h4c73fcd3363076f5
   2:     0x7fee3be34c6b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h0422dbb3077e6747
   3:     0x7fee3be3480c - std::panicking::default_hook::haac48fa641db8fa2
   4:     0x7fee3bdf979f - std::sys_common::unwind::begin_unwind_inner::h39d40f52add53ef7
   5:     0x7fee3bdfb888 - std::sys_common::unwind::begin_unwind_fmt::h64c0ff793199cc1b
   6:     0x7fee3be24d81 - rust_begin_unwind
   7:     0x7fee3be7e85f - core::panicking::panic_fmt::h73bf9d7e8e891a73
   8:     0x7fee333aba0b - core::result::unwrap_failed::h82c81d60621f70bd
   9:     0x7fee333ab97e - rbml::Doc::as_str_slice::hd88d17b04c3f2cca
  10:     0x7fee39c07a62 - rustc_metadata::decoder::maybe_get_crate_hash::h1c0939ce4d9ba236
  11:     0x7fee39c3b01b - rustc_metadata::loader::Context::extract_one::h56453781fb65bffa
  12:     0x7fee39c32db5 - rustc_metadata::loader::Context::find_library_crate::h30ea71d32623d713
  13:     0x7fee39c18f96 - rustc_metadata::loader::Context::load_library_crate::h7787c1fa9559d604
  14:     0x7fee39c17e1f - rustc_metadata::creader::CrateReader::resolve_crate::h98decfaedbcfe12a
  15:     0x7fee39c196eb - rustc_metadata::creader::CrateReader::resolve_crate_deps::_$u7b$$u7b$closure$u7d$$u7d$::h4bd0eba4f8aa0bca
  16:     0x7fee39c1949c - _<std..collections..HashMap<K, V, S> as std..iter..FromIterator<(K, V)>>::from_iter::h7ccc89cd3e9da036
  17:     0x7fee39c151ba - rustc_metadata::creader::CrateReader::register_crate::hdfd966766b932c68
  18:     0x7fee39c1a562 - rustc_metadata::creader::CrateReader::read_extension_crate::hb0997de4fb0918fb
  19:     0x7fee39c1c85e - rustc_metadata::creader::CrateReader::read_exported_macros::hf3b61431145aafb6
  20:     0x7fee39c400e8 - _<macro_import..MacroLoader<'a> as syntax..visit..Visitor<'v>>::visit_item::h668e7bfc1acab9b3
  21:     0x7fee39c3eeea - rustc_metadata::macro_import::read_macro_defs::h240a20dad60749cc
  22:     0x7fee3c35d9ec - rustc_driver::driver::phase_2_configure_and_expand::h505e157de342d54f
  23:     0x7fee3c34409a - rustc_driver::driver::compile_input::h6491aaddd9e61258
  24:     0x7fee3c32c4e4 - rustc_driver::run_compiler::h80b2ba5e4d787c5f
  25:     0x7fee3c329941 - std::sys_common::unwind::try::try_fn::h34e27823ddd1d5e9
  26:     0x7fee3be24d0b - __rust_try
  27:     0x7fee3be24c9d - std::sys_common::unwind::inner_try::h9eebd8dc83f388a6
  28:     0x7fee3c32a18a - _<F as std..boxed..FnBox<A>>::call_box::h3d5d78986dfac5b2
  29:     0x7fee3be32e04 - std::sys::thread::Thread::new::thread_start::h471ad90789353b5b
  30:     0x7fee347f16f9 - start_thread
  31:     0x7fee3ba88b5c - clone
  32:                0x0 - <unknown>
@jonas-schievink
Copy link
Contributor

Looks like #33778

And damn that help is bad

@NoraCodes
Copy link
Contributor Author

Oh, yeah definitely the same bug - I was using rustup run nightly cargo clippy on the source. Builds perfectly after cargo clean.

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