From 509b9478f58582d8ddca1e2a31436e487b74fae5 Mon Sep 17 00:00:00 2001 From: Bryan Garza <1396101+bryangarza@users.noreply.github.com> Date: Thu, 10 Nov 2022 00:13:48 +0000 Subject: [PATCH] Refactor nested for-loops into find() calls --- compiler/rustc_ast_lowering/src/expr.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 6f68f679cc00..12930fd13636 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -617,18 +617,11 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::ExprKind::Closure(c) }; - let mut parent_has_track_caller = false; - for attrs in self.attrs.values() { - for attr in attrs.into_iter() { - if attr.has_name(sym::track_caller) { - parent_has_track_caller = true; - break; - } - } - if parent_has_track_caller { - break; - } - } + let parent_has_track_caller = self + .attrs + .values() + .find(|attrs| attrs.into_iter().find(|attr| attr.has_name(sym::track_caller)).is_some()) + .is_some(); let unstable_span = self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());