@@ -74,7 +74,7 @@ fn check_all_arms(cx: &LateContext<'_>, match_expr: &Expr<'_>, arms: &[Arm<'_>])
74
74
}
75
75
76
76
if let PatKind :: Wild = arm. pat . kind {
77
- if !eq_expr_value ( cx, match_expr, strip_return ( arm_expr) ) {
77
+ if !eq_expr_value ( cx, match_expr, arm_expr) {
78
78
return false ;
79
79
}
80
80
} else if !pat_same_as_expr ( arm. pat , arm_expr) {
@@ -103,27 +103,18 @@ fn check_if_let_inner(cx: &LateContext<'_>, if_let: &higher::IfLet<'_>) -> bool
103
103
if matches ! ( else_expr. kind, ExprKind :: Block ( ..) ) {
104
104
return false ;
105
105
}
106
- let ret = strip_return ( else_expr) ;
107
106
let let_expr_ty = cx. typeck_results ( ) . expr_ty ( if_let. let_expr ) ;
108
107
if is_type_diagnostic_item ( cx, let_expr_ty, sym:: Option ) {
109
- return is_res_lang_ctor ( cx, path_res ( cx, ret) , OptionNone ) || eq_expr_value ( cx, if_let. let_expr , ret) ;
108
+ return is_res_lang_ctor ( cx, path_res ( cx, else_expr) , OptionNone )
109
+ || eq_expr_value ( cx, if_let. let_expr , else_expr) ;
110
110
}
111
- return eq_expr_value ( cx, if_let. let_expr , ret ) ;
111
+ return eq_expr_value ( cx, if_let. let_expr , else_expr ) ;
112
112
}
113
113
}
114
114
115
115
false
116
116
}
117
117
118
- /// Strip `return` keyword if the expression type is `ExprKind::Ret`.
119
- fn strip_return < ' hir > ( expr : & ' hir Expr < ' hir > ) -> & ' hir Expr < ' hir > {
120
- if let ExprKind :: Ret ( Some ( ret) ) = expr. kind {
121
- ret
122
- } else {
123
- expr
124
- }
125
- }
126
-
127
118
/// Manually check for coercion casting by checking if the type of the match operand or let expr
128
119
/// differs with the assigned local variable or the function return type.
129
120
fn expr_ty_matches_p_ty ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > , p_expr : & Expr < ' _ > ) -> bool {
@@ -161,7 +152,6 @@ fn expr_ty_matches_p_ty(cx: &LateContext<'_>, expr: &Expr<'_>, p_expr: &Expr<'_>
161
152
}
162
153
163
154
fn pat_same_as_expr ( pat : & Pat < ' _ > , expr : & Expr < ' _ > ) -> bool {
164
- let expr = strip_return ( expr) ;
165
155
match ( & pat. kind , & expr. kind ) {
166
156
// Example: `Some(val) => Some(val)`
167
157
( PatKind :: TupleStruct ( QPath :: Resolved ( _, path) , tuple_params, _) , ExprKind :: Call ( call_expr, call_params) ) => {
0 commit comments