- let data: &[u8] = match *ctor {
- ConstantValue(const_val) => {
- match (const_val.val, &const_val.ty.sty) {
- (ConstValue::ByRef(id, alloc, offset), ty::Array(t, n)) => {
- if *t != tcx.types.u8 {
- // FIXME(oli-obk): can't mix const patterns with slice patterns and get
- // any sort of exhaustiveness/unreachable check yet
- return Ok(false);
- }
- let ptr = Pointer::new(id, offset);
- let n = n.assert_usize(tcx).unwrap();
- alloc.get_bytes(&tcx, ptr, Size::from_bytes(n)).unwrap()
- },
- (ConstValue::ScalarPair(Scalar::Bits { .. }, n), ty::Slice(_)) => {
- assert_eq!(n.to_usize(&tcx).unwrap(), 0);
- &[]
- },
- (ConstValue::ScalarPair(Scalar::Ptr(ptr), n), ty::Slice(t)) => {
- if *t != tcx.types.u8 {
- // FIXME(oli-obk): can't mix const patterns with slice patterns and get
- // any sort of exhaustiveness/unreachable check yet
- return Ok(false);
- }
- let n = n.to_usize(&tcx).unwrap();
- tcx.alloc_map
- .lock()
- .unwrap_memory(ptr.alloc_id)
- .get_bytes(&tcx, ptr, Size::from_bytes(n))
- .unwrap()
- },
- _ => bug!(
- "slice_pat_covered_by_constructor: {:#?}, {:#?}, {:#?}, {:#?}",
- ctor, prefix, slice, suffix,
- ),
+ let data: &[u8] = match (const_val.val, &const_val.ty.sty) {
+ (ConstValue::ByRef(id, alloc, offset), ty::Array(t, n)) => {
+ if *t != tcx.types.u8 {
+ // FIXME(oli-obk): can't mix const patterns with slice patterns and get
+ // any sort of exhaustiveness/unreachable check yet
+ return Ok(false);