From 5ab67dce0881690b705eed2e010bcc0fae169122 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 26 Nov 2024 11:47:41 -0500 Subject: [PATCH] Use TargetKind enum and Target::is_proc_macro These are added in cargo_metadata 0.19.0. --- test/integration-test/build.rs | 4 ++-- xtask/src/public_api.rs | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/test/integration-test/build.rs b/test/integration-test/build.rs index dfa78789..c019b4fc 100644 --- a/test/integration-test/build.rs +++ b/test/integration-test/build.rs @@ -8,7 +8,7 @@ use std::{ }; use cargo_metadata::{ - Artifact, CompilerMessage, Message, Metadata, MetadataCommand, Package, Target, + Artifact, CompilerMessage, Message, Metadata, MetadataCommand, Package, Target, TargetKind, }; use xtask::{exec, AYA_BUILD_INTEGRATION_BPF, LIBBPF_DIR}; @@ -281,7 +281,7 @@ fn main() { let Package { targets, .. } = integration_ebpf_package; for Target { name, kind, .. } in targets { - if *kind != ["bin"] { + if *kind != [TargetKind::Bin] { continue; } let dst = out_dir.join(name); diff --git a/xtask/src/public_api.rs b/xtask/src/public_api.rs index ac11ee18..8fec2bc6 100644 --- a/xtask/src/public_api.rs +++ b/xtask/src/public_api.rs @@ -56,16 +56,13 @@ pub fn public_api(options: Options, metadata: Metadata) -> Result<()> { if matches!(publish, Some(publish) if publish.is_empty()) { Ok(()) } else { - let target = target.as_ref().and_then(|target| { - let proc_macro = targets.iter().any(|Target { kind, .. }| { - kind.iter().any(|kind| kind == "proc-macro") - }); - (!proc_macro).then_some(target) - }); + let target = (!targets.iter().any(Target::is_proc_macro)) + .then(|| target.clone()) + .flatten(); let diff = check_package_api( &name, toolchain, - target.cloned(), + target, bless, workspace_root.as_std_path(), )