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