@@ -1312,28 +1312,16 @@ impl<Cx: TypeCx> WitnessMatrix<Cx> {
1312
1312
fn apply_constructor (
1313
1313
& mut self ,
1314
1314
pcx : & PlaceCtxt < ' _ , Cx > ,
1315
- mut missing_ctors : & [ Constructor < Cx > ] ,
1315
+ missing_ctors : & [ Constructor < Cx > ] ,
1316
1316
ctor : & Constructor < Cx > ,
1317
- report_individual_missing_ctors : bool ,
1318
1317
) {
1319
1318
if self . is_empty ( ) {
1320
1319
return ;
1321
1320
}
1322
1321
if matches ! ( ctor, Constructor :: Missing ) {
1323
1322
// We got the special `Missing` constructor that stands for the constructors not present
1324
- // in the match.
1325
- if !missing_ctors. is_empty ( ) && !report_individual_missing_ctors {
1326
- // Report `_` as missing.
1327
- missing_ctors = & [ Constructor :: Wildcard ] ;
1328
- } else if missing_ctors. iter ( ) . any ( |c| c. is_non_exhaustive ( ) ) {
1329
- // We need to report a `_` anyway, so listing other constructors would be redundant.
1330
- // `NonExhaustive` is displayed as `_` just like `Wildcard`, but it will be picked
1331
- // up by diagnostics to add a note about why `_` is required here.
1332
- missing_ctors = & [ Constructor :: NonExhaustive ] ;
1333
- }
1334
-
1335
- // For each missing constructor `c`, we add a `c(_, _, _)` witness appropriately
1336
- // filled with wildcards.
1323
+ // in the match. For each missing constructor `c`, we add a `c(_, _, _)` witness
1324
+ // appropriately filled with wildcards.
1337
1325
let mut ret = Self :: empty ( ) ;
1338
1326
for ctor in missing_ctors {
1339
1327
let pat = pcx. wild_from_ctor ( ctor. clone ( ) ) ;
@@ -1508,9 +1496,6 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1508
1496
split_ctors. push ( Constructor :: Missing ) ;
1509
1497
}
1510
1498
1511
- // Whether we should report "Enum::A and Enum::C are missing" or "_ is missing". At the top
1512
- // level we prefer to list all constructors.
1513
- let report_individual_missing_ctors = place. is_scrutinee || !all_missing;
1514
1499
// Which constructors are considered missing. We ensure that `!missing_ctors.is_empty() =>
1515
1500
// split_ctors.contains(Missing)`. The converse usually holds except when
1516
1501
// `!place_validity.is_known_valid()`.
@@ -1519,6 +1504,19 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1519
1504
missing_ctors. append ( & mut split_set. missing_empty ) ;
1520
1505
}
1521
1506
1507
+ // Whether we should report "Enum::A and Enum::C are missing" or "_ is missing". At the top
1508
+ // level we prefer to list all constructors.
1509
+ let report_individual_missing_ctors = place. is_scrutinee || !all_missing;
1510
+ if !missing_ctors. is_empty ( ) && !report_individual_missing_ctors {
1511
+ // Report `_` as missing.
1512
+ missing_ctors = vec ! [ Constructor :: Wildcard ] ;
1513
+ } else if missing_ctors. iter ( ) . any ( |c| c. is_non_exhaustive ( ) ) {
1514
+ // We need to report a `_` anyway, so listing other constructors would be redundant.
1515
+ // `NonExhaustive` is displayed as `_` just like `Wildcard`, but it will be picked
1516
+ // up by diagnostics to add a note about why `_` is required here.
1517
+ missing_ctors = vec ! [ Constructor :: NonExhaustive ] ;
1518
+ }
1519
+
1522
1520
let mut ret = WitnessMatrix :: empty ( ) ;
1523
1521
for ctor in split_ctors {
1524
1522
// Dig into rows that match `ctor`.
@@ -1533,7 +1531,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1533
1531
} ) ?;
1534
1532
1535
1533
// Transform witnesses for `spec_matrix` into witnesses for `matrix`.
1536
- witnesses. apply_constructor ( pcx, & missing_ctors, & ctor, report_individual_missing_ctors ) ;
1534
+ witnesses. apply_constructor ( pcx, & missing_ctors, & ctor) ;
1537
1535
// Accumulate the found witnesses.
1538
1536
ret. extend ( witnesses) ;
1539
1537
0 commit comments