@@ -74,7 +74,7 @@ fn check_all_arms(cx: &LateContext<'_>, match_expr: &Expr<'_>, arms: &[Arm<'_>])
7474 }
7575
7676 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) {
7878 return false ;
7979 }
8080 } 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
103103 if matches ! ( else_expr. kind, ExprKind :: Block ( ..) ) {
104104 return false ;
105105 }
106- let ret = strip_return ( else_expr) ;
107106 let let_expr_ty = cx. typeck_results ( ) . expr_ty ( if_let. let_expr ) ;
108107 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) ;
110110 }
111- return eq_expr_value ( cx, if_let. let_expr , ret ) ;
111+ return eq_expr_value ( cx, if_let. let_expr , else_expr ) ;
112112 }
113113 }
114114
115115 false
116116}
117117
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-
127118/// Manually check for coercion casting by checking if the type of the match operand or let expr
128119/// differs with the assigned local variable or the function return type.
129120fn 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<'_>
161152}
162153
163154fn pat_same_as_expr ( pat : & Pat < ' _ > , expr : & Expr < ' _ > ) -> bool {
164- let expr = strip_return ( expr) ;
165155 match ( & pat. kind , & expr. kind ) {
166156 // Example: `Some(val) => Some(val)`
167157 ( PatKind :: TupleStruct ( QPath :: Resolved ( _, path) , tuple_params, _) , ExprKind :: Call ( call_expr, call_params) ) => {
0 commit comments