|
1 | | -use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; |
| 1 | +use clippy_utils::diagnostics::span_lint_and_sugg; |
2 | 2 | use clippy_utils::source::snippet_block_with_applicability; |
3 | | -use clippy_utils::ty::implements_trait; |
4 | | -use clippy_utils::visitors::{for_each_expr_without_closures, Descend}; |
5 | | -use clippy_utils::{get_parent_expr, higher, is_from_proc_macro}; |
6 | | -use core::ops::ControlFlow; |
| 3 | +use clippy_utils::{higher, is_from_proc_macro}; |
7 | 4 | use rustc_errors::Applicability; |
8 | 5 | use rustc_hir::{BlockCheckMode, Expr, ExprKind, MatchSource}; |
9 | 6 | use rustc_lint::{LateContext, LateLintPass, LintContext}; |
10 | 7 | use rustc_middle::lint::in_external_macro; |
11 | 8 | use rustc_session::declare_lint_pass; |
12 | | -use rustc_span::sym; |
13 | 9 |
|
14 | 10 | declare_clippy_lint! { |
15 | 11 | /// ### What it does |
@@ -124,30 +120,6 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions { |
124 | 120 | ); |
125 | 121 | } |
126 | 122 | } |
127 | | - } else { |
128 | | - let _: Option<!> = for_each_expr_without_closures(cond, |e| { |
129 | | - if let ExprKind::Closure(closure) = e.kind { |
130 | | - // do not lint if the closure is called using an iterator (see #1141) |
131 | | - if let Some(parent) = get_parent_expr(cx, e) |
132 | | - && let ExprKind::MethodCall(_, self_arg, _, _) = &parent.kind |
133 | | - && let caller = cx.typeck_results().expr_ty(self_arg) |
134 | | - && let Some(iter_id) = cx.tcx.get_diagnostic_item(sym::Iterator) |
135 | | - && implements_trait(cx, caller, iter_id, &[]) |
136 | | - { |
137 | | - return ControlFlow::Continue(Descend::No); |
138 | | - } |
139 | | - |
140 | | - let body = cx.tcx.hir().body(closure.body); |
141 | | - let ex = &body.value; |
142 | | - if let ExprKind::Block(block, _) = ex.kind { |
143 | | - if !body.value.span.from_expansion() && !block.stmts.is_empty() { |
144 | | - span_lint(cx, BLOCKS_IN_CONDITIONS, ex.span, complex_block_message.clone()); |
145 | | - return ControlFlow::Continue(Descend::No); |
146 | | - } |
147 | | - } |
148 | | - } |
149 | | - ControlFlow::Continue(Descend::Yes) |
150 | | - }); |
151 | 123 | } |
152 | 124 | } |
153 | 125 | } |
0 commit comments