Skip to content

ICE when using exhaustive_patterns without never_type #51221

Closed
@jleedev

Description

@jleedev
~$ cat a.rs 
#![feature(exhaustive_patterns)]
fn main() {
    enum Void {}
    let a: Option<Void> = None;
    let None = a;
}
~$ rustc +nightly a.rs
error: internal compiler error: librustc_mir/build/matches/mod.rs:225: match pairs [MatchPair { place: _1, pattern: Pattern { ty: std::option::Option<main::Void>, span: a.rs:5:9: 5:13, kind: Variant { adt_def: std::option::Option, substs: [main::Void], variant_index: 0, subpatterns: [] } }, slice_len_checked: false }] remaining after simplifying irrefutable pattern
 --> a.rs:5:9
  |
5 |     let None = a;
  |         ^^^^

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:499:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error


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.28.0-nightly (524ad9b9e 2018-05-29) running on x86_64-apple-darwin

👉	101

This compiles successfully with #![feature(exhaustive_patterns,never_type)]. It's possible that this regressed when the two features were separated. It's also possible that stabilizing never_type first will make this issue moot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions