Closed
Description
This produces an ICE (playground link):
fn main() {
const CONST: &[(); 1] = &[()];
match &[()] {
&[()] => {}
CONST => {}
}
}
It points to this assert firing:
rust/src/librustc_mir/hair/pattern/_match.rs
Lines 1739 to 1745 in d801458
This assert assumes that if we match on a
&[T; n]
with a const, then T
must be u8
. I'm not sure where this assumption comes from (I'd guess byte-array patterns), but it's clearly wrong. Note that this also fails with any other non-u8
type here instead of ()
.Note that this does not fail when the arrays are not behind references, or if we use slices instead of arrays.
EDIT: removed unnecessary slice_patterns
feature gate
Metadata
Metadata
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Slice patterns, https://github.com/rust-lang/rust/issues/23121Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️High priorityRelevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.