@@ -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
}
@@ -777,9 +780,9 @@ fn max_slice_length<'p, 'a: 'p, 'tcx: 'a, I>(
777
780
max_fixed_len,
778
781
n. unwrap_usize ( cx. tcx ) ,
779
782
) ,
780
- ( ConstValue :: ScalarPair ( _, n) , ty:: Slice ( _) ) => max_fixed_len = cmp:: max (
783
+ ( ConstValue :: Slice ( _, n) , ty:: Slice ( _) ) => max_fixed_len = cmp:: max (
781
784
max_fixed_len,
782
- n. to_usize ( & cx . tcx ) . unwrap ( ) ,
785
+ n,
783
786
) ,
784
787
_ => { } ,
785
788
}
@@ -1414,27 +1417,25 @@ fn slice_pat_covered_by_const<'tcx>(
1414
1417
alloc. get_bytes ( & tcx, ptr, Size :: from_bytes ( n) ) . unwrap ( )
1415
1418
} ,
1416
1419
// a slice fat pointer to a zero length slice
1417
- ( ConstValue :: ScalarPair ( Scalar :: Bits { .. } , n ) , ty:: Slice ( t) ) => {
1420
+ ( ConstValue :: Slice ( Scalar :: Bits { .. } , 0 ) , ty:: Slice ( t) ) => {
1418
1421
if * t != tcx. types . u8 {
1419
1422
// FIXME(oli-obk): can't mix const patterns with slice patterns and get
1420
1423
// any sort of exhaustiveness/unreachable check yet
1421
1424
// This solely means that we don't lint about unreachable patterns, even if some
1422
1425
// are definitely unreachable.
1423
1426
return Ok ( false ) ;
1424
1427
}
1425
- assert_eq ! ( n. to_usize( & tcx) . unwrap( ) , 0 ) ;
1426
1428
& [ ]
1427
1429
} ,
1428
1430
//
1429
- ( ConstValue :: ScalarPair ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
1431
+ ( ConstValue :: Slice ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
1430
1432
if * t != tcx. types . u8 {
1431
1433
// FIXME(oli-obk): can't mix const patterns with slice patterns and get
1432
1434
// any sort of exhaustiveness/unreachable check yet
1433
1435
// This solely means that we don't lint about unreachable patterns, even if some
1434
1436
// are definitely unreachable.
1435
1437
return Ok ( false ) ;
1436
1438
}
1437
- let n = n. to_usize ( & tcx) . unwrap ( ) ;
1438
1439
tcx. alloc_map
1439
1440
. lock ( )
1440
1441
. unwrap_memory ( ptr. alloc_id )
@@ -1766,12 +1767,12 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
1766
1767
} ,
1767
1768
ty:: TyKind :: Slice ( t) => {
1768
1769
match value. val {
1769
- ConstValue :: ScalarPair ( ptr, n) => (
1770
+ ConstValue :: Slice ( ptr, n) => (
1770
1771
ptr. to_ptr ( ) . ok ( ) . map ( |ptr| (
1771
1772
ptr,
1772
1773
cx. tcx . alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) ,
1773
1774
) ) ,
1774
- n. to_bits ( cx . tcx . data_layout . pointer_size ) . unwrap ( ) as u64 ,
1775
+ n,
1775
1776
t,
1776
1777
) ,
1777
1778
_ => span_bug ! (
0 commit comments