@@ -105,7 +105,7 @@ declare_clippy_lint! {
105105}
106106
107107declare_clippy_lint ! {
108- /// **What it does:** Checks if the `if` and `else` block contain shared that can be
108+ /// **What it does:** Checks if the `if` and `else` block contain shared code that can be
109109 /// moved out of the blocks.
110110 ///
111111 /// **Why is this bad?** Duplicate code is less maintainable.
@@ -133,7 +133,7 @@ declare_clippy_lint! {
133133 /// };
134134 /// ```
135135 pub SHARED_CODE_IN_IF_BLOCKS ,
136- complexity ,
136+ pedantic ,
137137 "`if` statement with shared code in all blocks"
138138}
139139
@@ -172,14 +172,6 @@ fn lint_same_then_else(cx: &LateContext<'_>, blocks: &[&Block<'_>], has_uncondit
172172 }
173173 }
174174
175- fn min ( a : usize , b : usize ) -> usize {
176- if a < b {
177- a
178- } else {
179- b
180- }
181- }
182-
183175 fn lint_duplicate_code ( cx : & LateContext < ' _ > , position : & str , lint_start : Span , lint_end : Span ) {
184176 span_lint_and_help (
185177 cx,
@@ -232,9 +224,9 @@ fn lint_same_then_else(cx: &LateContext<'_>, blocks: &[&Block<'_>], has_uncondit
232224 return ;
233225 }
234226
235- start_eq = min ( start_eq , current_start_eq) ;
236- end_eq = min ( end_eq , current_end_eq) ;
237- expr_eq = expr_eq && block_expr_eq;
227+ start_eq = start_eq . min ( current_start_eq) ;
228+ end_eq = end_eq . min ( current_end_eq) ;
229+ expr_eq &= block_expr_eq;
238230
239231 // We can return if the eq count is 0 from both sides or if it has no unconditional else case
240232 if !has_unconditional_else || ( start_eq == 0 && end_eq == 0 && !( eval_expr && expr_eq) ) {
0 commit comments