Skip to content

ICE on pattern match against const &`static [u8] #46920

Closed
@chridou

Description

@chridou

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

Metadata

Metadata

Assignees

Labels

P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions