From 090b4b529f69a6cf307518ebfb59bf2749609235 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 19 Feb 2023 13:19:02 +0100 Subject: [PATCH] Fix unused/dead code warnings with VST3 disabled --- src/event_loop.rs | 6 +++--- src/midi.rs | 1 + src/plugin.rs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/event_loop.rs b/src/event_loop.rs index 034c8904..de1a993b 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -13,13 +13,13 @@ mod windows; pub(crate) use self::background_thread::BackgroundThread; -#[allow(unused_imports)] +#[cfg_attr(not(feature = "vst3"), allow(unused_imports))] #[cfg(all(target_family = "unix", not(target_os = "macos")))] pub(crate) use self::linux::LinuxEventLoop as OsEventLoop; -#[allow(unused_imports)] +#[cfg_attr(not(feature = "vst3"), allow(unused_imports))] #[cfg(target_os = "macos")] pub(crate) use self::macos::MacOSEventLoop as OsEventLoop; -#[allow(unused_imports)] +#[cfg_attr(not(feature = "vst3"), allow(unused_imports))] #[cfg(target_os = "windows")] pub(crate) use self::windows::WindowsEventLoop as OsEventLoop; diff --git a/src/midi.rs b/src/midi.rs index 69aa7ddb..1a612b0c 100644 --- a/src/midi.rs +++ b/src/midi.rs @@ -598,6 +598,7 @@ impl NoteEvent { /// Subtract a sample offset from this event's timing, needed to compensate for the block /// splitting in the VST3 wrapper implementation because all events have to be read upfront. + #[cfg_attr(not(feature = "vst3"), allow(dead_code))] pub(crate) fn subtract_timing(&mut self, samples: u32) { match self { NoteEvent::NoteOn { timing, .. } => *timing -= samples, diff --git a/src/plugin.rs b/src/plugin.rs index cab10ca8..85c6fdf4 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -263,12 +263,12 @@ pub trait Vst3Plugin: Plugin { const PLATFORM_VST3_CLASS_ID: [u8; 16] = swap_vst3_uid_byte_order(Self::VST3_CLASS_ID); } -#[cfg(not(target_os = "windows"))] +#[cfg(all(feature = "vst3", not(target_os = "windows")))] const fn swap_vst3_uid_byte_order(uid: [u8; 16]) -> [u8; 16] { uid } -#[cfg(target_os = "windows")] +#[cfg(all(feature = "vst3", target_os = "windows"))] const fn swap_vst3_uid_byte_order(mut uid: [u8; 16]) -> [u8; 16] { // No mutable references in const functions, so we can't use `uid.swap()` let original_uid = uid;