@@ -715,29 +715,46 @@ pub struct MatchPair<'pat, 'tcx: 'pat> {
715
715
716
716
#[ derive( Clone , Debug , PartialEq ) ]
717
717
enum TestKind < ' tcx > {
718
- // test the branches of enum
718
+ /// Test the branches of enum.
719
719
Switch {
720
+ /// The enum being tested
720
721
adt_def : & ' tcx ty:: AdtDef ,
722
+ /// The set of variants that we should create a branch for. We also
723
+ /// create an additional "otherwise" case.
721
724
variants : BitSet < VariantIdx > ,
722
725
} ,
723
726
724
- // test the branches of enum
727
+ /// Test what value an `integer`, `bool` or `char` has.
725
728
SwitchInt {
729
+ /// The type of the value that we're testing.
726
730
switch_ty : Ty < ' tcx > ,
731
+ /// The (ordered) set of values that we test for.
732
+ ///
733
+ /// For integers and `char`s we create a branch to each of the values in
734
+ /// `options`, as well as an "otherwise" branch for all other values, even
735
+ /// in the (rare) case that options is exhaustive.
736
+ ///
737
+ /// For `bool` we always generate two edges, one for `true` and one for
738
+ /// `false`.
727
739
options : Vec < u128 > ,
740
+ /// Reverse map used to ensure that the values in `options` are unique.
728
741
indices : FxHashMap < & ' tcx ty:: Const < ' tcx > , usize > ,
729
742
} ,
730
743
731
- // test for equality
744
+ /// Test for equality with value, possibly after an unsizing coercion to
745
+ /// `ty`,
732
746
Eq {
733
747
value : & ' tcx ty:: Const < ' tcx > ,
748
+ // Integer types are handled by `SwitchInt`, and constants with ADT
749
+ // types are converted back into patterns, so this can only be `&str`,
750
+ // `&[T]`, `f32` or `f64`.
734
751
ty : Ty < ' tcx > ,
735
752
} ,
736
753
737
- // test whether the value falls within an inclusive or exclusive range
754
+ /// Test whether the value falls within an inclusive or exclusive range
738
755
Range ( PatternRange < ' tcx > ) ,
739
756
740
- // test length of the slice is equal to len
757
+ /// Test length of the slice is equal to len
741
758
Len {
742
759
len : u64 ,
743
760
op : BinOp ,
0 commit comments