Skip to content

Broken MIR with const match #27918

Closed
@diaphore

Description

@diaphore

empty_and_catchall

fn empty_and_catchall(raw: &[u8]) {
    let mut iter = raw.split(|&b| b == b'/');
    let first = iter.next().unwrap();
    let second = iter.next();

    const EMPTY: &'static [u8] = b"";

    match (first, second) {
        (EMPTY, Some(EMPTY))  => (),
        _ => (),
    }
}

fn main() { empty_and_catchall(b"foo") }
Assertion failed!

Program: C:\Program Files\Rust nightly 1.4\bin\rustc.exe
File: C:/bot/slave/nightly-dist-rustc-win-gnu-64/build/src/llvm/include/llvm/Support/Casting.h, Line 237

Expression: isa<X>(Val) && "cast<Ty>() argument of incompatible type!"

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

empty

fn empty(raw: &[u8]) {
    let mut iter = raw.split(|&b| b == b'/');
    let first = iter.next().unwrap();
    let second = iter.next();

    const EMPTY: &'static [u8] = b"";

    match (first, second) {
        (EMPTY, Some(EMPTY))  => (),
    }
}

fn main() { empty(b"foo") }
thread 'rustc' panicked at 'assertion failed: `(left == right)` (left: `1`, right: `0`)', ../src/librustc\middle\check_match.rs:536

stack backtrace:
   1:         0x699bb42e - sys::backtrace::write::hb12aa40f2f209619ols
   2:         0x699c5115 - rt::unwind::register::h92f30f49d41046e7Qww
   3:         0x6998564f - rt::unwind::begin_unwind_inner::hbffbb4981b0d700aZtw
   4:         0x69985fdc - rt::unwind::begin_unwind_fmt::h393d9d0c019d9fa55sw
   5:         0x6925756e - middle::const_eval::const_expr_to_pat::h09de9c640f8e12dfYuj
   6:         0x692379ac - session::Session::span_note::he19d21226dfbf5ecNYv
   7:         0x6925c905 - middle::ty::TyS<'tcx>::builtin_deref::h8d5bf22a376109d3kcb
   8:         0x6925bbd4 - middle::ty::TyS<'tcx>::builtin_deref::h8d5bf22a376109d3kcb
   9:         0x6925b903 - middle::ty::TyS<'tcx>::builtin_deref::h8d5bf22a376109d3kcb
  10:         0x69237815 - session::Session::span_note::he19d21226dfbf5ecNYv
  11:         0x69230f81 - middle::check_match::MatchCheckCtxt<'a, 'tcx>.Visitor<'v>::visit_expr::h08c39dd719c14c968uh
  12:         0x692327bb - middle::check_match::MatchCheckCtxt<'a, 'tcx>.Visitor<'v>::visit_fn::ha264f9b30c751779Cvh
  13:         0x69232d11 - middle::check_match::check_crate::hf7369bd73cb3b474kwh
  14:         0x6923292b - middle::check_match::check_crate::hf7369bd73cb3b474kwh
  15:         0x67c0a4a3 - driver::assign_node_ids_and_map::habd9138624442090aEa
  16:         0x67be68c9 - driver::assign_node_ids_and_map::habd9138624442090aEa
  17:         0x67be1bb1 - driver::assign_node_ids_and_map::habd9138624442090aEa
  18:         0x67bc278c - driver::compile_input::hec03b27c99a60d9dTba
  19:         0x67d39bd8 - run_compiler::he293276e81cb97efObc
  20:         0x67d374f0 - run::hd965d7dec4214920ubc
  21:         0x67d36f69 - run::hd965d7dec4214920ubc
  22:         0x699ae9b4 - rt::unwind::try::inner_try::hfa861391a664fbdeSpw
  23:         0x67d37104 - run::hd965d7dec4214920ubc
  24:         0x699c2dee - rt::util::report_overflow::h4a1688dd50f7ee7eyaw
  25:     0x7ffdaf8413d2 - BaseThreadInitThunk

neither

Fails to compile but rustc catches the non exhaustive pattern successfully.

fn neither(raw: &[u8]) {
    let mut iter = raw.split(|&b| b == b'/');
    let first = iter.next().unwrap();
    let second = iter.next();

    match (first, second) {
        (b"", Some(b""))  => (),    
    }
}

fn main() { neither(b"foo") }

I have no idea how to include more info from LLVM.

$ rustc --version -v
rustc 1.4.0-nightly (e35fd7481 2015-08-17)
binary: rustc
commit-hash: e35fd748114c22df6d08991980c4f7e199414497
commit-date: 2015-08-17
host: x86_64-pc-windows-gnu
release: 1.4.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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