@@ -217,12 +217,12 @@ impl LiteralExpander<'tcx> {
217
217
// the easy case, deref a reference
218
218
( ConstValue :: Scalar ( Scalar :: Ptr ( p) ) , x, y) if x == y => {
219
219
let alloc = self . tcx . alloc_map . lock ( ) . unwrap_memory ( p. alloc_id ) ;
220
- ConstValue :: ByRef (
221
- p ,
220
+ ConstValue :: ByRef {
221
+ offset : p . offset ,
222
222
// FIXME(oli-obk): this should be the type's layout
223
- alloc. align ,
223
+ align : alloc. align ,
224
224
alloc,
225
- )
225
+ }
226
226
} ,
227
227
// unsize array to slice if pattern is array but match value or other patterns are slice
228
228
( ConstValue :: Scalar ( Scalar :: Ptr ( p) ) , ty:: Array ( t, n) , ty:: Slice ( u) ) => {
@@ -1436,9 +1436,10 @@ fn slice_pat_covered_by_const<'tcx>(
1436
1436
suffix : & [ Pattern < ' tcx > ] ,
1437
1437
) -> Result < bool , ErrorReported > {
1438
1438
let data: & [ u8 ] = match ( const_val. val , & const_val. ty . sty ) {
1439
- ( ConstValue :: ByRef ( ptr , _ , alloc) , ty:: Array ( t, n) ) => {
1439
+ ( ConstValue :: ByRef { offset , alloc, .. } , ty:: Array ( t, n) ) => {
1440
1440
assert_eq ! ( * t, tcx. types. u8 ) ;
1441
1441
let n = n. assert_usize ( tcx) . unwrap ( ) ;
1442
+ let ptr = Pointer :: new ( AllocId ( 0 ) , offset) ;
1442
1443
alloc. get_bytes ( & tcx, ptr, Size :: from_bytes ( n) ) . unwrap ( )
1443
1444
} ,
1444
1445
( ConstValue :: Slice { data, start, end } , ty:: Slice ( t) ) => {
@@ -1758,9 +1759,9 @@ fn specialize<'p, 'a: 'p, 'tcx>(
1758
1759
let ( alloc, offset, n, ty) = match value. ty . sty {
1759
1760
ty:: Array ( t, n) => {
1760
1761
match value. val {
1761
- ConstValue :: ByRef ( ptr , _ , alloc) => (
1762
+ ConstValue :: ByRef { offset , alloc, .. } => (
1762
1763
alloc,
1763
- ptr . offset ,
1764
+ offset,
1764
1765
n. unwrap_usize ( cx. tcx ) ,
1765
1766
t,
1766
1767
) ,
@@ -1778,7 +1779,7 @@ fn specialize<'p, 'a: 'p, 'tcx>(
1778
1779
( end - start) as u64 ,
1779
1780
t,
1780
1781
) ,
1781
- ConstValue :: ByRef ( .. ) => {
1782
+ ConstValue :: ByRef { .. } => {
1782
1783
// FIXME(oli-obk): implement `deref` for `ConstValue`
1783
1784
return None ;
1784
1785
} ,
0 commit comments