@@ -1319,28 +1319,16 @@ impl<Cx: TypeCx> WitnessMatrix<Cx> {
1319
1319
fn apply_constructor (
1320
1320
& mut self ,
1321
1321
pcx : & PlaceCtxt < ' _ , Cx > ,
1322
- mut missing_ctors : & [ Constructor < Cx > ] ,
1322
+ missing_ctors : & [ Constructor < Cx > ] ,
1323
1323
ctor : & Constructor < Cx > ,
1324
- report_individual_missing_ctors : bool ,
1325
1324
) {
1326
1325
if self . is_empty ( ) {
1327
1326
return ;
1328
1327
}
1329
1328
if matches ! ( ctor, Constructor :: Missing ) {
1330
1329
// We got the special `Missing` constructor that stands for the constructors not present
1331
- // in the match.
1332
- if !missing_ctors. is_empty ( ) && !report_individual_missing_ctors {
1333
- // Report `_` as missing.
1334
- missing_ctors = & [ Constructor :: Wildcard ] ;
1335
- } else if missing_ctors. iter ( ) . any ( |c| c. is_non_exhaustive ( ) ) {
1336
- // We need to report a `_` anyway, so listing other constructors would be redundant.
1337
- // `NonExhaustive` is displayed as `_` just like `Wildcard`, but it will be picked
1338
- // up by diagnostics to add a note about why `_` is required here.
1339
- missing_ctors = & [ Constructor :: NonExhaustive ] ;
1340
- }
1341
-
1342
- // For each missing constructor `c`, we add a `c(_, _, _)` witness appropriately
1343
- // filled with wildcards.
1330
+ // in the match. For each missing constructor `c`, we add a `c(_, _, _)` witness
1331
+ // appropriately filled with wildcards.
1344
1332
let mut ret = Self :: empty ( ) ;
1345
1333
for ctor in missing_ctors {
1346
1334
let pat = pcx. wild_from_ctor ( ctor. clone ( ) ) ;
@@ -1515,11 +1503,6 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1515
1503
split_ctors. push ( Constructor :: Missing ) ;
1516
1504
}
1517
1505
1518
- // Decide what constructors to report.
1519
- let is_integers = matches ! ( ctors_for_ty, ConstructorSet :: Integers { .. } ) ;
1520
- let always_report_all = place. is_scrutinee && !is_integers;
1521
- // Whether we should report "Enum::A and Enum::C are missing" or "_ is missing".
1522
- let report_individual_missing_ctors = always_report_all || !all_missing;
1523
1506
// Which constructors are considered missing. We ensure that `!missing_ctors.is_empty() =>
1524
1507
// split_ctors.contains(Missing)`. The converse usually holds except when
1525
1508
// `!place_validity.is_known_valid()`.
@@ -1528,6 +1511,21 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1528
1511
missing_ctors. append ( & mut split_set. missing_empty ) ;
1529
1512
}
1530
1513
1514
+ // Decide what constructors to report.
1515
+ let is_integers = matches ! ( ctors_for_ty, ConstructorSet :: Integers { .. } ) ;
1516
+ let always_report_all = place. is_scrutinee && !is_integers;
1517
+ // Whether we should report "Enum::A and Enum::C are missing" or "_ is missing".
1518
+ let report_individual_missing_ctors = always_report_all || !all_missing;
1519
+ if !missing_ctors. is_empty ( ) && !report_individual_missing_ctors {
1520
+ // Report `_` as missing.
1521
+ missing_ctors = vec ! [ Constructor :: Wildcard ] ;
1522
+ } else if missing_ctors. iter ( ) . any ( |c| c. is_non_exhaustive ( ) ) {
1523
+ // We need to report a `_` anyway, so listing other constructors would be redundant.
1524
+ // `NonExhaustive` is displayed as `_` just like `Wildcard`, but it will be picked
1525
+ // up by diagnostics to add a note about why `_` is required here.
1526
+ missing_ctors = vec ! [ Constructor :: NonExhaustive ] ;
1527
+ }
1528
+
1531
1529
let mut ret = WitnessMatrix :: empty ( ) ;
1532
1530
for ctor in split_ctors {
1533
1531
// Dig into rows that match `ctor`.
@@ -1542,7 +1540,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1542
1540
} ) ?;
1543
1541
1544
1542
// Transform witnesses for `spec_matrix` into witnesses for `matrix`.
1545
- witnesses. apply_constructor ( pcx, & missing_ctors, & ctor, report_individual_missing_ctors ) ;
1543
+ witnesses. apply_constructor ( pcx, & missing_ctors, & ctor) ;
1546
1544
// Accumulate the found witnesses.
1547
1545
ret. extend ( witnesses) ;
1548
1546
0 commit comments