Skip to content

ICE on a macro in a pattern alternation #23891

Closed
@goffrie

Description

@goffrie

The following code ICEs:

macro_rules! id {
    ($s: pat) => ($s);
}

fn main() {
    match (Some(123), Some(456)) {
        (id!(Some(a)), _) | (_, id!(Some(a))) => println!("{}", a),
        _ => (),
    }
}

It works when the macro call is removed.

My slightly-old version of rust gives the following backtrace:

thread 'rustc' panicked at 'no entry found for key', /home/goffrie/dev/rust/src/libcore/option.rs:330

stack backtrace:
   1:     0x7efefa08d032 - sys::backtrace::write::h7ca9d6657de1b548QBA
   2:     0x7efefa0b3082 - panicking::on_panic::hfaf5dfd21cc0545djHJ
   3:     0x7efef9ff97c9 - rt::unwind::begin_unwind_inner::hb398af6001c5d4f3mnJ
   4:     0x7efef9ff9b71 - rt::unwind::begin_unwind_fmt::ha1d436626fc5bf7fXlJ
   5:     0x7efefa0b2c07 - rust_begin_unwind
   6:     0x7efefa1052f4 - panicking::panic_fmt::h0bd6ed4ea3348908IZs
   7:     0x7efef8e04651 - check::_match::check_pat::ha2990e5282d22e34jQa
   8:     0x7efef8e0303e - check::_match::check_pat::ha2990e5282d22e34jQa
   9:     0x7efef8e0ffba - check::_match::check_match::h47d594fa122f6259Sab
  10:     0x7efef8edc501 - check::check_expr_with_unifier::h9332560874666675652
  11:     0x7efef8eb7496 - check::check_block_with_expected::h1a8e45815c6003bdP2r
  12:     0x7efef8e9f2d2 - check::check_fn::hb75ebebf0222a800fmn
  13:     0x7efef8eb4943 - check::check_bare_fn::h762d80345b3f5b23Vbn
  14:     0x7efef8eacf1f - check::check_item::h2e6a4db7222a1b5ezun
  15:     0x7efef8f6cce3 - check_crate::closure.35673
  16:     0x7efef8f68807 - check_crate::hae3402bbd14ff71ehfC
  17:     0x7efefa6af1fe - driver::phase_3_run_analysis_passes::ha5b83e6715d58901mGa
  18:     0x7efefa694375 - driver::compile_input::hecbda444ba92b3ecNba
  19:     0x7efefa75951d - run_compiler::h74aecff159dc62efG6b
  20:     0x7efefa75728c - thunk::F.Invoke<A, R>::invoke::h9300578721282765836
  21:     0x7efefa755ee0 - rt::unwind::try::try_fn::h3225268192642470759
  22:     0x7efefa127a08 - rust_try_inner
  23:     0x7efefa1279f5 - rust_try
  24:     0x7efefa75666b - thunk::F.Invoke<A, R>::invoke::h13041851399089429017
  25:     0x7efefa0a0885 - sys::thread::thread_start::h20fa58b29f51f627t8E
  26:     0x7efef41b4373 - start_thread
  27:     0x7efef9c8127c - __clone
  28:                0x0 - <unknown>

(The error message changed in some later version but the ICE still happens, apparently.)

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