Rust-clippy: thread 'main' panicked at '`else return` is not possible'

Created on 28 Dec 2016  路  5Comments  路  Source: rust-lang/rust-clippy

Running cargo clippy on my project causes clippy to panic.

Message and stack trace:

thread 'main' panicked at '`else return` is not possible', C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\libcore\option.rs:715
stack backtrace:
   0:     0x7ff97197edaa - std::panicking::Location::line::h3f91a23a140528f1
   1:     0x7ff97197e2b6 - std::panicking::Location::line::h3f91a23a140528f1
   2:     0x7ff971981c8d - std::panicking::rust_panic_with_hook::h7e1d2cc288a6d6e6
   3:     0x7ff971981b28 - std::panicking::begin_panic_fmt::h32a0ae8a5b33d0ae
   4:     0x7ff971981a44 - std::panicking::begin_panic_fmt::h32a0ae8a5b33d0ae
   5:     0x7ff9719819d9 - rust_begin_unwind
   6:     0x7ff971992107 - core::panicking::panic_fmt::he0e6e02f9ec39ef9
   7:     0x7ff97199216f - core::option::expect_failed::h7d530bc21bf41138
   8:     0x7ff7b4c75296 - <unknown>
   9:     0x7ff7b4c75474 - <unknown>
  10:     0x7ff96a8c2c1c - <rustc::lint::context::EarlyContext<'a> as syntax::visit::Visitor<'a>>::visit_fn::h1d53236c32c5d437
  11:     0x7ff96a7a1975 - <unknown>
  12:     0x7ff96a8aeb4c - rustc::lint::context::gather_attrs::ha6cadeb122d9ae67
  13:     0x7ff96a7a182e - <unknown>
  14:     0x7ff96a8aeb4c - rustc::lint::context::gather_attrs::ha6cadeb122d9ae67
  15:     0x7ff96a8c28d6 - <rustc::lint::context::EarlyContext<'a> as syntax::visit::Visitor<'a>>::visit_stmt::h05f76e5edae56176
  16:     0x7ff96a8c46fe - <rustc::lint::context::EarlyContext<'a> as syntax::visit::Visitor<'a>>::visit_block::h876d47bb890f5fdb
  17:     0x7ff96a8c2e4c - <rustc::lint::context::EarlyContext<'a> as syntax::visit::Visitor<'a>>::visit_fn::h1d53236c32c5d437
  18:     0x7ff96a79ebde - <unknown>
  19:     0x7ff96a8affbc - rustc::lint::context::gather_attrs::ha6cadeb122d9ae67
  20:     0x7ff96a8b19c0 - rustc::lint::context::gather_attrs::ha6cadeb122d9ae67
  21:     0x7ff96a8c421c - <rustc::lint::context::EarlyContext<'a> as syntax::visit::Visitor<'a>>::visit_mod::h35ff9feb0a7e8539
  22:     0x7ff96a8b193b - rustc::lint::context::gather_attrs::ha6cadeb122d9ae67
  23:     0x7ff96a8c421c - <rustc::lint::context::EarlyContext<'a> as syntax::visit::Visitor<'a>>::visit_mod::h35ff9feb0a7e8539
  24:     0x7ff96a8c9f13 - rustc::lint::context::check_ast_crate::h96ca2d63e898760d
  25:     0x7ff972c3fd0e - rustc_driver::driver::count_nodes::ha44ea76b460cacd8
  26:     0x7ff972c31fed - rustc_driver::driver::compile_input::h900404b51c1adf30
  27:     0x7ff972c86f76 - rustc_driver::run_compiler::hffa9ba21e70b1cf9
  28:     0x7ff7b4b9d465 - <unknown>
  29:     0x7ff971984611 - _rust_maybe_catch_panic
  30:     0x7ff97198249a - std::rt::lang_start::ha4bee7dfb0355245
  31:     0x7ff7b4ccefef - <unknown>
  32:     0x7ff99b518363 - BaseThreadInitThunk

Further information:

$ rustc -vV
rustc 1.15.0-nightly (71c06a56a 2016-12-18)
binary: rustc
commit-hash: 71c06a56a120a0d5e3b224105ee3e6754f83e5fa
commit-date: 2016-12-18
host: x86_64-pc-windows-msvc
release: 1.15.0-nightly
LLVM version: 3.9

$ cargo -V
cargo 0.16.0-nightly (ddb5c32 2016-12-16)

$ cargo clippy -V
0.0.104

Most helpful comment

Minimal reproduction:

fn main() {
    || return ();
}
thread 'main' panicked at '`else return` is not possible', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:715
note: Run with `RUST_BACKTRACE=1` for a backtrace.

All 5 comments

Thanks, but what we'd really need is the code triggering that :smile:

Took some time, but I found the offending line:

CODES.get(code as usize).cloned().map_or_else(|| bail!(t!("Unknown error code: {}"), code), Ok)

bail! is a macro from error-chain and t! is a macro that replaces a string literal with its localized version. Placing { and } around the bail! expression fixes the panic.

I'm getting the same issue when linting my crate with the traceback leading to the same code @llogiq linked above.

Is there any way for me to pick out the area that's causing the problem in my code? The crate contains thousands of lines of code and I've got very little idea of how to go about locating the exact part that triggered the error.

Minimal reproduction:

fn main() {
    || return ();
}
thread 'main' panicked at '`else return` is not possible', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:715
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Was this page helpful?
0 / 5 - 0 ratings