Skip to content

ICE: "enum pattern didn't resolve to enum or struct None" #33293

New issue

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

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

Already on GitHub? # to your account

Closed
mboecker opened this issue Apr 30, 2016 · 5 comments
Closed

ICE: "enum pattern didn't resolve to enum or struct None" #33293

mboecker opened this issue Apr 30, 2016 · 5 comments
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@mboecker
Copy link

mboecker commented Apr 30, 2016

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.

@jonas-schievink
Copy link
Contributor

Can you give a self-contained example that reproduces the bug? I can't reproduce this on playpen.

@mboecker
Copy link
Author

@nagisa nagisa added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-type-system Area: Type system labels Apr 30, 2016
@Aatch Aatch added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label May 3, 2016
@DanielShaulov
Copy link

dsprenkels added a commit to dsprenkels/rust that referenced this issue May 30, 2016
…h` returns `Err(true)`

In 1a374b8, (pr rust-lang#33046) fixed the error reporting of a specific
case, but the change that was introduced did not make sure that
`record_def` was called in all cases, which lead to an ICE in [1].
This change restores the original `else` case, but keeps the changes
that were committed in 1a374b8.

This commit fixes issue rust-lang#33293.

[1] `rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_`
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 1, 2016
…, r=petrochenkov

resolve: record pattern def when `resolve_pattern` returns `Err(true)`

I propose a fix for issue rust-lang#33293.

In 1a374b8, (pr rust-lang#33046) fixed the error reporting of a specific case, but the change that was introduced did not make sure that `record_def` was called in all cases, which lead to an ICE in [1].
This change restores the original `else` case, but keeps the changes that were committed in 1a374b8.

[1] `rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_`
@dsprenkels
Copy link
Contributor

This issue has been fixed by #33967, but no test was submitted.

@arielb1 arielb1 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 9, 2016
@jseyfried
Copy link
Contributor

cc me

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

No branches or pull requests

8 participants