Skip to content

Commit 21748e9

Browse files
csmoexFrednet
andauthored
Update clippy_lints/src/large_futures.rs
Co-authored-by: Fridtjof Stoldt <[email protected]>
1 parent 4fdae81 commit 21748e9

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

clippy_lints/src/large_futures.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,15 @@ impl_lint_pass!(LargeFuture => [LARGE_FUTURES]);
6060
impl<'tcx> LateLintPass<'tcx> for LargeFuture {
6161
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
6262
if let ExprKind::Match(expr, _, MatchSource::AwaitDesugar) = expr.kind {
63-
if let ExprKind::Call(func, [expr, ..]) = expr.kind {
64-
if matches!(
65-
func.kind,
66-
ExprKind::Path(QPath::LangItem(LangItem::IntoFutureIntoFuture, ..))
67-
) {
68-
let ty = cx.typeck_results().expr_ty(expr);
69-
if let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait()
70-
&& implements_trait(cx, ty, future_trait_def_id, &[]) {
71-
if let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(ty)) {
72-
let size = layout.layout.size();
73-
if size >= Size::from_bytes(self.future_size_threshold) {
63+
if let ExprKind::Call(func, [expr, ..]) = expr.kind
64+
&& let ExprKind::Path(QPath::LangItem(LangItem::IntoFutureIntoFuture, ..)) = func.kind
65+
&& let ty = cx.typeck_results().expr_ty(expr)
66+
&& let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait()
67+
&& implements_trait(cx, ty, future_trait_def_id, &[])
68+
&& let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(ty))
69+
&& let size = layout.layout.size()
70+
&& size >= Size::from_bytes(self.future_size_threshold)
71+
{
7472
span_lint_and_sugg(
7573
cx,
7674
LARGE_FUTURES,

0 commit comments

Comments
 (0)