Skip to content

Internal compiler error when mixing enum type with struct of the same name #6618

Closed
@hatahet

Description

@hatahet

I was testing out some code I found on the mailing list, and appended some of my own:

enum Foobar {
  Foo(~str),
  Bar(~str)
}

fn f<'a>(fb: &'a Foobar) -> &'a str {
  let rs = match *fb {
    Foo(ref rs) => rs,
    Bar(ref rs) => rs
  };
  let s: &'a str = *rs;
  s
}

struct Foo(int);

fn main() {
}

Compiling the above program (after adding struct Foo(int);) results in a compiler error. Setting the RUST_LOG flag to rustc=1,::rt::backtrace produces the following log dump:

rust: task failed at 'non-variant in variant_def_ids', /home/zhatahet/code/rust-0.6/src/libsyntax/ast_util.rs:55
/home/zhatahet/rust/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4f)[0x7f6edda7701f]
/home/zhatahet/rust/bin/../lib/librustrt.so(+0x2d921)[0x7f6edda88921]
/home/zhatahet/rust/bin/../lib/librustrt.so(upcall_fail+0x1ce)[0x7f6edda79a3e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10aa2b)[0x7f6edf5c3a2b]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10a9d2)[0x7f6edf5c39d2]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN3sys12begin_unwind17_61fe198059b9e3fc3_06E+0x71)[0x7f6edf50b4a1]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(_ZN8ast_util15variant_def_ids17_adb77598a27029ff3_06E+0x136)[0x7f6edeaa2926]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match17check_pat_variant17_4fbfcbee3eb1c2da3_06E+0x21b)[0x7f6ede0fe54b]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match9check_pat17_548e5ffb944ea5373_06E+0x3557)[0x7f6ede0f6457]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x438ee7)[0x7f6ede0f2ee7]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check6_match11check_match17_536eb3b0eafde7b13_06E+0x22f)[0x7f6ede0ee94f]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check23check_expr_with_unifier17_841417e8b97d6e713_06E+0x3ef1)[0x7f6ede1a8151]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check28check_expr_coercable_to_type17_5acee3342c4cd5a23_06E+0x91)[0x7f6ede1bbfc1]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check22check_decl_initializer17_1547d91555c977933_06E+0xb2)[0x7f6ede1cf042]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check16check_decl_local16_ac37e3abcfdd7ff3_06E+0x5ea)[0x7f6ede1cf72a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x5175ba)[0x7f6ede1d15ba]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check10check_stmt17_e63c562496e2808c3_06E+0x26e)[0x7f6ede1d102e]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x517791)[0x7f6ede1d1791]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check25check_block_with_expected17_b352eb1d2e7639c03_06E+0x21e)[0x7f6ede16caae]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check8check_fn17_20cad4a150c275a73_06E+0x1089)[0x7f6ede16b2f9]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check13check_bare_fn14_4fc3abe889a533_06E+0x17e)[0x7f6ede169fae]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check10check_item16_f8c9b58265752963_06E+0x43d)[0x7f6ede168ded]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x4ae801)[0x7f6ede168801]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(+0xe5154)[0x7f6edeaec154]
/home/zhatahet/rust/bin/../lib/libsyntax-84efebcb12c867a2-0.6.so(+0xe4cfa)[0x7f6edeaebcfa]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck5check16check_item_types17_b41350aeb9ad50f23_06E+0x430)[0x7f6ede1685d0]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x5e52a5)[0x7f6ede29f2a5]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle6typeck11check_crate17_63c941d6da5d83433_06E+0x2d0)[0x7f6ede29dec0]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_rest17_b2b258b84b35f3533_06E+0x1218)[0x7f6ede5380d8]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_upto17_12335154b455986e3_06E+0x108)[0x7f6ede53d3e8]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver13compile_input15_bb29edf7a232863_06E+0xca)[0x7f6ede53d82a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN12run_compiler17_64d52739a36d169c3_06E+0x20aa)[0x7f6ede56cf7a]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8bf5b1)[0x7f6ede5795b1]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8bbddc)[0x7f6ede575ddc]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0xd340e)[0x7f6edf58c40e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x153294)[0x7f6edf60c294]
/home/zhatahet/rust/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f6edda782b4]
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=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /home/zhatahet/code/rust-0.6/src/librustc/rustc.rc:357
/home/zhatahet/rust/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4f)[0x7f6edda7701f]
/home/zhatahet/rust/bin/../lib/librustrt.so(+0x2d921)[0x7f6edda88921]
/home/zhatahet/rust/bin/../lib/librustrt.so(upcall_fail+0x1ce)[0x7f6edda79a3e]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10aa2b)[0x7f6edf5c3a2b]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x10a9d2)[0x7f6edf5c39d2]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN3sys12begin_unwind17_61fe198059b9e3fc3_06E+0x71)[0x7f6edf50b4a1]
/home/zhatahet/rust/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x153294)[0x7f6edf60c294]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN7monitor17_78935df9ff9e1afa3_06E+0x1577)[0x7f6ede56f5a7]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8c1ae4)[0x7f6ede57bae4]
/home/zhatahet/rust/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN4main15_c4de63b748e03d3_06E+0x7e)[0x7f6ede57b6fe]
/home/zhatahet/rust/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f6edda782b4]
rust: domain main @0x177b3c0 root task failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions