Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE in match expression #14865

Closed
nrc opened this issue Jun 13, 2014 · 3 comments
Closed

ICE in match expression #14865

nrc opened this issue Jun 13, 2014 · 3 comments

Comments

@nrc
Copy link
Member

nrc commented Jun 13, 2014

The following match expression ICEs with

Basic Block in function '_ZN6middle6typeck9coherence13get_base_type20h0f2d8662897539e9xUv11v0.11.0.preE' does not have terminator!
label %match_case10
LLVM ERROR: Broken function found, compilation aborted!
make: *** [x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/stamp.rustc] Error 1

I'm afraid I haven't been able to identify exactly what causes the error, but replacing the _ with ty_uniq(_) | ty_rptr(_, _) | ty_trait(..) fixes the problem, so the error is there somewhere. The offending match is in coherance.rs.

match get(resolved_type).sty {
        ty_enum(..) | ty_struct(..) => {
            debug!("(getting base type) found base type");
            Some(resolved_type)
        }
        _ if ty::type_is_trait(resolved_type) => {
            debug!("(getting base type) found base type (trait)");
            Some(resolved_type)
        }

        ty_nil | ty_bot | ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
        ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) |
        ty_infer(..) | ty_param(..) | ty_self(..) | ty_err |
        ty_box(_) | ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => {
            debug!("(getting base type) no base type; found {:?}",
                   get(original_type).sty);
            None
        }
        ty_trait(..) => fail!("should have been caught")
    }
@ghost
Copy link

ghost commented Jun 14, 2014

Minimal test case:

enum X {
    Foo(uint),
    Bar(bool)
}

fn main() {
    match Foo(42) {
        Foo(..) => (),
        _ if true => (),
        Bar(..) => fail!("Oh dear")
    }
}

@nikomatsakis
Copy link
Contributor

cc @edwardw, sounds related to the trans match code that you were looking at recently

@edwardw
Copy link
Contributor

edwardw commented Jun 17, 2014

Indeed. And it seems to be very subtle. The following compiles:

enum X {
    Foo(uint),
    Bar(bool)
}

fn main() {
    match Foo(42) {
        _ if true => (),
        Foo(..) => (),
        Bar(..) => fail!("Oh dear")
    }
}

Although logically two piece of code are different, they should be of little difference as far as codegen is concerned. Yet, one compiles and the other doesn't. I'm investigating it.

@edwardw edwardw mentioned this issue Jun 18, 2014
edwardw added a commit to edwardw/rust that referenced this issue Jun 18, 2014
Fixes a codegen bug which generates illegal non-terminated LLVM block
when there are wildcard pattern with guard and enum patterns in a match
expression. Also refactors the code a little.

Closes rust-lang#14865
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jun 19, 2014
Closes rust-lang#14480 (vim: Add :RustRun and associated commands)
Closes rust-lang#14917 (Deprecate free-standing endian conversions in favor of methods on Int. Merge Bitwise into Int and add more bit operations.)
Closes rust-lang#14981 (librustc: Use expr_ty_adjusted in trans_overloaded_call.)
Closes rust-lang#14989 (std::task - Revamp TaskBuilder API)
Closes rust-lang#14997 (Reject double moves out of array elements)
Closes rust-lang#14998 (Vim: highlight escapes for byte literals.)
Closes rust-lang#15002 (Fix FIXME rust-lang#5275)
Closes rust-lang#15004 (Fix rust-lang#14865)
Closes rust-lang#15007 (debuginfo: Add test case for issue rust-lang#14411.)
Closes rust-lang#15012 ((doc) Change search placeholder text.)
Closes rust-lang#15013 (Update compiler-rt.)
Closes rust-lang#15017 (Deprecate the bytes!() macro.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants