@@ -1439,10 +1439,19 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1439
1439
// We treat match scrutinees of type `!` or `EmptyEnum` differently.
1440
1440
let is_toplevel_exception =
1441
1441
is_top_level && matches ! ( ctors_for_ty, ConstructorSet :: NoConstructors ) ;
1442
- // Whether empty patterns can be omitted for exhaustiveness.
1443
- let can_omit_empty_arms = is_toplevel_exception || mcx. tycx . is_exhaustive_patterns_feature_on ( ) ;
1444
- // Whether empty patterns are counted as useful or not.
1445
- let empty_arms_are_unreachable = place_validity. is_known_valid ( ) && can_omit_empty_arms;
1442
+ // Whether empty patterns can be omitted for exhaustiveness. Empty arms on a `!known_valid`
1443
+ // place are not guaranteed unreachable by the operational semantics, but we allow omitting them
1444
+ // in some cases nonetheless.
1445
+ let can_omit_empty_arms = is_toplevel_exception
1446
+ || mcx. tycx . is_exhaustive_patterns_feature_on ( )
1447
+ || ( mcx. tycx . is_min_exhaustive_patterns_feature_on ( ) && place_validity. is_known_valid ( ) ) ;
1448
+ // Whether empty patterns are counted as useful or not. Unlike for omitting arms, we only warn
1449
+ // an arm unreachable if it is guaranteed unreachable by the opsem (i.e. if the place is
1450
+ // `known_valid`).
1451
+ let empty_arms_are_unreachable = place_validity. is_known_valid ( )
1452
+ && ( is_toplevel_exception
1453
+ || mcx. tycx . is_exhaustive_patterns_feature_on ( )
1454
+ || mcx. tycx . is_min_exhaustive_patterns_feature_on ( ) ) ;
1446
1455
1447
1456
// Analyze the constructors present in this column.
1448
1457
let ctors = matrix. heads ( ) . map ( |p| p. ctor ( ) ) ;
0 commit comments