Skip to content

Compiler crash when matching generic enum #23151

Closed
@bluecube

Description

@bluecube

I tried this code:

enum Foo<T> {
    A(T),
    B
}

fn main() {
    let x = Foo::<u32>::A(14);
    let y = match x {
        Foo<T>::A(value) => value,
        Foo<T>::B => 7,
    };
    println!("{}", y);
}

and it gave me this message:

error.rs:9:9: 9:12 error: internal compiler error: ident only path should have been covered already
error.rs:9         Foo<T>::A(value) => value,
                   ^~~
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 'Box<Any>', /tmp/portage/dev-lang/rust-1.0.0_alpha2/work/rustc-1.0.0-alpha.2/src/libsyntax/diagnostic.rs:129

I have git version of rust from package in funtoo linux.
When I tried the code at play.rust-lang.org the example produced compiler error, but not a crash.

Meta

rustc --version-verbose:

rustc 1.0.0-dev (built 2015-02-28)
binary: rustc
commit-hash: unknown
commit-date: unknown
build-date: 2015-02-28
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev

Backtrace:

   1:     0x7f894f434c20 - sys::backtrace::write::h6db1343660ca93a2KlC
   2:     0x7f894f45a900 - <unknown>
   3:     0x7f894f3a5d80 - rt::unwind::begin_unwind_inner::h734e583390472682RBL
   4:     0x7f894c8fa4e0 - <unknown>
   5:     0x7f894c8fa470 - diagnostic::SpanHandler::span_bug::ha4389e9b9cd26b0cvYE
   6:     0x7f894c91c950 - parse::parser::Parser<'a>::parse_pat::hbaca44ef1986f811wLL
   7:     0x7f894c9314c0 - parse::parser::Parser<'a>::parse_arm::h03dad4fde878481bYzL
   8:     0x7f894c926950 - parse::parser::Parser<'a>::parse_bottom_expr::hd51982e53d14adeaKwK
   9:     0x7f894c92c9a0 - parse::parser::Parser<'a>::parse_dot_or_call_expr::h73cc376278c09c13LPK
  10:     0x7f894c92f7c0 - parse::parser::Parser<'a>::parse_prefix_expr::h9ada9bffadff12ebpcL
  11:     0x7f894c930020 - parse::parser::Parser<'a>::parse_binops::hd3006072d5866dc6shL
  12:     0x7f894c930600 - parse::parser::Parser<'a>::parse_assign_expr::hb68dbae6fdb97b62imL
  13:     0x7f894c932420 - <unknown>
  14:     0x7f894c932640 - parse::parser::Parser<'a>::parse_stmt::h3a7a8bca0f5459e8v4L
  15:     0x7f894c93bff0 - <unknown>
  16:     0x7f894c91add0 - <unknown>
  17:     0x7f894c940630 - <unknown>
  18:     0x7f894c9352c0 - <unknown>
  19:     0x7f894c946830 - <unknown>
  20:     0x7f894c951b90 - parse::parser::Parser<'a>::parse_crate_mod::h1592f06e4a607835FlO
  21:     0x7f894c963d90 - parse::parse_crate_from_file::h71bb673ba4ce988fvNV
  22:     0x7f894fa4f920 - <unknown>
  23:     0x7f894fa29c10 - driver::phase_1_parse_input::h5a91fba8b70d831dQra
  24:     0x7f894fa26610 - driver::compile_input::ha5d27daf21872ba2Gba
  25:     0x7f894faf4b50 - run_compiler::he50deb5aedf688fcZbc
  26:     0x7f894faf3480 - <unknown>
  27:     0x7f894faf2370 - <unknown>
  28:     0x7f894f4b7bc0 - <unknown>
  29:     0x7f894f4b7bb0 - rust_try
  30:     0x7f894faf2670 - <unknown>
  31:     0x7f894f448650 - <unknown>
  32:     0x7f894a0acf40 - <unknown>
  33:     0x7f894f02b7d9 - clone
  34:                0x0 - <unknown>

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