@@ -902,9 +902,8 @@ impl<'tcx> SplitWildcard<'tcx> {
902902 // This determines the set of all possible constructors for the type `pcx.ty`. For numbers,
903903 // arrays and slices we use ranges and variable-length slices when appropriate.
904904 //
905- // If the `exhaustive_patterns` feature is enabled, we make sure to omit constructors that
906- // are statically impossible. E.g., for `Option<!>`, we do not include `Some(_)` in the
907- // returned list of constructors.
905+ // We omit constructors that are statically impossible. E.g., for `Option<!>`, we do not
906+ // include `Some(_)` in the returned list of constructors.
908907 // Invariant: this is empty if and only if the type is uninhabited (as determined by
909908 // `cx.is_uninhabited()`).
910909 let all_ctors = match pcx. ty . kind ( ) {
@@ -941,32 +940,21 @@ impl<'tcx> SplitWildcard<'tcx> {
941940 // witness.
942941 let is_declared_nonexhaustive = cx. is_foreign_non_exhaustive_enum ( pcx. ty ) ;
943942
944- let is_exhaustive_pat_feature = cx. tcx . features ( ) . exhaustive_patterns ;
945-
946- // If `exhaustive_patterns` is disabled and our scrutinee is an empty enum, we treat it
947- // as though it had an "unknown" constructor to avoid exposing its emptiness. The
948- // exception is if the pattern is at the top level, because we want empty matches to be
949- // considered exhaustive.
950- let is_secretly_empty =
951- def. variants ( ) . is_empty ( ) && !is_exhaustive_pat_feature && !pcx. is_top_level ;
952-
953943 let mut ctors: SmallVec < [ _ ; 1 ] > = def
954944 . variants ( )
955945 . iter_enumerated ( )
956946 . filter ( |( _, v) | {
957- // If `exhaustive_patterns` is enabled, we exclude variants known to be
958- // uninhabited.
959- !is_exhaustive_pat_feature
960- || v. inhabited_predicate ( cx. tcx , * def) . subst ( cx. tcx , substs) . apply (
961- cx. tcx ,
962- cx. param_env ,
963- cx. module ,
964- )
947+ // exclude variants known to be uninhabited.
948+ v. inhabited_predicate ( cx. tcx , * def) . subst ( cx. tcx , substs) . apply (
949+ cx. tcx ,
950+ cx. param_env ,
951+ cx. module ,
952+ )
965953 } )
966954 . map ( |( idx, _) | Variant ( idx) )
967955 . collect ( ) ;
968956
969- if is_secretly_empty || is_declared_nonexhaustive {
957+ if is_declared_nonexhaustive {
970958 ctors. push ( NonExhaustive ) ;
971959 }
972960 ctors
@@ -998,12 +986,6 @@ impl<'tcx> SplitWildcard<'tcx> {
998986 let max = size. truncate ( u128:: MAX ) ;
999987 smallvec ! [ make_range( 0 , max) ]
1000988 }
1001- // If `exhaustive_patterns` is disabled and our scrutinee is the never type, we cannot
1002- // expose its emptiness. The exception is if the pattern is at the top level, because we
1003- // want empty matches to be considered exhaustive.
1004- ty:: Never if !cx. tcx . features ( ) . exhaustive_patterns && !pcx. is_top_level => {
1005- smallvec ! [ NonExhaustive ]
1006- }
1007989 ty:: Never => smallvec ! [ ] ,
1008990 _ if cx. is_uninhabited ( pcx. ty ) => smallvec ! [ ] ,
1009991 ty:: Adt ( ..) | ty:: Tuple ( ..) | ty:: Ref ( ..) => smallvec ! [ Single ] ,
0 commit comments