@@ -40,19 +40,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
40
40
suffix : & ' pat [ Box < Pat < ' tcx > > ] ,
41
41
) {
42
42
let tcx = self . tcx ;
43
- let ( min_length, exact_size) = if let Some ( place_resolved) = place. try_to_place ( self ) {
44
- match place_resolved. ty ( & self . local_decls , tcx) . ty . kind ( ) {
45
- ty:: Array ( _, length) => (
46
- length
47
- . try_to_target_usize ( tcx)
48
- . expect ( "expected len of array pat to be definite" ) ,
49
- true ,
50
- ) ,
51
- _ => ( ( prefix. len ( ) + suffix. len ( ) ) . try_into ( ) . unwrap ( ) , false ) ,
52
- }
43
+
44
+ // Minimum length of the sequence being matched, needed by projections.
45
+ // If `exact_size` is true, that "minimum" is actually an exact length.
46
+ //
47
+ // The caller of `prefix_slice_suffix` is responsible for enforcing
48
+ // that length if necessary, e.g. by checking the scrutinee's length.
49
+ let min_length: u64 ;
50
+ let exact_size: bool ;
51
+
52
+ if let Some ( place_resolved) = place. try_to_place ( self )
53
+ && let ty:: Array ( _, length) = place_resolved. ty ( & self . local_decls , tcx) . ty . kind ( )
54
+ {
55
+ min_length =
56
+ length. try_to_target_usize ( tcx) . expect ( "expected len of array pat to be definite" ) ;
57
+ exact_size = true ;
53
58
} else {
54
- ( ( prefix. len ( ) + suffix. len ( ) ) . try_into ( ) . unwrap ( ) , false )
55
- } ;
59
+ min_length = u64:: try_from ( prefix. len ( ) + suffix. len ( ) ) . unwrap ( ) ;
60
+ exact_size = false ;
61
+ }
56
62
57
63
match_pairs. extend ( prefix. iter ( ) . enumerate ( ) . map ( |( idx, subpattern) | {
58
64
let elem =
0 commit comments