@@ -629,18 +629,11 @@ pub(super) enum Constructor<'tcx> {
629629 /// `#[doc(hidden)]` ones.
630630 Hidden ,
631631 /// Fake extra constructor for constructors that are not seen in the matrix, as explained in the
632- /// code for [`Constructor::split`]. The carried `bool` is used for the
633- /// `non_exhaustive_omitted_patterns` lint.
634- Missing {
635- nonexhaustive_enum_missing_visible_variants : bool ,
636- } ,
632+ /// code for [`Constructor::split`].
633+ Missing ,
637634}
638635
639636impl < ' tcx > Constructor < ' tcx > {
640- pub ( super ) fn is_wildcard ( & self ) -> bool {
641- matches ! ( self , Wildcard )
642- }
643-
644637 pub ( super ) fn is_non_exhaustive ( & self ) -> bool {
645638 matches ! ( self , NonExhaustive )
646639 }
@@ -778,14 +771,8 @@ impl<'tcx> Constructor<'tcx> {
778771 let all_missing = split_set. present . is_empty ( ) ;
779772 let report_when_all_missing =
780773 pcx. is_top_level && !IntRange :: is_integral ( pcx. ty ) ;
781- let ctor = if all_missing && !report_when_all_missing {
782- Wildcard
783- } else {
784- Missing {
785- nonexhaustive_enum_missing_visible_variants : split_set
786- . nonexhaustive_enum_missing_visible_variants ,
787- }
788- } ;
774+ let ctor =
775+ if all_missing && !report_when_all_missing { Wildcard } else { Missing } ;
789776 smallvec ! [ ctor]
790777 } else {
791778 split_set. present
@@ -905,11 +892,9 @@ pub(super) enum ConstructorSet {
905892/// either fully included in or disjoint from each constructor in the column. This avoids
906893/// non-trivial intersections like between `0..10` and `5..15`.
907894#[ derive( Debug ) ]
908- struct SplitConstructorSet < ' tcx > {
909- present : SmallVec < [ Constructor < ' tcx > ; 1 ] > ,
910- missing : Vec < Constructor < ' tcx > > ,
911- /// For the `non_exhaustive_omitted_patterns` lint.
912- nonexhaustive_enum_missing_visible_variants : bool ,
895+ pub ( super ) struct SplitConstructorSet < ' tcx > {
896+ pub ( super ) present : SmallVec < [ Constructor < ' tcx > ; 1 ] > ,
897+ pub ( super ) missing : Vec < Constructor < ' tcx > > ,
913898}
914899
915900impl ConstructorSet {
@@ -1039,7 +1024,7 @@ impl ConstructorSet {
10391024 /// constructors to 1/ determine which constructors of the type (if any) are missing; 2/ split
10401025 /// constructors to handle non-trivial intersections e.g. on ranges or slices.
10411026 #[ instrument( level = "debug" , skip( self , pcx, ctors) , ret) ]
1042- fn split < ' a , ' tcx > (
1027+ pub ( super ) fn split < ' a , ' tcx > (
10431028 & self ,
10441029 pcx : & PatCtxt < ' _ , ' _ , ' tcx > ,
10451030 ctors : impl Iterator < Item = & ' a Constructor < ' tcx > > + Clone ,
@@ -1051,7 +1036,6 @@ impl ConstructorSet {
10511036 let mut missing = Vec :: new ( ) ;
10521037 // Constructors in `ctors`, except wildcards.
10531038 let mut seen = ctors. filter ( |c| !( matches ! ( c, Opaque | Wildcard ) ) ) ;
1054- let mut nonexhaustive_enum_missing_visible_variants = false ;
10551039 match self {
10561040 ConstructorSet :: Single => {
10571041 if seen. next ( ) . is_none ( ) {
@@ -1063,6 +1047,7 @@ impl ConstructorSet {
10631047 ConstructorSet :: Variants { visible_variants, hidden_variants, non_exhaustive } => {
10641048 let seen_set: FxHashSet < _ > = seen. map ( |c| c. as_variant ( ) . unwrap ( ) ) . collect ( ) ;
10651049 let mut skipped_a_hidden_variant = false ;
1050+
10661051 for variant in visible_variants {
10671052 let ctor = Variant ( * variant) ;
10681053 if seen_set. contains ( & variant) {
@@ -1071,8 +1056,6 @@ impl ConstructorSet {
10711056 missing. push ( ctor) ;
10721057 }
10731058 }
1074- nonexhaustive_enum_missing_visible_variants =
1075- * non_exhaustive && !missing. is_empty ( ) ;
10761059
10771060 for variant in hidden_variants {
10781061 let ctor = Variant ( * variant) ;
@@ -1159,7 +1142,7 @@ impl ConstructorSet {
11591142 ConstructorSet :: Uninhabited => { }
11601143 }
11611144
1162- SplitConstructorSet { present, missing, nonexhaustive_enum_missing_visible_variants }
1145+ SplitConstructorSet { present, missing }
11631146 }
11641147
11651148 /// Compute the set of constructors missing from this column.
@@ -1519,6 +1502,13 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
15191502 pub ( super ) fn is_or_pat ( & self ) -> bool {
15201503 matches ! ( self . ctor, Or )
15211504 }
1505+ pub ( super ) fn flatten_or_pat ( & ' p self ) -> SmallVec < [ & ' p Self ; 1 ] > {
1506+ if self . is_or_pat ( ) {
1507+ self . iter_fields ( ) . flat_map ( |p| p. flatten_or_pat ( ) ) . collect ( )
1508+ } else {
1509+ smallvec ! [ self ]
1510+ }
1511+ }
15221512
15231513 pub ( super ) fn ctor ( & self ) -> & Constructor < ' tcx > {
15241514 & self . ctor
@@ -1704,7 +1694,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
17041694#[ derive( Debug , Clone ) ]
17051695pub ( crate ) struct WitnessPat < ' tcx > {
17061696 ctor : Constructor < ' tcx > ,
1707- fields : Vec < WitnessPat < ' tcx > > ,
1697+ pub ( crate ) fields : Vec < WitnessPat < ' tcx > > ,
17081698 ty : Ty < ' tcx > ,
17091699}
17101700
0 commit comments