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