@@ -589,8 +589,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
589589 // away.)
590590 let ( match_pair_index, match_pair) =
591591 candidate. match_pairs . iter ( ) . enumerate ( ) . find ( |& ( _, mp) | mp. place == * test_place) ?;
592- let mut fully_matched = false ;
593592
593+ let fully_matched;
594594 let ret = match ( & test. kind , & match_pair. pattern . kind ) {
595595 // If we are performing a variant switch, then this
596596 // informs variant patterns, but nothing else.
@@ -602,8 +602,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
602602 fully_matched = true ;
603603 Some ( variant_index. as_usize ( ) )
604604 }
605-
606- ( & TestKind :: Switch { .. } , _) => None ,
605+ ( & TestKind :: Switch { .. } , _) => {
606+ fully_matched = false ;
607+ None
608+ }
607609
608610 // If we are performing a switch over integers, then this informs integer
609611 // equality, but nothing else.
@@ -617,8 +619,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
617619 let index = options. get_index_of ( value) . unwrap ( ) ;
618620 Some ( index)
619621 }
620-
621622 ( TestKind :: SwitchInt { switch_ty : _, options } , PatKind :: Range ( range) ) => {
623+ fully_matched = false ;
622624 let not_contained =
623625 self . values_not_contained_in_range ( & * range, options) . unwrap_or ( false ) ;
624626
@@ -628,8 +630,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
628630 options. len ( )
629631 } )
630632 }
631-
632- ( & TestKind :: SwitchInt { .. } , _) => None ,
633+ ( & TestKind :: SwitchInt { .. } , _) => {
634+ fully_matched = false ;
635+ None
636+ }
633637
634638 (
635639 & TestKind :: Len { len : test_len, op : BinOp :: Eq } ,
@@ -647,21 +651,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
647651 // test_len < pat_len. If $actual_len = test_len,
648652 // then $actual_len < pat_len and we don't have
649653 // enough elements.
654+ fully_matched = false ;
650655 Some ( 1 )
651656 }
652657 ( Ordering :: Equal | Ordering :: Greater , & Some ( _) ) => {
653658 // This can match both if $actual_len = test_len >= pat_len,
654659 // and if $actual_len > test_len. We can't advance.
660+ fully_matched = false ;
655661 None
656662 }
657663 ( Ordering :: Greater , & None ) => {
658664 // test_len != pat_len, so if $actual_len = test_len, then
659665 // $actual_len != pat_len.
666+ fully_matched = false ;
660667 Some ( 1 )
661668 }
662669 }
663670 }
664-
665671 (
666672 & TestKind :: Len { len : test_len, op : BinOp :: Ge } ,
667673 PatKind :: Slice { prefix, slice, suffix } ,
@@ -679,16 +685,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
679685 // test_len <= pat_len. If $actual_len < test_len,
680686 // then it is also < pat_len, so the test passing is
681687 // necessary (but insufficient).
688+ fully_matched = false ;
682689 Some ( 0 )
683690 }
684691 ( Ordering :: Greater , & None ) => {
685692 // test_len > pat_len. If $actual_len >= test_len > pat_len,
686693 // then we know we won't have a match.
694+ fully_matched = false ;
687695 Some ( 1 )
688696 }
689697 ( Ordering :: Greater , & Some ( _) ) => {
690698 // test_len < pat_len, and is therefore less
691699 // strict. This can still go both ways.
700+ fully_matched = false ;
692701 None
693702 }
694703 }
@@ -699,13 +708,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
699708 fully_matched = true ;
700709 Some ( 0 )
701710 } else {
711+ fully_matched = false ;
702712 // If the testing range does not overlap with pattern range,
703713 // the pattern can be matched only if this test fails.
704714 if !test. overlaps ( pat, self . tcx , self . param_env ) ? { Some ( 1 ) } else { None }
705715 }
706716 }
707-
708717 ( TestKind :: Range ( range) , & PatKind :: Constant { value } ) => {
718+ fully_matched = false ;
709719 if !range. contains ( value, self . tcx , self . param_env ) ? {
710720 // `value` is not contained in the testing range,
711721 // so `value` can be matched only if this test fails.
@@ -714,8 +724,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
714724 None
715725 }
716726 }
717-
718- ( & TestKind :: Range { .. } , _) => None ,
727+ ( & TestKind :: Range { .. } , _) => {
728+ fully_matched = false ;
729+ None
730+ }
719731
720732 ( & TestKind :: Eq { .. } | & TestKind :: Len { .. } , _) => {
721733 // The call to `self.test(&match_pair)` below is not actually used to generate any
@@ -737,6 +749,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
737749 fully_matched = true ;
738750 Some ( 0 )
739751 } else {
752+ fully_matched = false ;
740753 None
741754 }
742755 }
0 commit comments