203
203
//! before.
204
204
//! That's almost correct, but only works if there were no wildcards in those first
205
205
//! components. So we need to check that `p` is useful with respect to the rows that
206
- //! start with a wildcard, if there are any. This is where `D ` comes in:
206
+ //! start with a wildcard, if there are any. This is where `S(_, x) ` comes in:
207
207
//! `U(P, p) := U(S(_, P), S(_, p))`
208
208
//!
209
209
//! For example, if `P` is:
@@ -634,8 +634,8 @@ impl Slice {
634
634
}
635
635
636
636
/// The exhaustiveness-checking paper does not include any details on
637
- /// checking variable-length slice patterns. However, they are matched
638
- /// by an infinite collection of fixed-length array patterns.
637
+ /// checking variable-length slice patterns. However, they may be
638
+ /// matched by an infinite collection of fixed-length array patterns.
639
639
///
640
640
/// Checking the infinite set directly would take an infinite amount
641
641
/// of time. However, it turns out that for each finite set of
@@ -646,11 +646,11 @@ impl Slice {
646
646
/// `sₘ` for each sufficiently-large length `m` that applies to exactly
647
647
/// the same subset of `P`.
648
648
///
649
- /// Because of that, each witness for reachability-checking from one
649
+ /// Because of that, each witness for reachability-checking of one
650
650
/// of the sufficiently-large lengths can be transformed to an
651
- /// equally-valid witness from any other length, so we only have
652
- /// to check slice lengths from the "minimal sufficiently-large length"
653
- /// and below .
651
+ /// equally-valid witness of any other length, so we only have
652
+ /// to check slices of the "minimal sufficiently-large length"
653
+ /// and less .
654
654
///
655
655
/// Note that the fact that there is a *single* `sₘ` for each `m`
656
656
/// not depending on the specific pattern in `P` is important: if
@@ -659,8 +659,8 @@ impl Slice {
659
659
/// `[.., false]`
660
660
/// Then any slice of length ≥1 that matches one of these two
661
661
/// patterns can be trivially turned to a slice of any
662
- /// other length ≥1 that matches them and vice-versa - for
663
- /// but the slice from length 2 `[false, true]` that matches neither
662
+ /// other length ≥1 that matches them and vice-versa,
663
+ /// but the slice of length 2 `[false, true]` that matches neither
664
664
/// of these patterns can't be turned to a slice from length 1 that
665
665
/// matches neither of these patterns, so we have to consider
666
666
/// slices from length 2 there.
@@ -787,7 +787,7 @@ enum Constructor<'tcx> {
787
787
Opaque ,
788
788
/// Fake extra constructor for enums that aren't allowed to be matched exhaustively.
789
789
NonExhaustive ,
790
- /// Fake constructor for those types for which we can't list constructors explicitely , like
790
+ /// Fake constructor for those types for which we can't list constructors explicitly , like
791
791
/// `f64` and `&str`.
792
792
Unlistable ,
793
793
/// Wildcard pattern.
@@ -796,13 +796,10 @@ enum Constructor<'tcx> {
796
796
797
797
impl < ' tcx > Constructor < ' tcx > {
798
798
fn is_wildcard ( & self ) -> bool {
799
- match self {
800
- Wildcard => true ,
801
- _ => false ,
802
- }
799
+ matches ! ( self , Wildcard )
803
800
}
804
801
805
- fn as_intrange ( & self ) -> Option < & IntRange < ' tcx > > {
802
+ fn as_int_range ( & self ) -> Option < & IntRange < ' tcx > > {
806
803
match self {
807
804
IntRange ( range) => Some ( range) ,
808
805
_ => None ,
@@ -827,7 +824,7 @@ impl<'tcx> Constructor<'tcx> {
827
824
}
828
825
}
829
826
830
- /// Some constructors (namely Wildcard, IntRange and Slice) actually stand for a set of actual
827
+ /// Some constructors (namely ` Wildcard`, ` IntRange` and ` Slice` ) actually stand for a set of actual
831
828
/// constructors (like variants, integers or fixed-sized slices). When specializing for these
832
829
/// constructors, we want to be specialising for the actual underlying constructors.
833
830
/// Naively, we would simply return the list of constructors they correspond to. We instead are
@@ -863,8 +860,8 @@ impl<'tcx> Constructor<'tcx> {
863
860
864
861
/// For wildcards, there are two groups of constructors: there are the constructors actually
865
862
/// present in the matrix (`head_ctors`), and the constructors not present (`missing_ctors`).
866
- /// Two constructors that are not in the matrix will either both be catched (by a wildcard), or
867
- /// both not be catched . Therefore we can keep the missing constructors grouped together.
863
+ /// Two constructors that are not in the matrix will either both be caught (by a wildcard), or
864
+ /// both not be caught . Therefore we can keep the missing constructors grouped together.
868
865
fn split_wildcard < ' p > ( pcx : PatCtxt < ' _ , ' p , ' tcx > ) -> SmallVec < [ Self ; 1 ] > {
869
866
// Missing constructors are those that are not matched by any non-wildcard patterns in the
870
867
// current column. We only fully construct them on-demand, because they're rarely used and
@@ -882,8 +879,8 @@ impl<'tcx> Constructor<'tcx> {
882
879
}
883
880
}
884
881
885
- /// Returns whether `self` is covered by `other`, ie whether `self` is a subset of `other`. For
886
- /// the simple cases, this is simply checking for equality. For the "grouped" constructors,
882
+ /// Returns whether `self` is covered by `other`, i.e. whether `self` is a subset of `other`.
883
+ /// For the simple cases, this is simply checking for equality. For the "grouped" constructors,
887
884
/// this checks for inclusion.
888
885
fn is_covered_by < ' p > ( & self , pcx : PatCtxt < ' _ , ' p , ' tcx > , other : & Self ) -> bool {
889
886
match ( self , other) {
@@ -955,7 +952,7 @@ impl<'tcx> Constructor<'tcx> {
955
952
Variant ( _) => used_ctors. iter ( ) . any ( |c| c == self ) ,
956
953
IntRange ( range) => used_ctors
957
954
. iter ( )
958
- . filter_map ( |c| c. as_intrange ( ) )
955
+ . filter_map ( |c| c. as_int_range ( ) )
959
956
. any ( |other| range. is_covered_by ( pcx, other) ) ,
960
957
Slice ( slice) => used_ctors
961
958
. iter ( )
@@ -1601,7 +1598,7 @@ fn all_constructors<'p, 'tcx>(pcx: PatCtxt<'_, 'p, 'tcx>) -> Vec<Constructor<'tc
1601
1598
_ if cx. is_uninhabited ( pcx. ty ) => vec ! [ ] ,
1602
1599
ty:: Adt ( ..) | ty:: Tuple ( ..) => vec ! [ Single ] ,
1603
1600
ty:: Ref ( _, t, _) if !t. is_str ( ) => vec ! [ Single ] ,
1604
- // This type is one for which we don't know how to list constructors, like &str of f64.
1601
+ // This type is one for which we don't know how to list constructors, like ` &str` or ` f64` .
1605
1602
_ => vec ! [ Unlistable ] ,
1606
1603
}
1607
1604
}
@@ -1851,7 +1848,7 @@ impl<'tcx> IntRange<'tcx> {
1851
1848
let row_borders = pcx
1852
1849
. matrix
1853
1850
. head_ctors ( pcx. cx )
1854
- . filter_map ( |ctor| ctor. as_intrange ( ) )
1851
+ . filter_map ( |ctor| ctor. as_int_range ( ) )
1855
1852
. filter_map ( |range| {
1856
1853
let intersection = self . intersection ( pcx. cx . tcx , & range) ;
1857
1854
let should_lint = self . suspicious_intersection ( & range) ;
0 commit comments