@@ -389,25 +389,25 @@ impl SplitIntRange {
389
389
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
390
390
enum SliceKind {
391
391
/// Patterns of length `n` (`[x, y]`).
392
- FixedLen ( u64 ) ,
392
+ FixedLen ( usize ) ,
393
393
/// Patterns using the `..` notation (`[x, .., y]`).
394
394
/// Captures any array constructor of `length >= i + j`.
395
395
/// In the case where `array_len` is `Some(_)`,
396
396
/// this indicates that we only care about the first `i` and the last `j` values of the array,
397
397
/// and everything in between is a wildcard `_`.
398
- VarLen ( u64 , u64 ) ,
398
+ VarLen ( usize , usize ) ,
399
399
}
400
400
401
401
impl SliceKind {
402
- fn arity ( self ) -> u64 {
402
+ fn arity ( self ) -> usize {
403
403
match self {
404
404
FixedLen ( length) => length,
405
405
VarLen ( prefix, suffix) => prefix + suffix,
406
406
}
407
407
}
408
408
409
409
/// Whether this pattern includes patterns of length `other_len`.
410
- fn covers_length ( self , other_len : u64 ) -> bool {
410
+ fn covers_length ( self , other_len : usize ) -> bool {
411
411
match self {
412
412
FixedLen ( len) => len == other_len,
413
413
VarLen ( prefix, suffix) => prefix + suffix <= other_len,
@@ -419,13 +419,13 @@ impl SliceKind {
419
419
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
420
420
pub ( super ) struct Slice {
421
421
/// `None` if the matched value is a slice, `Some(n)` if it is an array of size `n`.
422
- array_len : Option < u64 > ,
422
+ array_len : Option < usize > ,
423
423
/// The kind of pattern it is: fixed-length `[x, y]` or variable length `[x, .., y]`.
424
424
kind : SliceKind ,
425
425
}
426
426
427
427
impl Slice {
428
- fn new ( array_len : Option < u64 > , kind : SliceKind ) -> Self {
428
+ fn new ( array_len : Option < usize > , kind : SliceKind ) -> Self {
429
429
let kind = match ( array_len, kind) {
430
430
// If the middle `..` is empty, we effectively have a fixed-length pattern.
431
431
( Some ( len) , VarLen ( prefix, suffix) ) if prefix + suffix >= len => FixedLen ( len) ,
@@ -434,7 +434,7 @@ impl Slice {
434
434
Slice { array_len, kind }
435
435
}
436
436
437
- fn arity ( self ) -> u64 {
437
+ fn arity ( self ) -> usize {
438
438
self . kind . arity ( )
439
439
}
440
440
@@ -508,16 +508,16 @@ impl Slice {
508
508
#[ derive( Debug ) ]
509
509
struct SplitVarLenSlice {
510
510
/// If the type is an array, this is its size.
511
- array_len : Option < u64 > ,
511
+ array_len : Option < usize > ,
512
512
/// The arity of the input slice.
513
- arity : u64 ,
513
+ arity : usize ,
514
514
/// The smallest slice bigger than any slice seen. `max_slice.arity()` is the length `L`
515
515
/// described above.
516
516
max_slice : SliceKind ,
517
517
}
518
518
519
519
impl SplitVarLenSlice {
520
- fn new ( prefix : u64 , suffix : u64 , array_len : Option < u64 > ) -> Self {
520
+ fn new ( prefix : usize , suffix : usize , array_len : Option < usize > ) -> Self {
521
521
SplitVarLenSlice { array_len, arity : prefix + suffix, max_slice : VarLen ( prefix, suffix) }
522
522
}
523
523
@@ -687,12 +687,12 @@ impl<'tcx> Constructor<'tcx> {
687
687
}
688
688
PatKind :: Array { prefix, slice, suffix } | PatKind :: Slice { prefix, slice, suffix } => {
689
689
let array_len = match pat. ty . kind ( ) {
690
- ty:: Array ( _, length) => Some ( length. eval_usize ( cx. tcx , cx. param_env ) ) ,
690
+ ty:: Array ( _, length) => Some ( length. eval_usize ( cx. tcx , cx. param_env ) as usize ) ,
691
691
ty:: Slice ( _) => None ,
692
692
_ => span_bug ! ( pat. span, "bad ty {:?} for slice pattern" , pat. ty) ,
693
693
} ;
694
- let prefix = prefix. len ( ) as u64 ;
695
- let suffix = suffix. len ( ) as u64 ;
694
+ let prefix = prefix. len ( ) ;
695
+ let suffix = suffix. len ( ) ;
696
696
let kind = if slice. is_some ( ) {
697
697
VarLen ( prefix, suffix)
698
698
} else {
@@ -885,7 +885,7 @@ impl<'tcx> SplitWildcard<'tcx> {
885
885
let all_ctors = match pcx. ty . kind ( ) {
886
886
ty:: Bool => smallvec ! [ make_range( 0 , 1 ) ] ,
887
887
ty:: Array ( sub_ty, len) if len. try_eval_usize ( cx. tcx , cx. param_env ) . is_some ( ) => {
888
- let len = len. eval_usize ( cx. tcx , cx. param_env ) ;
888
+ let len = len. eval_usize ( cx. tcx , cx. param_env ) as usize ;
889
889
if len != 0 && cx. is_uninhabited ( sub_ty) {
890
890
smallvec ! [ ]
891
891
} else {
@@ -1273,7 +1273,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
1273
1273
PatKind :: Slice { prefix : subpatterns. collect ( ) , slice : None , suffix : vec ! [ ] }
1274
1274
}
1275
1275
VarLen ( prefix, _) => {
1276
- let mut prefix: Vec < _ > = subpatterns. by_ref ( ) . take ( prefix as usize ) . collect ( ) ;
1276
+ let mut prefix: Vec < _ > = subpatterns. by_ref ( ) . take ( prefix) . collect ( ) ;
1277
1277
if slice. array_len . is_some ( ) {
1278
1278
// Improves diagnostics a bit: if the type is a known-size array, instead
1279
1279
// of reporting `[x, _, .., _, y]`, we prefer to report `[x, .., y]`.
0 commit comments