@@ -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 }
@@ -777,9 +780,9 @@ fn max_slice_length<'p, 'a: 'p, 'tcx: 'a, I>(
777780 max_fixed_len,
778781 n. unwrap_usize ( cx. tcx ) ,
779782 ) ,
780- ( ConstValue :: ScalarPair ( _, n) , ty:: Slice ( _) ) => max_fixed_len = cmp:: max (
783+ ( ConstValue :: Slice ( _, n) , ty:: Slice ( _) ) => max_fixed_len = cmp:: max (
781784 max_fixed_len,
782- n. to_usize ( & cx . tcx ) . unwrap ( ) ,
785+ n,
783786 ) ,
784787 _ => { } ,
785788 }
@@ -1421,27 +1424,25 @@ fn slice_pat_covered_by_const<'tcx>(
14211424 alloc. get_bytes ( & tcx, ptr, Size :: from_bytes ( n) ) . unwrap ( )
14221425 } ,
14231426 // a slice fat pointer to a zero length slice
1424- ( ConstValue :: ScalarPair ( Scalar :: Bits { .. } , n ) , ty:: Slice ( t) ) => {
1427+ ( ConstValue :: Slice ( Scalar :: Bits { .. } , 0 ) , ty:: Slice ( t) ) => {
14251428 if * t != tcx. types . u8 {
14261429 // FIXME(oli-obk): can't mix const patterns with slice patterns and get
14271430 // any sort of exhaustiveness/unreachable check yet
14281431 // This solely means that we don't lint about unreachable patterns, even if some
14291432 // are definitely unreachable.
14301433 return Ok ( false ) ;
14311434 }
1432- assert_eq ! ( n. to_usize( & tcx) . unwrap( ) , 0 ) ;
14331435 & [ ]
14341436 } ,
14351437 //
1436- ( ConstValue :: ScalarPair ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
1438+ ( ConstValue :: Slice ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
14371439 if * t != tcx. types . u8 {
14381440 // FIXME(oli-obk): can't mix const patterns with slice patterns and get
14391441 // any sort of exhaustiveness/unreachable check yet
14401442 // This solely means that we don't lint about unreachable patterns, even if some
14411443 // are definitely unreachable.
14421444 return Ok ( false ) ;
14431445 }
1444- let n = n. to_usize ( & tcx) . unwrap ( ) ;
14451446 tcx. alloc_map
14461447 . lock ( )
14471448 . unwrap_memory ( ptr. alloc_id )
@@ -1773,12 +1774,12 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
17731774 } ,
17741775 ty:: TyKind :: Slice ( t) => {
17751776 match value. val {
1776- ConstValue :: ScalarPair ( ptr, n) => (
1777+ ConstValue :: Slice ( ptr, n) => (
17771778 ptr. to_ptr ( ) . ok ( ) . map ( |ptr| (
17781779 ptr,
17791780 cx. tcx . alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) ,
17801781 ) ) ,
1781- n. to_bits ( cx . tcx . data_layout . pointer_size ) . unwrap ( ) as u64 ,
1782+ n,
17821783 t,
17831784 ) ,
17841785 _ => span_bug ! (
0 commit comments