Skip to content

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

@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

Activity

chridou

chridou commented on Dec 21, 2017

@chridou
Author

I have some additional information on this:

  • It worked on nightly a week or so ago
  • It also seems to crash the RLS since visual studio code tells me that RLS crashed 5 times and will not be restarted.
Deewiant

Deewiant commented on Dec 22, 2017

@Deewiant
Contributor

Bisecting points to 0c26d8f, introduced in #46582.

MageSlayer

MageSlayer commented on Jan 16, 2018

@MageSlayer

@alexcrichton
Please mark it as regression.

alexcrichton

alexcrichton commented on Jan 16, 2018

@alexcrichton
Member

cc @nikomatsakis and @rust-lang/compiler, I think this is a new beta regression!

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jan 16, 2018
nikomatsakis

nikomatsakis commented on Jan 16, 2018

@nikomatsakis
Contributor

Will investigate.

self-assigned this
on Jan 16, 2018
nikomatsakis

nikomatsakis commented on Jan 16, 2018

@nikomatsakis
Contributor

triage: P-high

added a commit that references this issue on Jan 16, 2018
06e32d0
added a commit that references this issue on Jan 19, 2018
5965b79

3 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Participants

      @alexcrichton@nikomatsakis@Deewiant@MageSlayer@chridou

      Issue actions

        ICE on pattern match against const &`static [u8] · Issue #46920 · rust-lang/rust