@@ -848,9 +848,9 @@ fn check_single_match_opt_like(
848
848
( & paths:: RESULT , "Ok" ) ,
849
849
] ;
850
850
851
- // We want to suggest to exclude an arm that contains only wildcards or forms the ehaustive
852
- // match with the second branch.
853
- if !contains_only_wilds ( arms[ 1 ] . pat ) && !form_exhaustive_tuples ( arms[ 0 ] . pat , arms[ 1 ] . pat ) {
851
+ // We want to suggest to exclude an arm that contains only wildcards or forms the exhaustive
852
+ // match with the second branch, without enum variants in matches .
853
+ if !contains_only_wilds ( arms[ 1 ] . pat ) && !form_exhaustive_matches ( arms[ 0 ] . pat , arms[ 1 ] . pat ) {
854
854
return ;
855
855
}
856
856
@@ -907,30 +907,30 @@ fn contains_only_wilds(pat: &Pat<'_>) -> bool {
907
907
}
908
908
}
909
909
910
- /// Returns true if the given patterns form the tuples that exhaustively matches all possible
911
- /// parameters .
910
+ /// Returns true if the given patterns forms only exhaustive matches that don't contain enum
911
+ /// patterns without a wildcard .
912
912
///
913
- /// Here are some examples :
913
+ /// For example :
914
914
///
915
915
/// ```
916
- /// // Doesn't form exhaustive match , because the first arm may contain not only E::V .
916
+ /// // Returns false , because the first arm contain enum without a wildcard .
917
917
/// match x {
918
918
/// (Some(E::V), _) => todo!(),
919
919
/// (None, _) => {}
920
920
/// }
921
921
///
922
- /// // Forms exhaustive match , because the patterns cover all possible cases at the same positions .
922
+ /// // Returns true , because the both arms form exhaustive matches and without enum variants .
923
923
/// match x {
924
924
/// (Some(_), _) => todo!(),
925
925
/// (None, _) => {}
926
926
/// }
927
927
/// ```
928
- fn form_exhaustive_tuples ( left : & Pat < ' _ > , right : & Pat < ' _ > ) -> bool {
928
+ fn form_exhaustive_matches ( left : & Pat < ' _ > , right : & Pat < ' _ > ) -> bool {
929
929
match ( & left. kind , & right. kind ) {
930
930
( PatKind :: Wild , _) | ( _, PatKind :: Wild ) => true ,
931
931
( PatKind :: Tuple ( left_in, left_pos) , PatKind :: Tuple ( right_in, right_pos) ) => {
932
- // We don't actually know the position and presence of the `..` (dotdot) operator in
933
- // the arms, so we need to evaluate the correct offsets here in order to iterate in
932
+ // We don't actually know the position and the presence of the `..` (dotdot) operator
933
+ // in the arms, so we need to evaluate the correct offsets here in order to iterate in
934
934
// both arms at the same time.
935
935
let len = max (
936
936
left_in. len ( ) + {
0 commit comments