|
543 | 543 | //! recurse into subpatterns. That second part is done through [`PlaceValidity`], most notably
|
544 | 544 | //! [`PlaceValidity::specialize`].
|
545 | 545 | //!
|
546 |
| -//! Having said all that, in practice we don't fully follow what's been presented in this section. |
547 |
| -//! Let's call "toplevel exception" the case where the match scrutinee itself has type `!` or |
548 |
| -//! `EmptyEnum`. First, on stable rust, we require `_` patterns for empty types in all cases apart |
549 |
| -//! from the toplevel exception. The `exhaustive_patterns` and `min_exaustive_patterns` allow |
550 |
| -//! omitting patterns in the cases described above. There's a final detail: in the toplevel |
551 |
| -//! exception or with the `exhaustive_patterns` feature, we ignore place validity when checking |
552 |
| -//! whether a pattern is required for exhaustiveness. I (Nadrieril) hope to deprecate this behavior. |
| 546 | +//! Having said all that, we don't fully follow what's been presented in this section. For |
| 547 | +//! backwards-compatibility, we ignore place validity when checking whether a pattern is required |
| 548 | +//! for exhaustiveness in two cases: when the `exhaustive_patterns` feature gate is on, or when the |
| 549 | +//! match scrutinee itself has type `!` or `EmptyEnum`. I (Nadrieril) hope to deprecate this |
| 550 | +//! exception. |
553 | 551 | //!
|
554 | 552 | //!
|
555 | 553 | //!
|
@@ -883,13 +881,10 @@ impl<Cx: PatCx> PlaceInfo<Cx> {
|
883 | 881 | self.is_scrutinee && matches!(ctors_for_ty, ConstructorSet::NoConstructors);
|
884 | 882 | // Whether empty patterns are counted as useful or not. We only warn an empty arm unreachable if
|
885 | 883 | // it is guaranteed unreachable by the opsem (i.e. if the place is `known_valid`).
|
886 |
| - let empty_arms_are_unreachable = self.validity.is_known_valid() |
887 |
| - && (is_toplevel_exception |
888 |
| - || cx.is_exhaustive_patterns_feature_on() |
889 |
| - || cx.is_min_exhaustive_patterns_feature_on()); |
| 884 | + let empty_arms_are_unreachable = self.validity.is_known_valid(); |
890 | 885 | // Whether empty patterns can be omitted for exhaustiveness. We ignore place validity in the
|
891 | 886 | // toplevel exception and `exhaustive_patterns` cases for backwards compatibility.
|
892 |
| - let can_omit_empty_arms = empty_arms_are_unreachable |
| 887 | + let can_omit_empty_arms = self.validity.is_known_valid() |
893 | 888 | || is_toplevel_exception
|
894 | 889 | || cx.is_exhaustive_patterns_feature_on();
|
895 | 890 |
|
|
0 commit comments