Closed
Description
I matched against a &'static [u8]
and got the error below. The code compiles on stable and beta. Interestingly I do these kinds of pattern matches elsewhere in the code, too, and there it works.
I found errors with similiar error messages but could not relate them to this code. So sorry if this is a duplicate.
I tried this code:
Can be reproduced on rust playground:
const CURSOR_PARTITION_LABEL: &'static [u8] = b"partition";
const CURSOR_EVENT_TYPE_LABEL: &'static [u8] = b"event_type";
fn main() {
let sample = b"abce";
match &sample[..] {
CURSOR_PARTITION_LABEL => println!("a"),
CURSOR_EVENT_TYPE_LABEL => println!("b"),
_ => (),
}
}
I expected to see this happen:
A successful build.
Instead, this happened:
error: internal compiler error: broken MIR in NodeId(2445) (""): errors selecting obligation: [FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<[u8] as std::marker::Unsize<[u8]>>)),depth=1),Unimplemented)]
Meta
rustc --version --verbose
:
rustc 1.24.0-nightly (7eb64b86c 2017-12-20)
binary: rustc
commit-hash: 7eb64b86ce44cc1828dd176a8b981e37ea08fc38
commit-date: 2017-12-20
host: x86_64-unknown-linux-gnu
release: 1.24.0-nightly
LLVM version: 4.0