@@ -947,21 +947,16 @@ impl ConstructorSet {
947
947
/// For this we first need to know about the full set of constructors for this type, which is
948
948
/// represented by this `ConstructorSet`. We then construct two lists of constructors.
949
949
///
950
- /// Formally, this returns two vecs `split` and `missing`, respecting the following constraints:
951
- /// - `split` covers the whole type
952
- /// - `split` is made of:
953
- /// - at most one wildcard (`Wildcard` or `Missing`)
954
- /// - non-wildcard constructors that are each covered by some non-wildcard constructor in `ctors`
955
- /// - together, the non-wildcard constructors in `split` cover all the non-wildcard
956
- /// constructor in `ctors`, including `Opaques`
950
+ /// Formally, this returns two vecs `present` and `missing`, respecting the following constraints:
951
+ /// - the union of `present` and `missing` covers the whole type
952
+ /// - `present` and `missing` are disjoint
953
+ /// - neither contains any wildcard
954
+ /// - each constructor in `present` is covered by some non-wildcard constructor in `ctors`
955
+ /// - together, the constructors in `present` cover all the non-wildcard constructor in `ctors`, including `Opaques`
957
956
/// - non-wildcards in `ctors` do no cover anything in `missing`
958
- /// - if we replace the `Wildcard`/`Missing` in `split` with all of `missing`, this also
959
- /// covers the whole type
960
- /// - constructors in `split` and `missing` are split for the `ctors` list; in other words,
957
+ /// - constructors in `present` and `missing` are split for the `ctors` list; in other words,
961
958
/// they are either fully included in or disjoint from each constructor in `ctors`
962
959
///
963
- /// Note in particular that wildcards in `ctors` are irrelevant; they do not change which
964
- /// constructors are present.
965
960
/// FIXME(Nadrieril): examples?
966
961
pub ( super ) fn split < ' a , ' tcx > (
967
962
& self ,
@@ -975,14 +970,15 @@ impl ConstructorSet {
975
970
' tcx : ' a ,
976
971
{
977
972
let mut missing = Vec :: new ( ) ;
978
- let mut split = Vec :: new ( ) ;
973
+ let mut present = Vec :: new ( ) ;
979
974
// Constructors in `ctors`, except wildcards and opaques.
980
975
let mut seen = Vec :: new ( ) ;
981
976
for ctor in ctors. cloned ( ) {
982
977
match ctor {
978
+ // Wildcards in `ctors` are irrelevant to splitting
983
979
Wildcard => { }
984
980
Constructor :: Opaque ( ..) => {
985
- split . push ( ctor) ;
981
+ present . push ( ctor) ;
986
982
}
987
983
_ => {
988
984
seen. push ( ctor) ;
@@ -994,7 +990,7 @@ impl ConstructorSet {
994
990
if seen. is_empty ( ) {
995
991
missing. push ( Single ) ;
996
992
} else {
997
- split . push ( Single ) ;
993
+ present . push ( Single ) ;
998
994
}
999
995
}
1000
996
ConstructorSet :: Variants { variants, non_exhaustive } => {
@@ -1003,7 +999,7 @@ impl ConstructorSet {
1003
999
for variant in variants {
1004
1000
let ctor = Variant ( * variant) ;
1005
1001
if seen_set. contains ( & variant) {
1006
- split . push ( ctor) ;
1002
+ present . push ( ctor) ;
1007
1003
} else if ctor. is_doc_hidden_variant ( pcx) || ctor. is_unstable_variant ( pcx) {
1008
1004
// We don't want to mention any variants that are `doc(hidden)` or
1009
1005
// behind an unstable feature gate.
@@ -1029,7 +1025,7 @@ impl ConstructorSet {
1029
1025
let ctor = IntRange ( splitted_range) ;
1030
1026
match seen {
1031
1027
Presence :: Unseen => missing. push ( ctor) ,
1032
- Presence :: Seen => split . push ( ctor) ,
1028
+ Presence :: Seen => present . push ( ctor) ,
1033
1029
}
1034
1030
}
1035
1031
if * non_exhaustive {
@@ -1042,7 +1038,7 @@ impl ConstructorSet {
1042
1038
let ctor = Slice ( splitted_slice) ;
1043
1039
match seen {
1044
1040
Presence :: Unseen => missing. push ( ctor) ,
1045
- Presence :: Seen => split . push ( ctor) ,
1041
+ Presence :: Seen => present . push ( ctor) ,
1046
1042
}
1047
1043
}
1048
1044
}
@@ -1052,13 +1048,13 @@ impl ConstructorSet {
1052
1048
if seen. is_empty ( ) {
1053
1049
missing. push ( slice) ;
1054
1050
} else {
1055
- split . push ( slice) ;
1051
+ present . push ( slice) ;
1056
1052
}
1057
1053
}
1058
1054
ConstructorSet :: Unlistable => {
1059
1055
// Since we can't list constructors, we take the ones in the matrix. This might list
1060
1056
// some constructors several times but there's not much we can do.
1061
- split . extend ( seen) ;
1057
+ present . extend ( seen) ;
1062
1058
missing. push ( NonExhaustive ) ;
1063
1059
}
1064
1060
// If `exhaustive_patterns` is disabled and our scrutinee is an empty type, we cannot
@@ -1071,14 +1067,7 @@ impl ConstructorSet {
1071
1067
}
1072
1068
ConstructorSet :: Uninhabited => { }
1073
1069
}
1074
- if !missing. is_empty ( ) {
1075
- if split. is_empty ( ) {
1076
- split. push ( Wildcard ) ;
1077
- } else {
1078
- split. push ( Missing ) ;
1079
- }
1080
- }
1081
- ( split, missing)
1070
+ ( present, missing)
1082
1071
}
1083
1072
}
1084
1073
0 commit comments