@@ -954,6 +954,9 @@ struct FlatPat<'pat, 'tcx> {
954
954
955
955
/// ...and these types asserted.
956
956
ascriptions : Vec < Ascription < ' tcx > > ,
957
+
958
+ /// Whether this recursively contains no bindings or ascriptions.
959
+ simple : bool ,
957
960
}
958
961
959
962
impl < ' tcx , ' pat > FlatPat < ' pat , ' tcx > {
@@ -968,7 +971,11 @@ impl<'tcx, 'pat> FlatPat<'pat, 'tcx> {
968
971
969
972
cx. simplify_match_pairs ( & mut match_pairs, & mut bindings, & mut ascriptions) ;
970
973
971
- FlatPat { span : pattern. span , match_pairs, bindings, ascriptions }
974
+ let simple = bindings. is_empty ( )
975
+ && ascriptions. is_empty ( )
976
+ && match_pairs. iter ( ) . all ( |mp| mp. is_simple ( ) ) ;
977
+
978
+ FlatPat { span : pattern. span , match_pairs, bindings, ascriptions, simple }
972
979
}
973
980
}
974
981
@@ -1084,12 +1091,27 @@ struct Ascription<'tcx> {
1084
1091
1085
1092
#[ derive( Debug , Clone ) ]
1086
1093
enum TestCase < ' pat , ' tcx > {
1087
- Irrefutable { binding : Option < Binding < ' tcx > > , ascription : Option < Ascription < ' tcx > > } ,
1088
- Variant { adt_def : ty:: AdtDef < ' tcx > , variant_index : VariantIdx } ,
1089
- Constant { value : mir:: Const < ' tcx > } ,
1094
+ Irrefutable {
1095
+ binding : Option < Binding < ' tcx > > ,
1096
+ ascription : Option < Ascription < ' tcx > > ,
1097
+ } ,
1098
+ Variant {
1099
+ adt_def : ty:: AdtDef < ' tcx > ,
1100
+ variant_index : VariantIdx ,
1101
+ } ,
1102
+ Constant {
1103
+ value : mir:: Const < ' tcx > ,
1104
+ } ,
1090
1105
Range ( & ' pat PatRange < ' tcx > ) ,
1091
- Slice { len : usize , variable_length : bool } ,
1092
- Or { pats : Box < [ FlatPat < ' pat , ' tcx > ] > } ,
1106
+ Slice {
1107
+ len : usize ,
1108
+ variable_length : bool ,
1109
+ } ,
1110
+ Or {
1111
+ pats : Box < [ FlatPat < ' pat , ' tcx > ] > ,
1112
+ /// Whether this recursively contains no bindings or ascriptions.
1113
+ simple : bool ,
1114
+ } ,
1093
1115
}
1094
1116
1095
1117
#[ derive( Debug , Clone ) ]
@@ -1443,7 +1465,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1443
1465
1444
1466
let first_match_pair = first_candidate. match_pairs . remove ( 0 ) ;
1445
1467
let or_span = first_match_pair. pattern . span ;
1446
- let TestCase :: Or { pats } = first_match_pair. test_case else { unreachable ! ( ) } ;
1468
+ let TestCase :: Or { pats, .. } = first_match_pair. test_case else { unreachable ! ( ) } ;
1447
1469
1448
1470
let remainder_start = self . cfg . start_new_block ( ) ;
1449
1471
// Test the alternatives of this or-pattern.
0 commit comments