540
540
//! We track in the algorithm whether a given place is known to contain valid data. This is done
541
541
//! first by inspecting the scrutinee syntactically (which gives us `cx.known_valid_scrutinee`), and
542
542
//! then by tracking validity of each column of the matrix (which correspond to places) as we
543
- //! recurse into subpatterns. That second part is done through [`ValidityConstraint `], most notably
544
- //! [`ValidityConstraint ::specialize`].
543
+ //! recurse into subpatterns. That second part is done through [`PlaceValidity `], most notably
544
+ //! [`PlaceValidity ::specialize`].
545
545
//!
546
546
//! Having said all that, in practice we don't fully follow what's been presented in this section.
547
547
//! Let's call "toplevel exception" the case where the match scrutinee itself has type `!` or
@@ -718,7 +718,7 @@ use crate::constructor::{Constructor, ConstructorSet, IntRange};
718
718
use crate :: pat:: { DeconstructedPat , PatId , PatOrWild , WitnessPat } ;
719
719
use crate :: { Captures , MatchArm , PrivateUninhabitedField , TypeCx } ;
720
720
721
- use self :: ValidityConstraint :: * ;
721
+ use self :: PlaceValidity :: * ;
722
722
723
723
#[ cfg( feature = "rustc" ) ]
724
724
use rustc_data_structures:: stack:: ensure_sufficient_stack;
@@ -780,18 +780,14 @@ impl<'a, Cx: TypeCx> PlaceCtxt<'a, Cx> {
780
780
}
781
781
}
782
782
783
- /// Serves two purposes:
784
- /// - in a wildcard, tracks whether the wildcard matches only valid values (i.e. is a binding `_a`)
785
- /// or also invalid values (i.e. is a true `_` pattern).
786
- /// - in the matrix, track whether a given place (aka column) is known to contain a valid value or
787
- /// not.
783
+ /// Track whether a given place (aka column) is known to contain a valid value or not.
788
784
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
789
- pub enum ValidityConstraint {
785
+ pub enum PlaceValidity {
790
786
ValidOnly ,
791
787
MaybeInvalid ,
792
788
}
793
789
794
- impl ValidityConstraint {
790
+ impl PlaceValidity {
795
791
pub fn from_bool ( is_valid_only : bool ) -> Self {
796
792
if is_valid_only { ValidOnly } else { MaybeInvalid }
797
793
}
@@ -817,7 +813,7 @@ impl ValidityConstraint {
817
813
}
818
814
}
819
815
820
- impl fmt:: Display for ValidityConstraint {
816
+ impl fmt:: Display for PlaceValidity {
821
817
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
822
818
let s = match self {
823
819
ValidOnly => "✓" ,
@@ -836,7 +832,7 @@ struct PlaceInfo<Cx: TypeCx> {
836
832
/// so that we don't observe its emptiness.
837
833
private_uninhabited : bool ,
838
834
/// Whether the place is known to contain valid data.
839
- validity : ValidityConstraint ,
835
+ validity : PlaceValidity ,
840
836
/// Whether the place is the scrutinee itself or a subplace of it.
841
837
is_scrutinee : bool ,
842
838
}
@@ -1155,11 +1151,7 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
1155
1151
}
1156
1152
1157
1153
/// Build a new matrix from an iterator of `MatchArm`s.
1158
- fn new (
1159
- arms : & [ MatchArm < ' p , Cx > ] ,
1160
- scrut_ty : Cx :: Ty ,
1161
- scrut_validity : ValidityConstraint ,
1162
- ) -> Self {
1154
+ fn new ( arms : & [ MatchArm < ' p , Cx > ] , scrut_ty : Cx :: Ty , scrut_validity : PlaceValidity ) -> Self {
1163
1155
let place_info = PlaceInfo {
1164
1156
ty : scrut_ty,
1165
1157
private_uninhabited : false ,
@@ -1754,7 +1746,7 @@ pub fn compute_match_usefulness<'p, Cx: TypeCx>(
1754
1746
tycx : & Cx ,
1755
1747
arms : & [ MatchArm < ' p , Cx > ] ,
1756
1748
scrut_ty : Cx :: Ty ,
1757
- scrut_validity : ValidityConstraint ,
1749
+ scrut_validity : PlaceValidity ,
1758
1750
complexity_limit : Option < usize > ,
1759
1751
) -> Result < UsefulnessReport < ' p , Cx > , Cx :: Error > {
1760
1752
let mut cx = UsefulnessCtxt {
0 commit comments