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 nightly panics on refutable pattern #31561

Closed
dvgb opened this issue Feb 11, 2016 · 3 comments
Closed

rustc nightly panics on refutable pattern #31561

dvgb opened this issue Feb 11, 2016 · 3 comments
Labels
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dvgb
Copy link

dvgb commented Feb 11, 2016

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.

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 11, 2016
@huonw huonw added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Feb 11, 2016
@nikomatsakis nikomatsakis added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 3, 2016
@nikomatsakis
Copy link
Contributor

According to @arielb1 we used to block the use of refutable patterns in resolve, but it was changed, perhaps by @petrochenkov. @petrochenkov any thoughts?

@arielb1
Copy link
Contributor

arielb1 commented Mar 3, 2016

On further look, the error on old versions is an E0005 match error. Who's familiar with that?

@mitaa
Copy link
Contributor

mitaa commented Mar 4, 2016

It seems like this is somehow caused by the changes to is_useful in #31020.

arielb1 added a commit to arielb1/rust that referenced this issue Mar 4, 2016
bors added a commit that referenced this issue Mar 6, 2016
alexcrichton pushed a commit to alexcrichton/rust that referenced this issue Mar 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants