@@ -715,29 +715,46 @@ pub struct MatchPair<'pat, 'tcx: 'pat> {
715715
716716#[ derive( Clone , Debug , PartialEq ) ]
717717enum TestKind < ' tcx > {
718- // test the branches of enum
718+ /// Test the branches of enum.
719719 Switch {
720+ /// The enum being tested
720721 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.
721724 variants : BitSet < VariantIdx > ,
722725 } ,
723726
724- // test the branches of enum
727+ /// Test what value an `integer`, `bool` or `char` has.
725728 SwitchInt {
729+ /// The type of the value that we're testing.
726730 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`.
727739 options : Vec < u128 > ,
740+ /// Reverse map used to ensure that the values in `options` are unique.
728741 indices : FxHashMap < & ' tcx ty:: Const < ' tcx > , usize > ,
729742 } ,
730743
731- // test for equality
744+ /// Test for equality with value, possibly after an unsizing coercion to
745+ /// `ty`,
732746 Eq {
733747 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`.
734751 ty : Ty < ' tcx > ,
735752 } ,
736753
737- // test whether the value falls within an inclusive or exclusive range
754+ /// Test whether the value falls within an inclusive or exclusive range
738755 Range ( PatternRange < ' tcx > ) ,
739756
740- // test length of the slice is equal to len
757+ /// Test length of the slice is equal to len
741758 Len {
742759 len : u64 ,
743760 op : BinOp ,
0 commit comments