@@ -1312,7 +1312,7 @@ impl<Cx: TypeCx> WitnessMatrix<Cx> {
1312
1312
fn apply_constructor (
1313
1313
& mut self ,
1314
1314
pcx : & PlaceCtxt < ' _ , Cx > ,
1315
- missing_ctors : & [ Constructor < Cx > ] ,
1315
+ mut missing_ctors : & [ Constructor < Cx > ] ,
1316
1316
ctor : & Constructor < Cx > ,
1317
1317
report_individual_missing_ctors : bool ,
1318
1318
) {
@@ -1322,32 +1322,27 @@ impl<Cx: TypeCx> WitnessMatrix<Cx> {
1322
1322
if matches ! ( ctor, Constructor :: Missing ) {
1323
1323
// We got the special `Missing` constructor that stands for the constructors not present
1324
1324
// in the match.
1325
- if missing_ctors. is_empty ( ) {
1326
- // Nothing to report.
1327
- * self = Self :: empty ( ) ;
1328
- } else if !report_individual_missing_ctors {
1325
+ if !missing_ctors. is_empty ( ) && !report_individual_missing_ctors {
1329
1326
// Report `_` as missing.
1330
- let pat = pcx. wild_from_ctor ( Constructor :: Wildcard ) ;
1331
- self . push_pattern ( pat) ;
1327
+ missing_ctors = & [ Constructor :: Wildcard ] ;
1332
1328
} else if missing_ctors. iter ( ) . any ( |c| c. is_non_exhaustive ( ) ) {
1333
1329
// We need to report a `_` anyway, so listing other constructors would be redundant.
1334
1330
// `NonExhaustive` is displayed as `_` just like `Wildcard`, but it will be picked
1335
1331
// up by diagnostics to add a note about why `_` is required here.
1336
- let pat = pcx. wild_from_ctor ( Constructor :: NonExhaustive ) ;
1337
- self . push_pattern ( pat) ;
1338
- } else {
1339
- // For each missing constructor `c`, we add a `c(_, _, _)` witness appropriately
1340
- // filled with wildcards.
1341
- let mut ret = Self :: empty ( ) ;
1342
- for ctor in missing_ctors {
1343
- let pat = pcx. wild_from_ctor ( ctor. clone ( ) ) ;
1344
- // Clone `self` and add `c(_, _, _)` to each of its witnesses.
1345
- let mut wit_matrix = self . clone ( ) ;
1346
- wit_matrix. push_pattern ( pat) ;
1347
- ret. extend ( wit_matrix) ;
1348
- }
1349
- * self = ret;
1332
+ missing_ctors = & [ Constructor :: NonExhaustive ] ;
1333
+ }
1334
+
1335
+ // For each missing constructor `c`, we add a `c(_, _, _)` witness appropriately
1336
+ // filled with wildcards.
1337
+ let mut ret = Self :: empty ( ) ;
1338
+ for ctor in missing_ctors {
1339
+ let pat = pcx. wild_from_ctor ( ctor. clone ( ) ) ;
1340
+ // Clone `self` and add `c(_, _, _)` to each of its witnesses.
1341
+ let mut wit_matrix = self . clone ( ) ;
1342
+ wit_matrix. push_pattern ( pat) ;
1343
+ ret. extend ( wit_matrix) ;
1350
1344
}
1345
+ * self = ret;
1351
1346
} else {
1352
1347
// Any other constructor we unspecialize as expected.
1353
1348
for witness in self . 0 . iter_mut ( ) {
0 commit comments