From db41df112aded9ecbbbba421189f28f6eb326554 Mon Sep 17 00:00:00 2001 From: tamaron Date: Thu, 19 May 2022 18:58:59 +0900 Subject: [PATCH] fix --- clippy_utils/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index b3ecc4255a9..8f9e687fb6a 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -2153,8 +2153,8 @@ pub fn is_in_cfg_test(tcx: TyCtxt<'_>, id: hir::HirId) -> bool { fn is_cfg_test(attr: &Attribute) -> bool { if attr.has_name(sym::cfg) && let Some(items) = attr.meta_item_list() - && items.len() == 1 - && items[0].has_name(sym::test) + && let [item] = &*items + && item.has_name(sym::test) { true } else { @@ -2163,7 +2163,8 @@ pub fn is_in_cfg_test(tcx: TyCtxt<'_>, id: hir::HirId) -> bool { } tcx.hir() .parent_iter(id) - .any(|(parent_id, _)| tcx.hir().attrs(parent_id).iter().any(is_cfg_test)) + .flat_map(|(parent_id, _)| tcx.hir().attrs(parent_id)) + .any(is_cfg_test) } /// Checks whether item either has `test` attribute applied, or