@@ -589,8 +589,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
589
589
// away.)
590
590
let ( match_pair_index, match_pair) =
591
591
candidate. match_pairs . iter ( ) . enumerate ( ) . find ( |& ( _, mp) | mp. place == * test_place) ?;
592
- let mut fully_matched = false ;
593
592
593
+ let fully_matched;
594
594
let ret = match ( & test. kind , & match_pair. pattern . kind ) {
595
595
// If we are performing a variant switch, then this
596
596
// informs variant patterns, but nothing else.
@@ -602,8 +602,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
602
602
fully_matched = true ;
603
603
Some ( variant_index. as_usize ( ) )
604
604
}
605
-
606
- ( & TestKind :: Switch { .. } , _) => None ,
605
+ ( & TestKind :: Switch { .. } , _) => {
606
+ fully_matched = false ;
607
+ None
608
+ }
607
609
608
610
// If we are performing a switch over integers, then this informs integer
609
611
// equality, but nothing else.
@@ -617,8 +619,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
617
619
let index = options. get_index_of ( value) . unwrap ( ) ;
618
620
Some ( index)
619
621
}
620
-
621
622
( TestKind :: SwitchInt { switch_ty : _, options } , PatKind :: Range ( range) ) => {
623
+ fully_matched = false ;
622
624
let not_contained =
623
625
self . values_not_contained_in_range ( & * range, options) . unwrap_or ( false ) ;
624
626
@@ -628,8 +630,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
628
630
options. len ( )
629
631
} )
630
632
}
631
-
632
- ( & TestKind :: SwitchInt { .. } , _) => None ,
633
+ ( & TestKind :: SwitchInt { .. } , _) => {
634
+ fully_matched = false ;
635
+ None
636
+ }
633
637
634
638
(
635
639
& TestKind :: Len { len : test_len, op : BinOp :: Eq } ,
@@ -647,21 +651,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
647
651
// test_len < pat_len. If $actual_len = test_len,
648
652
// then $actual_len < pat_len and we don't have
649
653
// enough elements.
654
+ fully_matched = false ;
650
655
Some ( 1 )
651
656
}
652
657
( Ordering :: Equal | Ordering :: Greater , & Some ( _) ) => {
653
658
// This can match both if $actual_len = test_len >= pat_len,
654
659
// and if $actual_len > test_len. We can't advance.
660
+ fully_matched = false ;
655
661
None
656
662
}
657
663
( Ordering :: Greater , & None ) => {
658
664
// test_len != pat_len, so if $actual_len = test_len, then
659
665
// $actual_len != pat_len.
666
+ fully_matched = false ;
660
667
Some ( 1 )
661
668
}
662
669
}
663
670
}
664
-
665
671
(
666
672
& TestKind :: Len { len : test_len, op : BinOp :: Ge } ,
667
673
PatKind :: Slice { prefix, slice, suffix } ,
@@ -679,16 +685,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
679
685
// test_len <= pat_len. If $actual_len < test_len,
680
686
// then it is also < pat_len, so the test passing is
681
687
// necessary (but insufficient).
688
+ fully_matched = false ;
682
689
Some ( 0 )
683
690
}
684
691
( Ordering :: Greater , & None ) => {
685
692
// test_len > pat_len. If $actual_len >= test_len > pat_len,
686
693
// then we know we won't have a match.
694
+ fully_matched = false ;
687
695
Some ( 1 )
688
696
}
689
697
( Ordering :: Greater , & Some ( _) ) => {
690
698
// test_len < pat_len, and is therefore less
691
699
// strict. This can still go both ways.
700
+ fully_matched = false ;
692
701
None
693
702
}
694
703
}
@@ -699,13 +708,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
699
708
fully_matched = true ;
700
709
Some ( 0 )
701
710
} else {
711
+ fully_matched = false ;
702
712
// If the testing range does not overlap with pattern range,
703
713
// the pattern can be matched only if this test fails.
704
714
if !test. overlaps ( pat, self . tcx , self . param_env ) ? { Some ( 1 ) } else { None }
705
715
}
706
716
}
707
-
708
717
( TestKind :: Range ( range) , & PatKind :: Constant { value } ) => {
718
+ fully_matched = false ;
709
719
if !range. contains ( value, self . tcx , self . param_env ) ? {
710
720
// `value` is not contained in the testing range,
711
721
// so `value` can be matched only if this test fails.
@@ -714,8 +724,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
714
724
None
715
725
}
716
726
}
717
-
718
- ( & TestKind :: Range { .. } , _) => None ,
727
+ ( & TestKind :: Range { .. } , _) => {
728
+ fully_matched = false ;
729
+ None
730
+ }
719
731
720
732
( & TestKind :: Eq { .. } | & TestKind :: Len { .. } , _) => {
721
733
// 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> {
737
749
fully_matched = true ;
738
750
Some ( 0 )
739
751
} else {
752
+ fully_matched = false ;
740
753
None
741
754
}
742
755
}
0 commit comments