Skip to content

assertion failure in trans_alt when combining if, nested patterns #3121

Closed
@nikomatsakis

Description

@nikomatsakis

The following test:

enum side { mayo, catsup, vinegar }
enum order { hamburger, fries(side), shake }
enum meal { to_go(order), for_here(order) }

fn foo(m: @meal, cond: bool) {
    match *m {
      to_go(_) => { }
      for_here(_) if cond => {}
      for_here(hamburger) => {}
      for_here(fries(s)) => {}
      for_here(shake) => {}
    }
}

fn main() {
    foo(@for_here(hamburger), true)
}

results in an assertion failure in trans:

;RUST_LOG=rustc=0 rustc ~/tmp/pat-bug-in-trans.rs 
rust: task failed at 'Assertion m.len() > 0u || is_some(chk) failed', /Users/nmatsakis/versioned/rust-gold/src/rustc/middle/trans/alt.rs:431
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /Users/nmatsakis/versioned/rust-gold/src/rustc/driver/rustc.rs:264
rust: domain main @0x7f8d99800010 root task failed
rust: task failed at 'killed', /Users/nmatsakis/versioned/rust-gold/src/libcore/task.rs:520

The problem has to do with the if, something in the logic there gets a bit confused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-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