@@ -717,29 +717,46 @@ pub struct MatchPair<'pat, 'tcx: 'pat> {
717717
718718#[ derive( Clone , Debug , PartialEq ) ]
719719enum TestKind < ' tcx > {
720- // test the branches of enum
720+ /// Test the branches of enum.
721721 Switch {
722+ /// The enum being tested
722723 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.
723726 variants : BitSet < VariantIdx > ,
724727 } ,
725728
726- // test the branches of enum
729+ /// Test what value an `integer`, `bool` or `char` has.
727730 SwitchInt {
731+ /// The type of the value that we're testing.
728732 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`.
729741 options : Vec < u128 > ,
742+ /// Reverse map used to ensure that the values in `options` are unique.
730743 indices : FxHashMap < & ' tcx ty:: Const < ' tcx > , usize > ,
731744 } ,
732745
733- // test for equality
746+ /// Test for equality with value, possibly after an unsizing coercion to
747+ /// `ty`,
734748 Eq {
735749 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`.
736753 ty : Ty < ' tcx > ,
737754 } ,
738755
739- // test whether the value falls within an inclusive or exclusive range
756+ /// Test whether the value falls within an inclusive or exclusive range
740757 Range ( PatternRange < ' tcx > ) ,
741758
742- // test length of the slice is equal to len
759+ /// Test length of the slice is equal to len
743760 Len {
744761 len : u64 ,
745762 op : BinOp ,
0 commit comments