@@ -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 }
@@ -1414,27 +1417,25 @@ fn slice_pat_covered_by_const<'tcx>(
14141417 alloc. get_bytes ( & tcx, ptr, Size :: from_bytes ( n) ) . unwrap ( )
14151418 } ,
14161419 // 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) ) => {
14181421 if * t != tcx. types . u8 {
14191422 // FIXME(oli-obk): can't mix const patterns with slice patterns and get
14201423 // any sort of exhaustiveness/unreachable check yet
14211424 // This solely means that we don't lint about unreachable patterns, even if some
14221425 // are definitely unreachable.
14231426 return Ok ( false ) ;
14241427 }
1425- assert_eq ! ( n. to_usize( & tcx) . unwrap( ) , 0 ) ;
14261428 & [ ]
14271429 } ,
14281430 //
1429- ( ConstValue :: ScalarPair ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
1431+ ( ConstValue :: Slice ( Scalar :: Ptr ( ptr) , n) , ty:: Slice ( t) ) => {
14301432 if * t != tcx. types . u8 {
14311433 // FIXME(oli-obk): can't mix const patterns with slice patterns and get
14321434 // any sort of exhaustiveness/unreachable check yet
14331435 // This solely means that we don't lint about unreachable patterns, even if some
14341436 // are definitely unreachable.
14351437 return Ok ( false ) ;
14361438 }
1437- let n = n. to_usize ( & tcx) . unwrap ( ) ;
14381439 tcx. alloc_map
14391440 . lock ( )
14401441 . unwrap_memory ( ptr. alloc_id )
@@ -1766,12 +1767,12 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
17661767 } ,
17671768 ty:: TyKind :: Slice ( t) => {
17681769 match value. val {
1769- ConstValue :: ScalarPair ( ptr, n) => (
1770+ ConstValue :: Slice ( ptr, n) => (
17701771 ptr. to_ptr ( ) . ok ( ) . map ( |ptr| (
17711772 ptr,
17721773 cx. tcx . alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) ,
17731774 ) ) ,
1774- n. to_bits ( cx . tcx . data_layout . pointer_size ) . unwrap ( ) as u64 ,
1775+ n,
17751776 t,
17761777 ) ,
17771778 _ => span_bug ! (
0 commit comments