@@ -221,13 +221,16 @@ impl<'a, 'tcx> LiteralExpander<'a, 'tcx> {
221
221
// unsize array to slice if pattern is array but match value or other patterns are slice
222
222
( ConstValue :: Scalar ( Scalar :: Ptr ( p) ) , ty:: Array ( t, n) , ty:: Slice ( u) ) => {
223
223
assert_eq ! ( t, u) ;
224
- ConstValue :: ScalarPair (
224
+ ConstValue :: Slice (
225
225
Scalar :: Ptr ( p) ,
226
- n. map_evaluated ( |val| val. val . try_to_scalar ( ) ) . unwrap ( ) ,
226
+ n. map_evaluated ( |val| val. val . try_to_scalar ( ) )
227
+ . unwrap ( )
228
+ . to_usize ( & self . tcx )
229
+ . unwrap ( ) ,
227
230
)
228
231
} ,
229
232
// fat pointers stay the same
230
- ( ConstValue :: ScalarPair ( ..) , _, _) => val,
233
+ ( ConstValue :: Slice ( ..) , _, _) => val,
231
234
// FIXME(oli-obk): this is reachable for `const FOO: &&&u32 = &&&42;` being used
232
235
_ => bug ! ( "cannot deref {:#?}, {} -> {}" , val, crty, rty) ,
233
236
}
@@ -788,9 +791,9 @@ fn max_slice_length<'p, 'a: 'p, 'tcx: 'a, I>(
788
791
max_fixed_len,
789
792
n. unwrap_usize ( cx. tcx ) ,
790
793
) ,
791
- ( ConstValue :: ScalarPair ( _, n) , ty:: Slice ( _) ) => max_fixed_len = cmp:: max (
794
+ ( ConstValue :: Slice ( _, n) , ty:: Slice ( _) ) => max_fixed_len = cmp:: max (
792
795
max_fixed_len,
793
- n. to_usize ( & cx . tcx ) . unwrap ( ) ,
796
+ n,
794
797
) ,
795
798
_ => { } ,
796
799
}
@@ -1432,27 +1435,25 @@ fn slice_pat_covered_by_const<'tcx>(
1432
1435
alloc. get_bytes ( & tcx, ptr, Size :: from_bytes ( n) ) . unwrap ( )
1433
1436
} ,
1434
1437
// a slice fat pointer to a zero length slice
1435
- ( ConstValue :: ScalarPair ( Scalar :: Bits { .. } , n ) , ty:: Slice ( t) ) => {
1438
+ ( ConstValue :: Slice ( Scalar :: Bits { .. } , 0 ) , ty:: Slice ( t) ) => {
1436
1439
if * t != tcx. types . u8 {
1437
1440
// FIXME(oli-obk): can't mix const patterns with slice patterns and get
1438
1441
// any sort of exhaustiveness/unreachable check yet
1439
1442
// This solely means that we don't lint about unreachable patterns, even if some
1440
1443
// are definitely unreachable.
1441
1444
return Ok ( false ) ;
1442
1445
}
1443
- assert_eq ! ( n. to_usize( & tcx) . unwrap( ) , 0 ) ;
1444
1446
& [ ]
1445
1447
} ,
1446
1448
//
1447
- ( ConstValue :: ScalarPair ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
1449
+ ( ConstValue :: Slice ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
1448
1450
if * t != tcx. types . u8 {
1449
1451
// FIXME(oli-obk): can't mix const patterns with slice patterns and get
1450
1452
// any sort of exhaustiveness/unreachable check yet
1451
1453
// This solely means that we don't lint about unreachable patterns, even if some
1452
1454
// are definitely unreachable.
1453
1455
return Ok ( false ) ;
1454
1456
}
1455
- let n = n. to_usize ( & tcx) . unwrap ( ) ;
1456
1457
tcx. alloc_map
1457
1458
. lock ( )
1458
1459
. unwrap_memory ( ptr. alloc_id )
@@ -1784,12 +1785,12 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
1784
1785
} ,
1785
1786
ty:: TyKind :: Slice ( t) => {
1786
1787
match value. val {
1787
- ConstValue :: ScalarPair ( ptr, n) => (
1788
+ ConstValue :: Slice ( ptr, n) => (
1788
1789
ptr. to_ptr ( ) . ok ( ) . map ( |ptr| (
1789
1790
ptr,
1790
1791
cx. tcx . alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) ,
1791
1792
) ) ,
1792
- n. to_bits ( cx . tcx . data_layout . pointer_size ) . unwrap ( ) as u64 ,
1793
+ n,
1793
1794
t,
1794
1795
) ,
1795
1796
_ => span_bug ! (
0 commit comments