@@ -221,13 +221,16 @@ impl<'a, 'tcx> LiteralExpander<'a, 'tcx> {
221221 // unsize array to slice if pattern is array but match value or other patterns are slice
222222 ( ConstValue :: Scalar ( Scalar :: Ptr ( p) ) , ty:: Array ( t, n) , ty:: Slice ( u) ) => {
223223 assert_eq ! ( t, u) ;
224- ConstValue :: ScalarPair (
224+ ConstValue :: Slice (
225225 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 ( ) ,
227230 )
228231 } ,
229232 // fat pointers stay the same
230- ( ConstValue :: ScalarPair ( ..) , _, _) => val,
233+ ( ConstValue :: Slice ( ..) , _, _) => val,
231234 // FIXME(oli-obk): this is reachable for `const FOO: &&&u32 = &&&42;` being used
232235 _ => bug ! ( "cannot deref {:#?}, {} -> {}" , val, crty, rty) ,
233236 }
@@ -788,9 +791,9 @@ fn max_slice_length<'p, 'a: 'p, 'tcx: 'a, I>(
788791 max_fixed_len,
789792 n. unwrap_usize ( cx. tcx ) ,
790793 ) ,
791- ( ConstValue :: ScalarPair ( _, n) , ty:: Slice ( _) ) => max_fixed_len = cmp:: max (
794+ ( ConstValue :: Slice ( _, n) , ty:: Slice ( _) ) => max_fixed_len = cmp:: max (
792795 max_fixed_len,
793- n. to_usize ( & cx . tcx ) . unwrap ( ) ,
796+ n,
794797 ) ,
795798 _ => { } ,
796799 }
@@ -1432,27 +1435,25 @@ fn slice_pat_covered_by_const<'tcx>(
14321435 alloc. get_bytes ( & tcx, ptr, Size :: from_bytes ( n) ) . unwrap ( )
14331436 } ,
14341437 // 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) ) => {
14361439 if * t != tcx. types . u8 {
14371440 // FIXME(oli-obk): can't mix const patterns with slice patterns and get
14381441 // any sort of exhaustiveness/unreachable check yet
14391442 // This solely means that we don't lint about unreachable patterns, even if some
14401443 // are definitely unreachable.
14411444 return Ok ( false ) ;
14421445 }
1443- assert_eq ! ( n. to_usize( & tcx) . unwrap( ) , 0 ) ;
14441446 & [ ]
14451447 } ,
14461448 //
1447- ( ConstValue :: ScalarPair ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
1449+ ( ConstValue :: Slice ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
14481450 if * t != tcx. types . u8 {
14491451 // FIXME(oli-obk): can't mix const patterns with slice patterns and get
14501452 // any sort of exhaustiveness/unreachable check yet
14511453 // This solely means that we don't lint about unreachable patterns, even if some
14521454 // are definitely unreachable.
14531455 return Ok ( false ) ;
14541456 }
1455- let n = n. to_usize ( & tcx) . unwrap ( ) ;
14561457 tcx. alloc_map
14571458 . lock ( )
14581459 . unwrap_memory ( ptr. alloc_id )
@@ -1784,12 +1785,12 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
17841785 } ,
17851786 ty:: TyKind :: Slice ( t) => {
17861787 match value. val {
1787- ConstValue :: ScalarPair ( ptr, n) => (
1788+ ConstValue :: Slice ( ptr, n) => (
17881789 ptr. to_ptr ( ) . ok ( ) . map ( |ptr| (
17891790 ptr,
17901791 cx. tcx . alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) ,
17911792 ) ) ,
1792- n. to_bits ( cx . tcx . data_layout . pointer_size ) . unwrap ( ) as u64 ,
1793+ n,
17931794 t,
17941795 ) ,
17951796 _ => span_bug ! (
0 commit comments