Skip to content

assertion failure with src/test/ui/pattern/const-pat-ice.rs #59996

Closed
@matthiaskrgr

Description

@matthiaskrgr
// failure-status: 101
// rustc-env:RUST_BACKTRACE=0

// This is a repro test for an ICE in our pattern handling of constants.

const FOO: &&&u32 = &&&42;

fn main() {
    match unimplemented!() {
        &&&42 => {},
        FOO => {},
        _ => {},
    }
}

When checking with "cargo check", rustc hits an assertion failure:

    Checking crash v0.1.0 (/tmp/crash)
warning: unreachable arm
 --> src/main.rs:7:18
  |
7 |         &&&42 => {},
  |                  ^^
  |
  = note: #[warn(unreachable_code)] on by default

warning: unreachable pattern
 --> src/main.rs:8:9
  |
8 |         FOO => {},
  |         ^^^
  |
  = note: #[warn(unreachable_patterns)] on by default

thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir/hair/pattern/_match.rs:1069:5
stack backtrace:
   0:     0x7f2eaa92bd73 - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::he0ba5a87706fdb06
                               at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1:     0x7f2eaa923bfb - std::sys_common::backtrace::_print::h0f3483ebe5e1af88
                               at src/libstd/sys_common/backtrace.rs:71
   2:     0x7f2eaa927fd6 - std::panicking::default_hook::{{closure}}::haadf77e5fbe3559e
                               at src/libstd/sys_common/backtrace.rs:59
                               at src/libstd/panicking.rs:197
   3:     0x7f2eaa927d69 - std::panicking::default_hook::hdaa11accde9a3f58
                               at src/libstd/panicking.rs:211
   4:     0x7f2ea86c51f0 - rustc::util::common::panic_hook::h4cbb878598297ef8
   5:     0x7f2eaa9287c8 - std::panicking::rust_panic_with_hook::hf72148e2f6bd5661
                               at src/libstd/panicking.rs:478
   6:     0x7f2ea8de2cf4 - std::panicking::begin_panic::h2007827ee00b90b2
   7:     0x7f2ea8e093c4 - rustc_mir::hair::pattern::_match::is_useful::hd7ed9e7213150024
   8:     0x7f2ea8e0ab6d - rustc_mir::hair::pattern::_match::is_useful_specialized::hb8a1598a65e3b271
   9:     0x7f2ea91e7f54 - <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold::h3fcdca02ea14ec38
  10:     0x7f2ea8e0a605 - rustc_mir::hair::pattern::_match::is_useful::hd7ed9e7213150024
  11:     0x7f2ea8e0ab6d - rustc_mir::hair::pattern::_match::is_useful_specialized::hb8a1598a65e3b271
  12:     0x7f2ea91e7f54 - <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold::h3fcdca02ea14ec38
  13:     0x7f2ea8e0a605 - rustc_mir::hair::pattern::_match::is_useful::hd7ed9e7213150024
  14:     0x7f2ea918ce06 - rustc_mir::hair::pattern::check_match::check_arms::h6c99f59ecc84ce94
  15:     0x7f2ea8e059ab - rustc_mir::hair::pattern::_match::MatchCheckCtxt::create_and_enter::h1b1560cb14c299f7
  16:     0x7f2ea918c3d7 - <rustc_mir::hair::pattern::check_match::MatchVisitor as rustc::hir::intravisit::Visitor>::visit_expr::haf5104fa4e978225
  17:     0x7f2ea918c16b - <rustc_mir::hair::pattern::check_match::MatchVisitor as rustc::hir::intravisit::Visitor>::visit_expr::haf5104fa4e978225
  18:     0x7f2ea918c561 - <rustc_mir::hair::pattern::check_match::MatchVisitor as rustc::hir::intravisit::Visitor>::visit_body::hb0e552a09c406625
  19:     0x7f2ea918bf6c - rustc_mir::hair::pattern::check_match::check_match::h0531531b2ba4c51b
  20:     0x7f2eaa3b25aa - rustc::ty::query::__query_compute::check_match::hc106e74c584eb3c9
  21:     0x7f2eaa30173c - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_match>::compute::hb98edf93d3a6e54c
  22:     0x7f2eaa2fa24a - rustc::dep_graph::graph::DepGraph::with_task_impl::h638c28c96ca61a0c
  23:     0x7f2eaa316fe7 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::hacd07eac3642d837
  24:     0x7f2eaa301658 - rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::heecedce46dfbac9a
  25:     0x7f2eaa2f50b7 - rustc::util::common::time::h85c150ce80df33f3
  26:     0x7f2eaa9394a9 - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:87
  27:     0x7f2eaa2ffe31 - rustc_interface::passes::analysis::{{closure}}::h43f87ca6908e783e
  28:     0x7f2eaa2f4468 - rustc::util::common::time::h61b8a0bb51f98662
  29:     0x7f2eaa34d14e - rustc_interface::passes::analysis::h2a8459513ab94adc
  30:     0x7f2eaac07682 - rustc::ty::query::__query_compute::analysis::hfdfdefc95b72369b
  31:     0x7f2eaac39d88 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute::hc5444c8ee5e312dc
  32:     0x7f2eaac16a72 - rustc::dep_graph::graph::DepGraph::with_task_impl::h6ae66b24bed5ec4f
  33:     0x7f2eaac3ac4d - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h146c2a97853525ef
  34:     0x7f2eaabfe859 - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::hc5bcf3e705fb931f
  35:     0x7f2eaa38fb04 - rustc_interface::passes::create_global_ctxt::{{closure}}::h77440ef2a630b6be
  36:     0x7f2eaac01028 - rustc_interface::interface::run_compiler_in_existing_thread_pool::h46bba02ee59f142b
  37:     0x7f2eaabe1b63 - std::thread::local::LocalKey<T>::with::h34ffb00bfd367860
  38:     0x7f2eaac46c84 - scoped_tls::ScopedKey<T>::set::h7d0ef554ad6a2f92
  39:     0x7f2eaac77d4f - syntax::with_globals::h8119039844d87a66
  40:     0x7f2eaabe3357 - std::sys_common::backtrace::__rust_begin_short_backtrace::h04eb124b36b3f4b3
  41:     0x7f2eaa9394a9 - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:87
  42:     0x7f2eaac02b58 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h62a25d2cc7f5b35b
  43:     0x7f2eaa90aefe - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h9112a52938383736
                               at /rustc/3de0106789468b211bcc3a25c09c0cf07119186d/src/liballoc/boxed.rs:702
  44:     0x7f2eaa93820f - std::sys::unix::thread::Thread::new::thread_start::h858b049c594cf60d
                               at /rustc/3de0106789468b211bcc3a25c09c0cf07119186d/src/liballoc/boxed.rs:702
                               at src/libstd/sys_common/thread.rs:14
                               at src/libstd/sys/unix/thread.rs:80
  45:     0x7f2eaa85ea9c - start_thread
  46:     0x7f2eaa77fb22 - clone
  47:                0x0 - <unknown>
query stack during panic:
#0 [check_match] processing `main::main`
#1 [analysis] running analysis passes on this crate
end of query stack

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.35.0-nightly (3de010678 2019-04-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental -C target-cpu=native --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `crash`.

To learn more, run the command again with --verbose.

cc rust-lang/rust-clippy#3142

Metadata

Metadata

Assignees

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-testsuiteArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions