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

rustc panicked when I use 'let binding' to 'destructure' an enum #32578

Closed
yykkxk opened this issue Mar 29, 2016 · 2 comments
Closed

rustc panicked when I use 'let binding' to 'destructure' an enum #32578

yykkxk opened this issue Mar 29, 2016 · 2 comments

Comments

@yykkxk
Copy link

yykkxk commented Mar 29, 2016

I know it is an error to 'destructure an enum with let binding'. But it should be a compile error, not a compiler panic. I find it occurs when an enum has three kinds of structs.(normal struct, unit struct, tuple struct)

I tried this code.

enum Language {
    Chinese(i32),
    Janpanese,
    Other {
          a: i32,
          b: i32,
    }
}

fn main() {
    let c = Language::Chinese(32);
    let Language::Chinese(i) = c;
}

I got this:

Compiling rust-study v0.1.0 (file:///home/ding/project-fedora/rust-study)
error: internal compiler error: unexpected panic
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 'assertion failed: (left == right) (left: 2, right: 1)', ../src/librustc/middle/check_match.rs:1051
note: Run with RUST_BACKTRACE=1 for a backtrace.

Meta

rustc 1.9.0-nightly (7b0b80a 2016-03-02)
binary: rustc
commit-hash: 7b0b80a
commit-date: 2016-03-02
host: x86_64-unknown-linux-gnu
release: 1.9.0-nightly

Backtrace:

[...........]$ RUST_BACKTRACE=1 cargo build -v
Compiling ..........
Running rustc book_learn/enum.rs --crate-name gcc --crate-type bin -g --out-dir /home/ding/project-fedora/rust-study/target/debug --emit=dep-info,link -L dependency=/home/ding/project-fedora/rust-study/target/debug -L dependency=/home/ding/project-fedora/rust-study/target/debug/deps
error: internal compiler error: unexpected panic
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
thread 'rustc' panicked at 'assertion failed: (left == right) (left: 2, right: 1)', ../src/librustc/middle/check_match.rs:1051
stack backtrace:
1: 0x7f279cde7420 - sys::backtrace::tracing::imp::write::hafd161163f579c22qhv
2: 0x7f279cdf07cb - panicking::default_handler::$u7b$$u7b$closure$u7d$$u7d$::closure.44622
3: 0x7f279cdf0323 - panicking::default_handler::hf2d947b7574856d7OWz
4: 0x7f279cdb4a9c - sys_common::unwind::begin_unwind_inner::hc47573e10f703d4dJ5t
5: 0x7f279cdb5538 - sys_common::unwind::begin_unwind_fmt::h46e3049686ee3eb0P4t
6: 0x7f279a0a0a68 - middle::check_match::check_irrefutable::hf4f3190a79f4e43992j
7: 0x7f279a071a12 - middle::check_match::check_local::h98b3e55827a94f0230j
8: 0x7f279a071c67 - middle::check_match::check_fn::h611a29c4ed420569T1j
9: 0x7f279a0723d1 - middle::check_match::check_crate::h958664ff10508e28DQi
10: 0x7f279d3181ce - driver::phase_3_run_analysis_passes::
$u7b$$u7b$closure$u7d$$u7d$::closure.28569
11: 0x7f279d3150b4 - middle::ty::context::ctxt<'tcx>::create_and_enter::h9120522648527365715
12: 0x7f279d311b9f - driver::phase_3_run_analysis_passes::h6774489415173405543
13: 0x7f279d2e4ed5 - driver::compile_input::hff497ea9e892ddf1Hca
14: 0x7f279d2d2a57 - run_compiler::hd54b7109a035c12b6Oc
15: 0x7f279d2d01d1 - sys_common::unwind::try::try_fn::h12672314472111852986
16: 0x7f279cde4e0b - __rust_try
17: 0x7f279cddd2ed - sys_common::unwind::inner_try::h4ba21e6d9bc82236L2t
18: 0x7f279d2d0a20 - boxed::F.FnBox::call_box::h3704598993629746835
19: 0x7f279cdeed99 - sys::thread::Thread::new::thread_start::hf030860cf63100a98Ty
20: 0x7f2795556609 - start_thread
21: 0x7f279ca60a4c - clone
22: 0x0 -

Could not compile rust-study.

Caused by:
Process didn't exit successfully: rustc book_learn/enum.rs --crate-name gcc --crate-type bin -g --out-dir /home/ding/project-fedora/rust-study/target/debug --emit=dep-info,link -L dependency=/home/ding/project-fedora/rust-study/target/debug -L dependency=/home/ding/project-fedora/rust-study/target/debug/deps (exit code: 101)

@mitaa
Copy link
Contributor

mitaa commented Mar 29, 2016

Could you try a newer nightly build? This should be fixed (#31561)

@yykkxk
Copy link
Author

yykkxk commented Mar 30, 2016

You are right. It has been fixed in the lastest nightly build. Thank you.

@yykkxk yykkxk closed this as completed Mar 30, 2016
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

No branches or pull requests

2 participants