@@ -2096,32 +2096,19 @@ fn split_grouped_constructors<'p, 'tcx>(
20962096 let mut max_suffix_len = self_suffix;
20972097 let mut max_fixed_len = 0 ;
20982098
2099- for row in matrix. heads ( ) {
2100- match * row. kind {
2101- PatKind :: Constant { value } => {
2102- // extract the length of an array/slice from a constant
2103- match ( value. val , & value. ty . kind ) {
2104- ( _, ty:: Array ( _, n) ) => {
2105- max_fixed_len =
2106- cmp:: max ( max_fixed_len, n. eval_usize ( tcx, param_env) )
2107- }
2108- (
2109- ty:: ConstKind :: Value ( ConstValue :: Slice { start, end, .. } ) ,
2110- ty:: Slice ( _) ,
2111- ) => max_fixed_len = cmp:: max ( max_fixed_len, ( end - start) as u64 ) ,
2112- _ => { }
2099+ let head_ctors =
2100+ matrix. heads ( ) . filter_map ( |pat| pat_constructor ( tcx, param_env, pat) ) ;
2101+ for ctor in head_ctors {
2102+ match ctor {
2103+ Slice ( slice) => match slice. pattern_kind ( ) {
2104+ FixedLen ( len) => {
2105+ max_fixed_len = cmp:: max ( max_fixed_len, len) ;
21132106 }
2114- }
2115- PatKind :: Slice { ref prefix, slice : None , ref suffix }
2116- | PatKind :: Array { ref prefix, slice : None , ref suffix } => {
2117- let fixed_len = prefix. len ( ) as u64 + suffix. len ( ) as u64 ;
2118- max_fixed_len = cmp:: max ( max_fixed_len, fixed_len) ;
2119- }
2120- PatKind :: Slice { ref prefix, slice : Some ( _) , ref suffix }
2121- | PatKind :: Array { ref prefix, slice : Some ( _) , ref suffix } => {
2122- max_prefix_len = cmp:: max ( max_prefix_len, prefix. len ( ) as u64 ) ;
2123- max_suffix_len = cmp:: max ( max_suffix_len, suffix. len ( ) as u64 ) ;
2124- }
2107+ VarLen ( prefix, suffix) => {
2108+ max_prefix_len = cmp:: max ( max_prefix_len, prefix) ;
2109+ max_suffix_len = cmp:: max ( max_suffix_len, suffix) ;
2110+ }
2111+ } ,
21252112 _ => { }
21262113 }
21272114 }
0 commit comments