Change:
Results in cc
modify labels: I-ICE C-Bug T-compiler A-const-generics
I'm looking into this currently.
Partially as a note to myself and partially as an update to anyone interested The root cause of this bug seems to be the fact that we currently don't explicitly handle slice const values in , and therefore we always say they cannot match. This error eventually bubbles up to to produce all three errors.

Discussion:
InvalidProgramInfo, ResourceExhaustionInfo, UndefinedBehaviorInfo, }; <del> pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue}; </del> <ins> pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue, get_slice_bytes}; </ins> pub use self::allocation::{Allocation, AllocationExtra, Relocations, UndefMask};

Scalar(v), Undef }); <ins> /// Gets the bytes of a constant slice value. pub fn get_slice_bytes<'tcx>(cx: &impl HasDataLayout, val: ConstValue<'tcx>) -> &'tcx [u8] { if let ConstValue::Slice { data, start, end } = val { let len = end - start; data.get_bytes( cx, // invent a pointer, only the offset is relevant anyway Pointer::new(AllocId(0), Size::from_bytes(start as u64)), Size::from_bytes(len as u64), ).unwrap_or_else(|err| bug!("const slice is invalid: {:?}", err)) } else { bug!("expected const slice, but found another const value"); } } </ins>

use crate::ty::subst::{GenericArg, GenericArgKind, SubstsRef}; use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; use crate::ty::error::{ExpectedFound, TypeError}; <del> use crate::mir::interpret::{ConstValue, Scalar}; </del> <ins> use crate::mir::interpret::{ConstValue, get_slice_bytes, Scalar}; </ins> use std::rc::Rc; use std::iter; use rustc_target::spec::abi;

// FIXME(const_generics): we should either handle `Scalar::Ptr` or add a comment // saying that we're not handling it intentionally. <del> // FIXME(const_generics): handle `ConstValue::ByRef` and `ConstValue::Slice`. </del> <ins> (a_val @ ConstValue::Slice { .. }, b_val @ ConstValue::Slice { .. }) => { let a_bytes = get_slice_bytes(&tcx, a_val); let b_bytes = get_slice_bytes(&tcx, b_val); if a_bytes == b_bytes { Ok(tcx.mk_const(ty::Const { val: a_val, ty: a.ty, })) } else { Err(TypeError::ConstMismatch(expected_found(relation, &a, &b))) } } // FIXME(const_generics): handle `ConstValue::ByRef`. </ins> // FIXME(const_generics): this is wrong, as it is a projection (ConstValue::Unevaluated(a_def_id, a_substs),

use rustc::lint; use rustc::mir::{Field, BorrowKind, Mutability}; use rustc::mir::{UserTypeProjection}; <del> use rustc::mir::interpret::{GlobalId, ConstValue, sign_extend, AllocId, Pointer}; </del> <ins> use rustc::mir::interpret::{GlobalId, ConstValue, get_slice_bytes, sign_extend}; </ins> use rustc::traits::{ObligationCause, PredicateObligation}; use rustc::ty::{self, Region, TyCtxt, AdtDef, Ty, UserType, DefIdTree}; use rustc::ty::{CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations}; use rustc::ty::subst::{SubstsRef, GenericArg}; <del> use rustc::ty::layout::{VariantIdx, Size}; </del> <ins> use rustc::ty::layout::VariantIdx; </ins> use rustc::hir::{self, RangeEnd}; use rustc::hir::def::{CtorOf, Res, DefKind, CtorKind}; use rustc::hir::pat_util::EnumerateAndAdjustIterator;

if let ty::Str = ty.kind { match (a.val, b.val) { <del> ( ConstValue::Slice { data: alloc_a, start: offset_a, end: end_a }, ConstValue::Slice { data: alloc_b, start: offset_b, end: end_b }, ) => { let len_a = end_a - offset_a; let len_b = end_b - offset_b; let a = alloc_a.get_bytes( &tcx, // invent a pointer, only the offset is relevant anyway Pointer::new(AllocId(0), Size::from_bytes(offset_a as u64)), Size::from_bytes(len_a as u64), ); let b = alloc_b.get_bytes( &tcx, // invent a pointer, only the offset is relevant anyway Pointer::new(AllocId(0), Size::from_bytes(offset_b as u64)), Size::from_bytes(len_b as u64), ); if let (Ok(a), Ok(b)) = (a, b) { return from_bool(a == b); } </del> <ins> (ConstValue::Slice { .. }, ConstValue::Slice { .. }) => { let a_bytes = get_slice_bytes(&tcx, a.val); let b_bytes = get_slice_bytes(&tcx, b.val); return from_bool(a_bytes == b_bytes); </ins> } _ => (), }

<ins> #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash struct ConstString<const T: &'static str>; struct ConstBytes<const T: &'static [u8]>; pub fn main() { let _: ConstString<"Hello"> = ConstString::<"Hello">; let _: ConstString<"Hello"> = ConstString::<"World">; //~ ERROR mismatched types let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↦">; let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; //~ ERROR mismatched types let _: ConstBytes<b"AAA"> = ConstBytes::<{&[0x41, 0x41, 0x41]}>; let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">; //~ ERROR mismatched types } </ins>

<ins> warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> $DIR/slice-const-param-mismatch.rs:1:12 | LL | #![feature(const_generics)] |            ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types --> $DIR/slice-const-param-mismatch.rs:9:35 | LL |     let _: ConstString<"Hello"> = ConstString::<"World">; |                                   ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"` | = note: expected type `ConstString<>` found type `ConstString<>` error[E0308]: mismatched types --> $DIR/slice-const-param-mismatch.rs:11:33 | LL |     let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; |                                  ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"` | = note: expected type `ConstString<>` found type `ConstString<>` error[E0308]: mismatched types --> $DIR/slice-const-param-mismatch.rs:13:33 | LL |     let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">; |                                 ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"` | = note: expected type `ConstBytes<>` found type `ConstBytes<>` error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. </ins>

<ins> // run-pass #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash pub fn function_with_str<const STRING: &'static str>() -> &'static str { STRING } pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] { BYTES } pub fn main() { assert_eq!(function_with_str::<"Rust">(), "Rust"); assert_eq!(function_with_str::<"ℇ㇈↦">(), "ℇ㇈↦"); assert_eq!(function_with_bytes::<b"AAAA">(), &[0x41, 0x41, 0x41, 0x41]); assert_eq!(function_with_bytes::<{&[0x41, 0x41, 0x41, 0x41]}>(), b"AAAA"); } </ins>

<ins> warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> $DIR/slice-const-param.rs:3:12 | LL | #![feature(const_generics)] |            ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default </ins>