- // a slice fat pointer to a zero length slice
- (ConstValue::Slice(Scalar::Bits { .. }, 0), 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
- // This solely means that we don't lint about unreachable patterns, even if some
- // are definitely unreachable.
- return Ok(false);
- }
- &[]
- },
- //
- (ConstValue::Slice(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
- // This solely means that we don't lint about unreachable patterns, even if some
- // are definitely unreachable.
- return Ok(false);
- }
- tcx.alloc_map
- .lock()
- .unwrap_memory(ptr.alloc_id)
- .get_bytes(&tcx, ptr, Size::from_bytes(n))
- .unwrap()
+ (ConstValue::Slice { data, start, end }, ty::Slice(t)) => {
+ assert_eq!(*t, tcx.types.u8);
+ let ptr = Pointer::new(AllocId(0), Size::from_bytes(start as u64));
+ data.get_bytes(&tcx, ptr, Size::from_bytes((end - start) as u64)).unwrap()