Skip to content

Constants, slice patterns, and exhaustiveness interact in suboptimal ways #65413

Closed
@arielb1

Description

@arielb1

For example,

#![feature(slice_patterns)]

const C0: &'static [u8] = b"\x00";

fn main() {
   let x: &[u8] = &[0];
   match x { // this code compiles
       &[] => {},
       &[1..=255] => {},
       C0 => {}, //~ unreachable pattern (no it's not)
       &[_, _, ..] => {}
   }
}

cc @oli-obk

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-slice-patternsArea: Slice patterns, https://github.com/rust-lang/rust/issues/23121C-bugCategory: This is a bug.F-slice_patterns`#![feature(slice_patterns)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions