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

only string and byte strings supported in compare_values #26989

Closed
simonsimon006 opened this issue Jul 12, 2015 · 3 comments
Closed

only string and byte strings supported in compare_values #26989

simonsimon006 opened this issue Jul 12, 2015 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@simonsimon006
Copy link

When I try to compile my code, the compiler fails with "only string and byte strings supported in compare_values";.
My code:

struct Foo {
    x: Option<i32>,
    y: Option<i32>
}
fn main() {
    let mut test = Foo {x: Option::None, y: Option::Some(32)};
    match test {
        Foo {x: Some(12), y: a @ _} => println!("{:?}", a),
        Foo {y: Option::Some(ref mut a), x: Option::None} => {
            //println!("{:?}", a);
            *a=11000;
        },
        Foo {y: Option::Some(32), ..} => println!("all"),
        _ => println!("other")
    }
    println!("{:?}", test.y);
}

I am learning the language, so I don't know if this really is a bug.

Here the backtrace:

stack backtrace:
   1:     0x7f332c7e62d9 - sys::backtrace::write::h534114ba1b06b93294r
   2:     0x7f332c7ee1f9 - panicking::on_panic::h4e97afe0febd2c7biJw
   3:     0x7f332c7aeff2 - rt::unwind::begin_unwind_inner::hfe7dd1cef83ccc0fsow
   4:     0x7f3329b93a2d - rt::unwind::begin_unwind::h11509303451443813476
   5:     0x7f3329b940eb - diagnostic::Handler::bug::h238bf6cb3345eafa4aC
   6:     0x7f332a77917b - session::Session::bug::h3b46b49c0728a5bdior
   7:     0x7f332b6ac537 - trans::_match::compile_submatch_continue::h950de3ef5f507e64T0H
   8:     0x7f332b6a7c16 - trans::_match::compile_submatch::ha5fc5204dd2d2befZUH
   9:     0x7f332b6aba24 - trans::_match::compile_submatch_continue::h950de3ef5f507e64T0H
  10:     0x7f332b6a7c16 - trans::_match::compile_submatch::ha5fc5204dd2d2befZUH
  11:     0x7f332b6aba24 - trans::_match::compile_submatch_continue::h950de3ef5f507e64T0H
  12:     0x7f332b6a8175 - trans::_match::compile_submatch::ha5fc5204dd2d2befZUH
  13:     0x7f332b6a9f7b - trans::_match::compile_submatch_continue::h950de3ef5f507e64T0H
  14:     0x7f332b6a7c16 - trans::_match::compile_submatch::ha5fc5204dd2d2befZUH
  15:     0x7f332b6af82d - trans::_match::trans_match_inner::hec6393d4bbea11f96uI
  16:     0x7f332b672cf5 - trans::expr::trans_rvalue_dps_unadjusted::h8fcdb28f6f732a15FkB
  17:     0x7f332b648eac - trans::expr::trans_into::hada10aa0abe58f6fXaA
  18:     0x7f332b648a1a - trans::controlflow::trans_stmt_semi::hf87684594e9d274dD2u
  19:     0x7f332b5ccd8a - trans::controlflow::trans_block::h58628df23515fb60z3u
  20:     0x7f332b5cb9f1 - trans::base::trans_closure::h8e149909d93e9d35jHh
  21:     0x7f332b5cd6ca - trans::base::trans_fn::h6fdd3daa5a1290101Rh
  22:     0x7f332b5d0497 - trans::base::trans_item::hae1a16e69a6f2b67dgi
  23:     0x7f332b5de302 - trans::base::trans_crate::h60d17a2e7a10efe004i
  24:     0x7f332cd341e6 - driver::phase_4_translate_to_llvm::h2764cf85036c98d7nOa
  25:     0x7f332cd0ffe6 - driver::compile_input::hd8975b759aec0d60Qba
  26:     0x7f332cdc60e1 - run_compiler::h3b0c3beaef2163aa75b
  27:     0x7f332cdc3932 - boxed::F.FnBox<A>::call_box::h5202619178778601284
  28:     0x7f332cdc2ef9 - rt::unwind::try::try_fn::h4053862560305393821
  29:     0x7f332c85d3d8 - rust_try_inner
  30:     0x7f332c85d3c5 - rust_try
  31:     0x7f332cdc3194 - boxed::F.FnBox<A>::call_box::h4599430653034051152
  32:     0x7f332c7ecf91 - sys::thread::Thread::new::thread_start::h089e987aa4c0e52dzvv
  33:     0x7f332733e353 - start_thread
  34:     0x7f332c43ebfc - __clone
  35:                0x0 - <unknown>
@petrochenkov
Copy link
Contributor

Minimized:

fn main() {
    match (0, 0) {
        (0, ref _a) => {}
        (_, 0) => {}
        _ => {}
    }
}

@Aatch Aatch added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 13, 2015
@Aatch
Copy link
Contributor

Aatch commented Jul 13, 2015

Wierd, just swapping the first two arms causes it to start compiling again...

fn main() {
    match (0, 0) {
        (_, 0) => {}
        (0, ref _a) => {}
        _ => {}
    }
}

eefriedman added a commit to eefriedman/rust that referenced this issue Jul 15, 2015
The old code was not well structured, difficult to understand,
and buggy.

The new implementation is completely naive, so there may be a slight
runtime performance loss. That said, adding optimizations on top of
a clear and correct implementation seems easier than trying to
fix the old mess.

Fixes issue rust-lang#19064.
Fixes issue rust-lang#26989.
Fixes issue rust-lang#26251.
Fixes issue rust-lang#18060.
Fixes issue rust-lang#24875.
Fixes issue rust-lang#23311.
Fixes issue rust-lang#20046.
@steveklabnik
Copy link
Member

This ICE seems to be fixed on

rustc 1.12.0-nightly (b30eff7ba 2016-08-05)

I have a hunch that this is due to MIR being turned on, though I'm not sure. Please let me know if this still ICEs for you, but closing for now 🎊

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) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants