@@ -389,25 +389,25 @@ impl SplitIntRange {
389389#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
390390enum SliceKind {
391391 /// Patterns of length `n` (`[x, y]`).
392- FixedLen ( u64 ) ,
392+ FixedLen ( usize ) ,
393393 /// Patterns using the `..` notation (`[x, .., y]`).
394394 /// Captures any array constructor of `length >= i + j`.
395395 /// In the case where `array_len` is `Some(_)`,
396396 /// this indicates that we only care about the first `i` and the last `j` values of the array,
397397 /// and everything in between is a wildcard `_`.
398- VarLen ( u64 , u64 ) ,
398+ VarLen ( usize , usize ) ,
399399}
400400
401401impl SliceKind {
402- fn arity ( self ) -> u64 {
402+ fn arity ( self ) -> usize {
403403 match self {
404404 FixedLen ( length) => length,
405405 VarLen ( prefix, suffix) => prefix + suffix,
406406 }
407407 }
408408
409409 /// 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 {
411411 match self {
412412 FixedLen ( len) => len == other_len,
413413 VarLen ( prefix, suffix) => prefix + suffix <= other_len,
@@ -419,13 +419,13 @@ impl SliceKind {
419419#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
420420pub ( super ) struct Slice {
421421 /// `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 > ,
423423 /// The kind of pattern it is: fixed-length `[x, y]` or variable length `[x, .., y]`.
424424 kind : SliceKind ,
425425}
426426
427427impl Slice {
428- fn new ( array_len : Option < u64 > , kind : SliceKind ) -> Self {
428+ fn new ( array_len : Option < usize > , kind : SliceKind ) -> Self {
429429 let kind = match ( array_len, kind) {
430430 // If the middle `..` is empty, we effectively have a fixed-length pattern.
431431 ( Some ( len) , VarLen ( prefix, suffix) ) if prefix + suffix >= len => FixedLen ( len) ,
@@ -434,7 +434,7 @@ impl Slice {
434434 Slice { array_len, kind }
435435 }
436436
437- fn arity ( self ) -> u64 {
437+ fn arity ( self ) -> usize {
438438 self . kind . arity ( )
439439 }
440440
@@ -508,16 +508,16 @@ impl Slice {
508508#[ derive( Debug ) ]
509509struct SplitVarLenSlice {
510510 /// If the type is an array, this is its size.
511- array_len : Option < u64 > ,
511+ array_len : Option < usize > ,
512512 /// The arity of the input slice.
513- arity : u64 ,
513+ arity : usize ,
514514 /// The smallest slice bigger than any slice seen. `max_slice.arity()` is the length `L`
515515 /// described above.
516516 max_slice : SliceKind ,
517517}
518518
519519impl 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 {
521521 SplitVarLenSlice { array_len, arity : prefix + suffix, max_slice : VarLen ( prefix, suffix) }
522522 }
523523
@@ -687,12 +687,12 @@ impl<'tcx> Constructor<'tcx> {
687687 }
688688 PatKind :: Array { prefix, slice, suffix } | PatKind :: Slice { prefix, slice, suffix } => {
689689 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 ) ,
691691 ty:: Slice ( _) => None ,
692692 _ => span_bug ! ( pat. span, "bad ty {:?} for slice pattern" , pat. ty) ,
693693 } ;
694- let prefix = prefix. len ( ) as u64 ;
695- let suffix = suffix. len ( ) as u64 ;
694+ let prefix = prefix. len ( ) ;
695+ let suffix = suffix. len ( ) ;
696696 let kind = if slice. is_some ( ) {
697697 VarLen ( prefix, suffix)
698698 } else {
@@ -885,7 +885,7 @@ impl<'tcx> SplitWildcard<'tcx> {
885885 let all_ctors = match pcx. ty . kind ( ) {
886886 ty:: Bool => smallvec ! [ make_range( 0 , 1 ) ] ,
887887 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 ;
889889 if len != 0 && cx. is_uninhabited ( sub_ty) {
890890 smallvec ! [ ]
891891 } else {
@@ -1273,7 +1273,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
12731273 PatKind :: Slice { prefix : subpatterns. collect ( ) , slice : None , suffix : vec ! [ ] }
12741274 }
12751275 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 ( ) ;
12771277 if slice. array_len . is_some ( ) {
12781278 // Improves diagnostics a bit: if the type is a known-size array, instead
12791279 // of reporting `[x, _, .., _, y]`, we prefer to report `[x, .., y]`.
0 commit comments