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

Match bytes and &str #26510

Closed
ctjhoa opened this issue Jun 22, 2015 · 2 comments
Closed

Match bytes and &str #26510

ctjhoa opened this issue Jun 22, 2015 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ctjhoa
Copy link
Contributor

ctjhoa commented Jun 22, 2015

I tried this code:

#![feature(slice_patterns)]

fn main() {
    let buf = [0u8; 4];
    match &buf {
        &[0, 1, 0, 0] => (),
        b"true" => (),
        _ => ()
    }   

}

I expected to see this happen:
I'm relatively new to rust, I tried to match a &str and &[u8] which seems to be the same type according to the doc :
http://doc.rust-lang.org/std/primitive.str.html#method.as_bytes

Instead, this happened:
The compiler panicked. I have maybe done something wrong but the compiler should not panicked for that.

Meta

rustc --version --verbose:

rustc 1.2.0-nightly (2f5683913 2015-06-18)
binary: rustc
commit-hash: 2f5683913c9815d9f12494784747f79b0f3b3066
commit-date: 2015-06-18
host: x86_64-unknown-linux-gnu
release: 1.2.0-nightly

Backtrace:

stack backtrace:
   1:     0x7fefaea8f3d3 - sys::backtrace::write::hac6f7844a2c08518pqs
   2:     0x7fefaea97551 - panicking::on_panic::he3a077dab5880a1969w
   3:     0x7fefaea5628a - rt::unwind::begin_unwind_inner::h07f84ceedf6e11d3KPw
   4:     0x7fefac86127e - rt::unwind::begin_unwind::h10696837115463997933
   5:     0x7fefac9d6525 - middle::check_match::is_useful::h9a04b6e449073316V6h
   6:     0x7fefac9feb34 - middle::check_match::is_useful_specialized::h6788c2bb0c1a90c7Yfi
   7:     0x7fefac9ffd01 - middle::check_match::is_useful::closure.84515
   8:     0x7fefac9ffa36 - option::Option<T>::map::h16552866249183522699
   9:     0x7fefac9d69ff - middle::check_match::is_useful::h9a04b6e449073316V6h
  10:     0x7fefac9cde61 - middle::check_match::check_expr::h992a26755f1102e2jsh
  11:     0x7fefac9cfe7a - middle::check_match::check_fn::h9f9b0f213eee3b189Fi
  12:     0x7fefac9d06e0 - visit::walk_item::h1113646532361864268
  13:     0x7fefac9d056a - middle::check_match::check_crate::hd23a048468bf7963Wrh
  14:     0x7fefaeff943e - driver::phase_3_run_analysis_passes::h0789c185cb5142aeIGa
  15:     0x7fefaefd94fa - driver::compile_input::h673b093cab67a345Tba
  16:     0x7fefaf094f37 - run_compiler::hd964f53796cdaa72G7b
  17:     0x7fefaf092526 - boxed::F.FnBox<A>::call_box::h4406333435808980122
  18:     0x7fefaf091d29 - rt::unwind::try::try_fn::h10492881588876420525
  19:     0x7fefaeb13ed8 - rust_try_inner
  20:     0x7fefaeb13ec5 - rust_try
  21:     0x7fefaea82147 - rt::unwind::try::inner_try::h18f1f3c9b9ec8956DLw
  22:     0x7fefaf091f49 - boxed::F.FnBox<A>::call_box::h8032357446467525174
  23:     0x7fefaea96181 - sys::thread::Thread::new::thread_start::h6ee35face9d3fb15AVv
  24:     0x7fefa881f353 - start_thread
  25:     0x7fefae6eabfc - __clone
  26:                0x0 - <unknown>

Thanks

@arielb1
Copy link
Contributor

arielb1 commented Jun 22, 2015

slice patterns are buggy.

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 23, 2015
@Mark-Simulacrum
Copy link
Member

Duplicate/related to #18027.

@bors bors closed this as completed in 8d3e89b Oct 27, 2016
steveklabnik added a commit to rust-lang/glacier that referenced this issue Nov 3, 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) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants