|
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 | //! |
@@ -953,13 +951,10 @@ impl<Cx: PatCx> PlaceInfo<Cx> { |
953 | 951 | self.is_scrutinee && matches!(ctors_for_ty, ConstructorSet::NoConstructors); |
954 | 952 | // Whether empty patterns are counted as useful or not. We only warn an empty arm unreachable if |
955 | 953 | // it is guaranteed unreachable by the opsem (i.e. if the place is `known_valid`). |
956 | | - let empty_arms_are_unreachable = self.validity.is_known_valid() |
957 | | - && (is_toplevel_exception |
958 | | - || cx.is_exhaustive_patterns_feature_on() |
959 | | - || cx.is_min_exhaustive_patterns_feature_on()); |
| 954 | + let empty_arms_are_unreachable = self.validity.is_known_valid(); |
960 | 955 | // Whether empty patterns can be omitted for exhaustiveness. We ignore place validity in the |
961 | 956 | // toplevel exception and `exhaustive_patterns` cases for backwards compatibility. |
962 | | - let can_omit_empty_arms = empty_arms_are_unreachable |
| 957 | + let can_omit_empty_arms = self.validity.is_known_valid() |
963 | 958 | || is_toplevel_exception |
964 | 959 | || cx.is_exhaustive_patterns_feature_on(); |
965 | 960 |
|
|
0 commit comments