@@ -105,7 +105,7 @@ declare_clippy_lint! {
105
105
}
106
106
107
107
declare_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
109
109
/// moved out of the blocks.
110
110
///
111
111
/// **Why is this bad?** Duplicate code is less maintainable.
@@ -133,7 +133,7 @@ declare_clippy_lint! {
133
133
/// };
134
134
/// ```
135
135
pub SHARED_CODE_IN_IF_BLOCKS ,
136
- complexity ,
136
+ pedantic ,
137
137
"`if` statement with shared code in all blocks"
138
138
}
139
139
@@ -172,14 +172,6 @@ fn lint_same_then_else(cx: &LateContext<'_>, blocks: &[&Block<'_>], has_uncondit
172
172
}
173
173
}
174
174
175
- fn min ( a : usize , b : usize ) -> usize {
176
- if a < b {
177
- a
178
- } else {
179
- b
180
- }
181
- }
182
-
183
175
fn lint_duplicate_code ( cx : & LateContext < ' _ > , position : & str , lint_start : Span , lint_end : Span ) {
184
176
span_lint_and_help (
185
177
cx,
@@ -232,9 +224,9 @@ fn lint_same_then_else(cx: &LateContext<'_>, blocks: &[&Block<'_>], has_uncondit
232
224
return ;
233
225
}
234
226
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;
238
230
239
231
// We can return if the eq count is 0 from both sides or if it has no unconditional else case
240
232
if !has_unconditional_else || ( start_eq == 0 && end_eq == 0 && !( eval_expr && expr_eq) ) {
0 commit comments