Closed
Description
Hi everyone,
This code caused a ICE for me.
enum EnumA {
JustA(i32),
Same(i32)
}
/*enum EnumB {
JustB(i32),
Same(i32)
}*/
fn test() -> EnumA {
EnumA::JustA(2)
}
fn main() {
loop {
let p = match test() {
EnumA (r) => r,
EnumB::Same(x) => x
};
}
}
The compiler said this.
src/main.rs:58:6: 58:45 error: internal compiler error: ../src/librustc/middle/mem_categorization.rs:1265: enum pattern didn't resolve to enum or struct None
src/main.rs:58 EnumA (r) => r, => {
^~~~~~~~~~~~~~~~~~~~~~~~
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:537
stack backtrace:
1: 0x7f8277138610 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
2: 0x7f8277145d5b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
3: 0x7f82771458fc - std::panicking::default_hook::hc2c969e7453d080c
4: 0x7f827710b28f - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e25
5: 0x7f82746c7478 - std::sys_common::unwind::begin_unwind::h24c4c0fa2cfe995a
6: 0x7f82746c741b - syntax::errors::Handler::span_bug::h1878d6587b8bfd95
7: 0x7f82746c8b22 - rustc::session::opt_span_bug_fmt::_$u7b$$u7b$closure$u7d$$u7d$::hf0fb5697f8f25f40
8: 0x7f82746c8a12 - rustc::session::span_bug_fmt::h4591bcbadfc38558
9: 0x7f827475cc43 - rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_::hff665d681985439e
10: 0x7f827475b434 - rustc_typeck::check::regionck::link_pattern::h882c0c8cd92b31b1
11: 0x7f8274758049 - rustc_typeck::check::regionck::visit_expr::h30460da2fc8589c6
12: 0x7f8274758f7a - rustc_typeck::check::regionck::visit_local::hb6a6ae3ac5eae28f
13: 0x7f827475a285 - rustc::hir::intravisit::walk_expr::hf0b626b32adf4c13
14: 0x7f8274757f49 - rustc_typeck::check::regionck::visit_expr::h30460da2fc8589c6
15: 0x7f8274755956 - rustc_typeck::check::regionck::Rcx::visit_fn_body::ha2fc797207b15bdd
16: 0x7f82746e5d78 - rustc_typeck::check::regionck::regionck_fn::hefb39d001a6577cc
17: 0x7f82746e0877 - rustc_typeck::check::check_bare_fn::h7e4c2ad58d1814dd
18: 0x7f82746ef99f - rustc_typeck::check::check_method_body::h7863cacbf117e455
19: 0x7f82746daf5e - rustc_typeck::check::check_item_body::h7ffec660fc242796
20: 0x7f82746d2be1 - rustc_typeck::check::check_item_bodies::ha729008a2e67410e
21: 0x7f82746ca21f - rustc_typeck::check_crate::hb08ba31a6a5f65b5
22: 0x7f8277693f00 - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::h06c776ef4d1c70b6
23: 0x7f8277691f5e - rustc::ty::context::TyCtxt::create_and_enter::hb0e0e916c7274a64
24: 0x7f827766490d - rustc_driver::driver::compile_input::h0629572e6f316b31
25: 0x7f827764553c - rustc_driver::run_compiler::h8902aebf8b1849a8
26: 0x7f8277642c41 - std::sys_common::unwind::try::try_fn::h4c74456035d0fcc7
27: 0x7f8277135deb - __rust_try
28: 0x7f8277135d7d - std::sys_common::unwind::inner_try::h47a4d9cd4a369dcd
29: 0x7f827764348a - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
30: 0x7f8277143ef4 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
31: 0x7f826eecb423 - start_thread
32: 0x7f8276da2cbc - clone
33: 0x0 - <unknown>
The bug doesn't appear in rust stable or beta, only in nightly.
rustc 1.10.0-nightly (8da2bcac5 2016-04-28)
binary: rustc
commit-hash: 8da2bcac5db1e091b90cceb19d0496f0f7501c88
commit-date: 2016-04-28
host: x86_64-unknown-linux-gnu
release: 1.10.0-nightly
edit: used minimal example instead of my code.