@@ -587,7 +587,7 @@ enum Constructor<'tcx> {
587
587
/// Ranges of literal values (`2..=5` and `2..5`).
588
588
ConstantRange ( u128 , u128 , Ty < ' tcx > , RangeEnd , Span ) ,
589
589
/// Array patterns of length n.
590
- Slice ( u64 ) ,
590
+ FixedLenSlice ( u64 ) ,
591
591
}
592
592
593
593
// Ignore spans when comparing, they don't carry semantic information as they are only for lints.
@@ -601,7 +601,7 @@ impl<'tcx> std::cmp::PartialEq for Constructor<'tcx> {
601
601
Constructor :: ConstantRange ( a_start, a_end, a_ty, a_range_end, _) ,
602
602
Constructor :: ConstantRange ( b_start, b_end, b_ty, b_range_end, _) ,
603
603
) => a_start == b_start && a_end == b_end && a_ty == b_ty && a_range_end == b_range_end,
604
- ( Constructor :: Slice ( a) , Constructor :: Slice ( b) ) => a == b,
604
+ ( Constructor :: FixedLenSlice ( a) , Constructor :: FixedLenSlice ( b) ) => a == b,
605
605
_ => false ,
606
606
}
607
607
}
@@ -610,7 +610,7 @@ impl<'tcx> std::cmp::PartialEq for Constructor<'tcx> {
610
610
impl < ' tcx > Constructor < ' tcx > {
611
611
fn is_slice ( & self ) -> bool {
612
612
match self {
613
- Slice { .. } => true ,
613
+ FixedLenSlice { .. } => true ,
614
614
_ => false ,
615
615
}
616
616
}
@@ -644,7 +644,7 @@ impl<'tcx> Constructor<'tcx> {
644
644
ty:: Const :: from_bits( tcx, * hi, ty) ,
645
645
)
646
646
}
647
- Constructor :: Slice ( val) => format ! ( "[{}]" , val) ,
647
+ Constructor :: FixedLenSlice ( val) => format ! ( "[{}]" , val) ,
648
648
_ => bug ! ( "bad constructor being displayed: `{:?}" , self ) ,
649
649
}
650
650
}
@@ -707,7 +707,7 @@ impl<'tcx> Constructor<'tcx> {
707
707
match ty. kind {
708
708
ty:: Tuple ( ref fs) => fs. len ( ) as u64 ,
709
709
ty:: Slice ( ..) | ty:: Array ( ..) => match * self {
710
- Slice ( length) => length,
710
+ FixedLenSlice ( length) => length,
711
711
ConstantValue ( ..) => 0 ,
712
712
_ => bug ! ( "bad slice pattern {:?} {:?}" , self , ty) ,
713
713
} ,
@@ -980,14 +980,14 @@ fn all_constructors<'a, 'tcx>(
980
980
. collect ( ) ,
981
981
ty:: Array ( ref sub_ty, len) if len. try_eval_usize ( cx. tcx , cx. param_env ) . is_some ( ) => {
982
982
let len = len. eval_usize ( cx. tcx , cx. param_env ) ;
983
- if len != 0 && cx. is_uninhabited ( sub_ty) { vec ! [ ] } else { vec ! [ Slice ( len) ] }
983
+ if len != 0 && cx. is_uninhabited ( sub_ty) { vec ! [ ] } else { vec ! [ FixedLenSlice ( len) ] }
984
984
}
985
985
// Treat arrays of a constant but unknown length like slices.
986
986
ty:: Array ( ref sub_ty, _) | ty:: Slice ( ref sub_ty) => {
987
987
if cx. is_uninhabited ( sub_ty) {
988
- vec ! [ Slice ( 0 ) ]
988
+ vec ! [ FixedLenSlice ( 0 ) ]
989
989
} else {
990
- ( 0 ..pcx. max_slice_length + 1 ) . map ( |length| Slice ( length) ) . collect ( )
990
+ ( 0 ..pcx. max_slice_length + 1 ) . map ( |length| FixedLenSlice ( length) ) . collect ( )
991
991
}
992
992
}
993
993
ty:: Adt ( def, substs) if def. is_enum ( ) => def
@@ -1711,15 +1711,17 @@ fn pat_constructors<'tcx>(
1711
1711
pat. span,
1712
1712
) ] ) ,
1713
1713
PatKind :: Array { .. } => match pcx. ty . kind {
1714
- ty:: Array ( _, length) => Some ( vec ! [ Slice ( length. eval_usize( cx. tcx, cx. param_env) ) ] ) ,
1714
+ ty:: Array ( _, length) => {
1715
+ Some ( vec ! [ FixedLenSlice ( length. eval_usize( cx. tcx, cx. param_env) ) ] )
1716
+ }
1715
1717
_ => span_bug ! ( pat. span, "bad ty {:?} for array pattern" , pcx. ty) ,
1716
1718
} ,
1717
1719
PatKind :: Slice { ref prefix, ref slice, ref suffix } => {
1718
1720
let pat_len = prefix. len ( ) as u64 + suffix. len ( ) as u64 ;
1719
1721
if slice. is_some ( ) {
1720
- Some ( ( pat_len..pcx. max_slice_length + 1 ) . map ( Slice ) . collect ( ) )
1722
+ Some ( ( pat_len..pcx. max_slice_length + 1 ) . map ( FixedLenSlice ) . collect ( ) )
1721
1723
} else {
1722
- Some ( vec ! [ Slice ( pat_len) ] )
1724
+ Some ( vec ! [ FixedLenSlice ( pat_len) ] )
1723
1725
}
1724
1726
}
1725
1727
PatKind :: Or { .. } => {
@@ -1741,7 +1743,7 @@ fn constructor_sub_pattern_tys<'a, 'tcx>(
1741
1743
match ty. kind {
1742
1744
ty:: Tuple ( ref fs) => fs. into_iter ( ) . map ( |t| t. expect_ty ( ) ) . collect ( ) ,
1743
1745
ty:: Slice ( ty) | ty:: Array ( ty, _) => match * ctor {
1744
- Slice ( length) => ( 0 ..length) . map ( |_| ty) . collect ( ) ,
1746
+ FixedLenSlice ( length) => ( 0 ..length) . map ( |_| ty) . collect ( ) ,
1745
1747
ConstantValue ( ..) => vec ! [ ] ,
1746
1748
_ => bug ! ( "bad slice pattern {:?} {:?}" , ctor, ty) ,
1747
1749
} ,
@@ -2238,7 +2240,7 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>(
2238
2240
2239
2241
PatKind :: Array { ref prefix, ref slice, ref suffix }
2240
2242
| PatKind :: Slice { ref prefix, ref slice, ref suffix } => match * constructor {
2241
- Slice ( ..) => {
2243
+ FixedLenSlice ( ..) => {
2242
2244
let pat_len = prefix. len ( ) + suffix. len ( ) ;
2243
2245
if let Some ( slice_count) = ctor_wild_subpatterns. len ( ) . checked_sub ( pat_len) {
2244
2246
if slice_count == 0 || slice. is_some ( ) {
0 commit comments