Skip to content

compiler crash on innocent-looking match #46964

Closed
@idubrov

Description

@idubrov

the compiler unexpectedly panicked. this is a bug.

I tried this code (hyper = "0.11.9"):

extern crate hyper;

pub fn crash(mime: &hyper::mime::Mime) -> bool {
  match (mime.subtype(), mime.suffix()) {
    (_, Some(hyper::mime::JSON)) => true,
    (hyper::mime::JSON, None) => true,
    _ => false,
  }
}

I expected to see this happen: code compiles (two top branches are incompatible)

Instead, this happened: compiler crashed; re-ordering two top branches fixes the issue

Meta

rustc --version --verbose:

rustc 1.24.0-nightly (5165ee9e2 2017-12-22)
binary: rustc
commit-hash: 5165ee9e209e0e70d89946ccbb7e90b9c0c3a7ac
commit-date: 2017-12-22
host: x86_64-apple-darwin
release: 1.24.0-nightly
LLVM version: 4.0

Backtrace:

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: rustc 1.24.0-nightly (5165ee9e2 2017-12-22) running on x86_64-apple-darwin

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_const_eval/_match.rs:596:4
stack backtrace:
   0:        0x11385781b - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h6748dc16a2d8df2e
   1:        0x113866fae - std::sys_common::backtrace::print::hc1ecb1e5559e6c33
   2:        0x113861410 - std::panicking::default_hook::{{closure}}::hb04e69910a65792e
   3:        0x11386110a - std::panicking::default_hook::h1ca336fe29972357
   4:        0x113861876 - std::panicking::rust_panic_with_hook::h02eae9f31985336e
   5:        0x1116feba1 - std::panicking::begin_panic::h0170dac5d8645b28
   6:        0x1116f50fa - rustc_const_eval::_match::is_useful::h23e3cdc562cbb328
   7:        0x1116f62b2 - rustc_const_eval::_match::is_useful_specialized::h3f912ded1cb5a78e
   8:        0x1116e6b7c - <core::iter::Map<I, F> as core::iter::iterator::Iterator>::try_fold::h8379d8eb0a7a9f77
   9:        0x1116f5320 - rustc_const_eval::_match::is_useful::h23e3cdc562cbb328
  10:        0x1116f62b2 - rustc_const_eval::_match::is_useful_specialized::h3f912ded1cb5a78e
  11:        0x1116e6b7c - <core::iter::Map<I, F> as core::iter::iterator::Iterator>::try_fold::h8379d8eb0a7a9f77
  12:        0x1116f5320 - rustc_const_eval::_match::is_useful::h23e3cdc562cbb328
  13:        0x1116f62b2 - rustc_const_eval::_match::is_useful_specialized::h3f912ded1cb5a78e
  14:        0x1116e6b7c - <core::iter::Map<I, F> as core::iter::iterator::Iterator>::try_fold::h8379d8eb0a7a9f77
  15:        0x1116f5320 - rustc_const_eval::_match::is_useful::h23e3cdc562cbb328
  16:        0x1116fcc67 - rustc_const_eval::check_match::check_arms::hf0b2a24697c406ea
  17:        0x1116f4302 - rustc_const_eval::_match::MatchCheckCtxt::create_and_enter::h8ecb2ffcfac97c79
  18:        0x1116fc6f5 - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h5dc4813f83674f01
  19:        0x1116fc4ee - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h5dc4813f83674f01
  20:        0x1116fc860 - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body::h8627b10027254cdf
  21:        0x1116ff24d - rustc::session::Session::track_errors::he6d05d19e503027d
  22:        0x1116fc2a8 - rustc_const_eval::check_match::check_match::h581d60f966dd70ec
  23:        0x112015dee - rustc::dep_graph::graph::DepGraph::with_task_impl::he4debb199688f723
  24:        0x111d3054a - rustc_errors::Handler::track_diagnostics::he3d49a14b2f2a05b
  25:        0x111c209f0 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::h3e96520081b37b2e
  26:        0x11208ad8e - rustc::ty::maps::<impl rustc::ty::maps::queries::check_match<'tcx>>::force::h9b0cabeb54488ef9
  27:        0x11208b46a - rustc::ty::maps::<impl rustc::ty::maps::queries::check_match<'tcx>>::try_get::h168429d15c730e8b
  28:        0x111ec85e0 - rustc::ty::maps::TyCtxtAt::check_match::h1e0137c83b27f485
  29:        0x111c721b3 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::check_match::h395b3ef7e5d51eb3
  30:        0x1116fc029 - rustc::hir::intravisit::Visitor::visit_nested_body::hc3711ac4cbc2ecf6
  31:        0x11170dedf - rustc::hir::Crate::visit_all_item_likes::hafcfad702b50d9ac
  32:        0x1116fc1cf - rustc_const_eval::check_match::check_crate::hfadb55aaa16d50c3
  33:        0x10d3ccbc6 - <std::thread::local::LocalKey<T>>::with::h0f69a10298329fdf
  34:        0x10d3cf7cc - <std::thread::local::LocalKey<T>>::with::hb51817b52c5d173a
  35:        0x10d41c95e - rustc::ty::context::TyCtxt::create_and_enter::h0fc228efc283eb64
  36:        0x10d396952 - rustc_driver::driver::compile_input::h82abb659e9ffafec
  37:        0x10d3f9d6d - rustc_driver::run_compiler::h4102658971d5220d
  38:        0x10d351d31 - std::sys_common::backtrace::__rust_begin_short_backtrace::ha73cd560ba1185a4
  39:        0x1138913ae - __rust_maybe_catch_panic
  40:        0x10d32b84d - <F as alloc::boxed::FnBox<A>>::call_box::h4a09b2de7d586e97
  41:        0x113850247 - std::sys_common::thread::start_thread::h4cededf2a7a0e7f8
  42:        0x11386a688 - std::sys::unix::thread::Thread::new::thread_start::hc0d8e233205f2988
  43:     0x7fff995e293a - _pthread_body
  44:     0x7fff995e2886 - _pthread_start

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions