@@ -31,7 +31,7 @@ fn get_some(cx: &LateContext<'_>, pat: &Pat<'_>) -> Option<HirId> {
31
31
}
32
32
}
33
33
34
- fn get_none < ' tcx > ( cx : & LateContext < ' _ > , arm : & Arm < ' tcx > ) -> Option < & ' tcx Expr < ' tcx > > {
34
+ fn get_none < ' tcx > ( cx : & LateContext < ' _ > , arm : & Arm < ' tcx > , allow_wildcard : bool ) -> Option < & ' tcx Expr < ' tcx > > {
35
35
if let PatKind :: Expr ( PatExpr { kind : PatExprKind :: Path ( QPath :: Resolved ( _, path) ) , .. } ) = arm. pat . kind
36
36
&& let Some ( def_id) = path. res . opt_def_id ( )
37
37
// Since it comes from a pattern binding, we need to get the parent to actually match
@@ -48,7 +48,7 @@ fn get_none<'tcx>(cx: &LateContext<'_>, arm: &Arm<'tcx>) -> Option<&'tcx Expr<'t
48
48
&& cx. tcx . lang_items ( ) . get ( LangItem :: ResultErr ) == Some ( def_id)
49
49
{
50
50
Some ( arm. body )
51
- } else if let PatKind :: Wild = arm. pat . kind {
51
+ } else if let ( PatKind :: Wild , true ) = ( arm. pat . kind , allow_wildcard ) {
52
52
// We consider that the `Some` check will filter it out if it's not right.
53
53
Some ( arm. body )
54
54
} else {
@@ -62,11 +62,11 @@ fn get_some_and_none_bodies<'tcx>(
62
62
arm2 : & ' tcx Arm < ' tcx > ,
63
63
) -> Option < ( ( & ' tcx Expr < ' tcx > , HirId ) , & ' tcx Expr < ' tcx > ) > {
64
64
if let Some ( binding_id) = get_some ( cx, arm1. pat )
65
- && let Some ( body_none) = get_none ( cx, arm2)
65
+ && let Some ( body_none) = get_none ( cx, arm2, true )
66
66
{
67
67
Some ( ( ( arm1. body , binding_id) , body_none) )
68
68
} else if let Some ( binding_id) = get_some ( cx, arm2. pat )
69
- && let Some ( body_none) = get_none ( cx, arm1)
69
+ && let Some ( body_none) = get_none ( cx, arm1, false )
70
70
{
71
71
Some ( ( ( arm2. body , binding_id) , body_none) )
72
72
} else {
0 commit comments