diff options
| author | tamaron <tamaron1203@gmail.com> | 2022-05-19 18:58:59 +0900 |
|---|---|---|
| committer | tamaron <tamaron1203@gmail.com> | 2022-05-19 18:58:59 +0900 |
| commit | db41df112aded9ecbbbba421189f28f6eb326554 (patch) | |
| tree | 343203c3aff4ebab3617c8b2f42dd0eb5f772757 | |
| parent | b4c3f0f79b686035b94b8ca3535ff9274f7ef4d6 (diff) | |
| download | rust-db41df112aded9ecbbbba421189f28f6eb326554.tar.gz rust-db41df112aded9ecbbbba421189f28f6eb326554.zip | |
fix
| -rw-r--r-- | clippy_utils/src/lib.rs | 7 |
1 files 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 |
