@@ -156,23 +156,25 @@ declare_lint_pass!(CopyAndPaste => [
156
156
impl < ' tcx > LateLintPass < ' tcx > for CopyAndPaste {
157
157
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) {
158
158
if !expr. span . from_expansion ( ) {
159
- // skip ifs directly in else, it will be checked in the parent if
160
- if let Some ( & Expr {
161
- kind : ExprKind :: If ( _, _, Some ( ref else_expr) ) ,
162
- ..
163
- } ) = get_parent_expr ( cx, expr)
164
- {
165
- if else_expr. hir_id == expr. hir_id {
166
- return ;
159
+ if let ExprKind :: If ( _, _, _) = expr. kind {
160
+ // skip ifs directly in else, it will be checked in the parent if
161
+ if let Some ( & Expr {
162
+ kind : ExprKind :: If ( _, _, Some ( ref else_expr) ) ,
163
+ ..
164
+ } ) = get_parent_expr ( cx, expr)
165
+ {
166
+ if else_expr. hir_id == expr. hir_id {
167
+ return ;
168
+ }
167
169
}
168
- }
169
170
170
- let ( conds, blocks) = if_sequence ( expr) ;
171
- // Conditions
172
- lint_same_cond ( cx, & conds) ;
173
- lint_same_fns_in_if_cond ( cx, & conds) ;
174
- // Block duplication
175
- lint_same_then_else ( cx, & blocks, conds. len ( ) != blocks. len ( ) , expr) ;
171
+ let ( conds, blocks) = if_sequence ( expr) ;
172
+ // Conditions
173
+ lint_same_cond ( cx, & conds) ;
174
+ lint_same_fns_in_if_cond ( cx, & conds) ;
175
+ // Block duplication
176
+ lint_same_then_else ( cx, & blocks, conds. len ( ) != blocks. len ( ) , expr) ;
177
+ }
176
178
}
177
179
}
178
180
}
0 commit comments