Closed
Description
The below (invalid) code gives a panic in nightly rust. Stable and beta both happily reject it without panicking.
[:/tmp/tmp.O1NUYLh865] % cat c.rs
enum Thing {
Foo(u8),
Bar,
Baz,
}
fn main() {
let x = Thing::Foo(1);
let Thing::Foo(y) = x;
}
[:/tmp/tmp.O1NUYLh865] % multirust run nightly rustc c.rs
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:1060
note: Run with `RUST_BACKTRACE=1` for a backtrace.
[:/tmp/tmp.O1NUYLh865] 101 % RUST_BACKTRACE=1 multirust run nightly rustc c.rs
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:1060
stack backtrace:
1: 0x7f951e272800 - sys::backtrace::tracing::imp::write::h558d5f2978e55ac4ttu
2: 0x7f951e27a39b - panicking::default_handler::_$u7b$$u7b$closure$u7d$$u7d$::closure.43238
3: 0x7f951e279ef3 - panicking::default_handler::hbf3975cab47e4b81VWy
4: 0x7f951e243dac - sys_common::unwind::begin_unwind_inner::h78f1521fe1f5d27biit
5: 0x7f951e244848 - sys_common::unwind::begin_unwind_fmt::h964018da5137d3feoht
6: 0x7f951b58a488 - middle::check_match::check_irrefutable::h64cfa433b6a9a40ak8j
7: 0x7f951b55bec2 - middle::check_match::check_local::h8f4f38fe6a2d5f2bc6j
8: 0x7f951b55c117 - middle::check_match::check_fn::hcd366a08ad1d37a936j
9: 0x7f951b55c7b1 - middle::check_match::check_crate::hc1f332dc78a396f1JUi
10: 0x7f951e78af49 - driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::closure.27964
11: 0x7f951e78720e - middle::ty::context::ctxt<'tcx>::create_and_enter::h5439679730299442922
12: 0x7f951e783363 - driver::phase_3_run_analysis_passes::h12589397492560770879
13: 0x7f951e7560d8 - driver::compile_input::hb24a9d779e578b83Bca
14: 0x7f951e7463e8 - run_compiler::hf1f6ba491f28518acHc
15: 0x7f951e7438d1 - sys_common::unwind::try::try_fn::h10141810680521866859
16: 0x7f951e27028b - __rust_try
17: 0x7f951e2687cd - sys_common::unwind::inner_try::h876b2793e1ec4011kft
18: 0x7f951e744120 - boxed::F.FnBox<A>::call_box::h14464204619411869790
19: 0x7f951e278960 - sys::thread::Thread::new::thread_start::h36aef2efeb591414fUx
20: 0x7f9516a7b4a3 - start_thread
21: 0x7f951def913c - clone
22: 0x0 - <unknown>
[:/tmp/tmp.O1NUYLh865] 101 % multirust run beta rustc c.rsb
c.rs:9:9: 9:22 error: refutable pattern in local binding: `Bar` not covered [E0005]
c.rs:9 let Thing::Foo(y) = x;
^~~~~~~~~~~~~
c.rs:9:9: 9:22 help: run `rustc --explain E0005` to see a detailed explanation
error: aborting due to previous error
[:/tmp/tmp.O1NUYLh865] 101 % multirust run stable rustc c.rs
c.rs:9:9: 9:22 error: refutable pattern in local binding: `Bar` not covered [E0005]
c.rs:9 let Thing::Foo(y) = x;
^~~~~~~~~~~~~
c.rs:9:9: 9:22 help: run `rustc --explain E0005` to see a detailed explanation
error: aborting due to previous error
[:/tmp/tmp.O1NUYLh865] 101 % multirust run nightly rustc --version --verbose
multirust: checking metadata version
multirust: got metadata version 2
rustc 1.8.0-nightly (32b2ef7ad 2016-02-09)
binary: rustc
commit-hash: 32b2ef7add2836cba5867d2e5ac9610cef416447
commit-date: 2016-02-09
host: x86_64-unknown-linux-gnu
release: 1.8.0-nightly
[:/tmp/tmp.O1NUYLh865] % multirust run beta rustc --version --verbose
multirust: checking metadata version
multirust: got metadata version 2
rustc 1.7.0-beta.2 (f4b756e6c 2016-02-03)
binary: rustc
commit-hash: f4b756e6c6c204927c692449b11001e9db56199f
commit-date: 2016-02-03
host: x86_64-unknown-linux-gnu
release: 1.7.0-beta.2
[:/tmp/tmp.O1NUYLh865] % multirust run stable rustc --version --verbose
multirust: checking metadata version
multirust: got metadata version 2
rustc 1.6.0 (c30b771ad 2016-01-19)
binary: rustc
commit-hash: c30b771ad9d44ab84f8c88b80c25fcfde2433126
commit-date: 2016-01-19
host: x86_64-unknown-linux-gnu
release: 1.6.0
Seems to only happen when the enum has at least three arms. Changing number of arms the (left == right)
seems to have left equal to number of arms minus one.