pub fn test(&mut self, match_pair: &MatchPair<'tcx>) -> Test<'tcx> {
        match match_pair.pattern.kind {
            PatternKind::Variant { ref adt_def, variant_index: _, subpatterns: _ } => {
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::Switch { adt_def: adt_def.clone() },
                }
            }

            PatternKind::Constant { value: Literal::Value { .. } }
            if is_switch_ty(match_pair.pattern.ty) => {
                // for integers, we use a SwitchInt match, which allows
                // us to handle more cases
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::SwitchInt {
                        switch_ty: match_pair.pattern.ty,

                        // these maps are empty to start; cases are
                        // added below in add_cases_to_switch
                        options: vec![],
                        indices: FnvHashMap(),
                    }
                }
            }

            PatternKind::Constant { ref value } => {
                // for other types, we use an equality comparison
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::Eq {
                        value: value.clone(),
                        ty: match_pair.pattern.ty.clone(),
                    }
                }
            }

            PatternKind::Range { ref lo, ref hi } => {
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::Range {
                        lo: lo.clone(),
                        hi: hi.clone(),
                        ty: match_pair.pattern.ty.clone(),
                    },
                }
            }

            PatternKind::Slice { ref prefix, ref slice, ref suffix } => {
                let len = prefix.len() + suffix.len();
                let op = if slice.is_some() {
                    BinOp::Ge
                } else {
                    BinOp::Eq
                };
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::Len { len: len, op: op },
                }
            }

            PatternKind::Array { .. } |
            PatternKind::Wild |
            PatternKind::Binding { .. } |
            PatternKind::Leaf { .. } |
            PatternKind::Deref { .. } => {
                self.error_simplifyable(match_pair)
            }
        }
    }
/// Identifies what test is needed to decide if `match_pair` is applicable.
///
/// It is a bug to call this with a simplifyable pattern.
Identifies what test is needed to decide if `match_pair` is applicable.
It is a bug to call this with a simplifyable pattern.
Identifies what test is needed to decide if ` match_pair ` is applicable . It is a bug to call this with a simplifyable pattern .
pub fn test(&mut self, match_pair: &MatchPair<'tcx>) -> Test<'tcx> {
        match match_pair.pattern.kind {
            PatternKind::Variant { ref adt_def, variant_index: _, subpatterns: _ } => {
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::Switch { adt_def: adt_def.clone() },
                }
            }
            PatternKind::Constant { value: Literal::Value { .. } }
            if is_switch_ty(match_pair.pattern.ty) => {
                // for integers, we use a SwitchInt match, which allows
                // us to handle more cases
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::SwitchInt {
                        switch_ty: match_pair.pattern.ty,
                        // these maps are empty to start; cases are
                        // added below in add_cases_to_switch
                        options: vec![],
                        indices: FnvHashMap(),
                    }
                }
            }
            PatternKind::Constant { ref value } => {
                // for other types, we use an equality comparison
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::Eq {
                        value: value.clone(),
                        ty: match_pair.pattern.ty.clone(),
                    }
                }
            }
            PatternKind::Range { ref lo, ref hi } => {
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::Range {
                        lo: lo.clone(),
                        hi: hi.clone(),
                        ty: match_pair.pattern.ty.clone(),
                    },
                }
            }
            PatternKind::Slice { ref prefix, ref slice, ref suffix } => {
                let len = prefix.len() + suffix.len();
                let op = if slice.is_some() {
                    BinOp::Ge
                } else {
                    BinOp::Eq
                };
                Test {
                    span: match_pair.pattern.span,
                    kind: TestKind::Len { len: len, op: op },
                }
            }
            PatternKind::Array { .. } |
            PatternKind::Wild |
            PatternKind::Binding { .. } |
            PatternKind::Leaf { .. } |
            PatternKind::Deref { .. } => {
                self.error_simplifyable(match_pair)
            }
        }
    }
pub fn test ( & mut self , match_pair : & MatchPair < ' tcx > ) -> Test < ' tcx > { match match_pair . pattern . kind { PatternKind :: Variant { ref adt_def , variant_index : _ , subpatterns : _ } => { Test { span : match_pair . pattern . span , kind : TestKind :: Switch { adt_def : adt_def . clone ( ) } , } } PatternKind :: Constant { value : Literal :: Value { .. } } if is_switch_ty ( match_pair . pattern . ty ) => { // for integers, we use a SwitchInt match, which allows // us to handle more cases Test { span : match_pair . pattern . span , kind : TestKind :: SwitchInt { switch_ty : match_pair . pattern . ty , // these maps are empty to start; cases are // added below in add_cases_to_switch options : vec ! [ ] , indices : FnvHashMap ( ) , } } } PatternKind :: Constant { ref value } => { // for other types, we use an equality comparison Test { span : match_pair . pattern . span , kind : TestKind :: Eq { value : value . clone ( ) , ty : match_pair . pattern . ty . clone ( ) , } } } PatternKind :: Range { ref lo , ref hi } => { Test { span : match_pair . pattern . span , kind : TestKind :: Range { lo : lo . clone ( ) , hi : hi . clone ( ) , ty : match_pair . pattern . ty . clone ( ) , } , } } PatternKind :: Slice { ref prefix , ref slice , ref suffix } => { let len = prefix . len ( ) + suffix . len ( ) ; let op = if slice . is_some ( ) { BinOp :: Ge } else { BinOp :: Eq } ; Test { span : match_pair . pattern . span , kind : TestKind :: Len { len : len , op : op } , } } PatternKind :: Array { .. } | PatternKind :: Wild | PatternKind :: Binding { .. } | PatternKind :: Leaf { .. } | PatternKind :: Deref { .. } => { self . error_simplifyable ( match_pair ) } } }
Identifies what test is needed to decide if `match_pair` is applicable.
Identifies what test is needed to decide if ` match_pair ` is applicable .
&mut self
match_pair
&MatchPair<'tcx>