|
1 | | -use std::ops::ControlFlow; |
2 | | - |
3 | 1 | use clippy_utils::diagnostics::span_lint_and_sugg; |
4 | | -use clippy_utils::peel_blocks; |
5 | 2 | use clippy_utils::source::{snippet, walk_span_to_context}; |
6 | 3 | use clippy_utils::ty::implements_trait; |
7 | | -use clippy_utils::visitors::for_each_expr_without_closures; |
| 4 | +use clippy_utils::{desugar_await, peel_blocks}; |
8 | 5 | use rustc_errors::Applicability; |
9 | | -use rustc_hir::{ |
10 | | - Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, MatchSource, |
11 | | -}; |
| 6 | +use rustc_hir::{Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind}; |
12 | 7 | use rustc_lint::{LateContext, LateLintPass}; |
13 | 8 | use rustc_middle::ty::UpvarCapture; |
14 | 9 | use rustc_session::declare_lint_pass; |
@@ -99,20 +94,3 @@ fn desugar_async_block<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Op |
99 | 94 | None |
100 | 95 | } |
101 | 96 | } |
102 | | - |
103 | | -/// If `expr` is a desugared `.await`, return the original expression if it does not come from a |
104 | | -/// macro expansion. |
105 | | -fn desugar_await<'tcx>(expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> { |
106 | | - if let ExprKind::Match(match_value, _, MatchSource::AwaitDesugar) = expr.kind |
107 | | - && let ExprKind::Call(_, [into_future_arg]) = match_value.kind |
108 | | - && let ctxt = expr.span.ctxt() |
109 | | - && for_each_expr_without_closures(into_future_arg, |e| { |
110 | | - walk_span_to_context(e.span, ctxt).map_or(ControlFlow::Break(()), |_| ControlFlow::Continue(())) |
111 | | - }) |
112 | | - .is_none() |
113 | | - { |
114 | | - Some(into_future_arg) |
115 | | - } else { |
116 | | - None |
117 | | - } |
118 | | -} |
0 commit comments