From c91b74355f4c897a759c47ed1cf013e3ddceb9d3 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 3 Jul 2022 16:52:38 +0200 Subject: [PATCH] Let rustfmt handle string wrapping --- .rustfmt.toml | 1 + nih_plug_derive/src/enums.rs | 6 ++++-- nih_plug_derive/src/params.rs | 18 ++++++++++++------ src/event_loop/linux.rs | 13 ++++++++++--- src/event_loop/windows.rs | 5 ++++- src/wrapper/clap/context.rs | 18 +++++++++++++++--- src/wrapper/clap/wrapper.rs | 4 ++-- src/wrapper/standalone.rs | 7 ++++++- src/wrapper/standalone/backend/jack.rs | 5 ++++- src/wrapper/standalone/wrapper.rs | 4 ++-- src/wrapper/vst3/inner.rs | 8 +++++--- src/wrapper/vst3/view.rs | 4 ++-- 12 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 .rustfmt.toml diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 00000000..a5a68066 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1 @@ +format_strings = true diff --git a/nih_plug_derive/src/enums.rs b/nih_plug_derive/src/enums.rs index c8463dc2..d4fb57cd 100644 --- a/nih_plug_derive/src/enums.rs +++ b/nih_plug_derive/src/enums.rs @@ -50,7 +50,8 @@ pub fn derive_enum(input: TokenStream) -> TokenStream { _ => { return syn::Error::new( attr.span(), - "The name attribute should be a key-value pair with a string argument: #[name = \"foo bar\"]", + "The name attribute should be a key-value pair with a string \ + argument: #[name = \"foo bar\"]", ) .to_compile_error() .into() @@ -73,7 +74,8 @@ pub fn derive_enum(input: TokenStream) -> TokenStream { _ => { return syn::Error::new( attr.span(), - "The id attribute should be a key-value pair with a string argument: #[id = \"foo-bar\"]", + "The id attribute should be a key-value pair with a string argument: \ + #[id = \"foo-bar\"]", ) .to_compile_error() .into() diff --git a/nih_plug_derive/src/params.rs b/nih_plug_derive/src/params.rs index 077c7138..e77ef0fc 100644 --- a/nih_plug_derive/src/params.rs +++ b/nih_plug_derive/src/params.rs @@ -69,7 +69,8 @@ pub fn derive_params(input: TokenStream) -> TokenStream { _ => { return syn::Error::new( attr.span(), - "The id attribute should be a key-value pair with a string argument: #[id = \"foo_bar\"]", + "The id attribute should be a key-value pair with a string argument: \ + #[id = \"foo_bar\"]", ) .to_compile_error() .into() @@ -92,7 +93,8 @@ pub fn derive_params(input: TokenStream) -> TokenStream { _ => { return syn::Error::new( attr.span(), - "The persist attribute should be a key-value pair with a string argument: #[persist = \"foo_bar\"]", + "The persist attribute should be a key-value pair with a string \ + argument: #[persist = \"foo_bar\"]", ) .to_compile_error() .into() @@ -110,9 +112,12 @@ pub fn derive_params(input: TokenStream) -> TokenStream { .to_compile_error() .into(); } else if s.contains('/') { - return syn::Error::new(attr.span(), "Group names may not contain slashes") - .to_compile_error() - .into(); + return syn::Error::new( + attr.span(), + "Group names may not contain slashes", + ) + .to_compile_error() + .into(); } else if nested_attr.is_some() { return syn::Error::new(attr.span(), "Duplicate nested attribute") .to_compile_error() @@ -124,7 +129,8 @@ pub fn derive_params(input: TokenStream) -> TokenStream { _ => { return syn::Error::new( attr.span(), - "The nested attribute should be a key-value pair with a string argument: #[nested = \"Group Name\"]", + "The nested attribute should be a key-value pair with a string \ + argument: #[nested = \"Group Name\"]", ) .to_compile_error() .into() diff --git a/src/event_loop/linux.rs b/src/event_loop/linux.rs index 2f496ad0..5aaeea6c 100644 --- a/src/event_loop/linux.rs +++ b/src/event_loop/linux.rs @@ -12,7 +12,8 @@ use crate::util::permit_alloc; /// See [`EventLoop`][super::EventLoop]. #[cfg_attr( target_os = "macos", - deprecated = "macOS needs to have its own event loop implementation, this implementation may not work correctly" + deprecated = "macOS needs to have its own event loop implementation, this implementation may \ + not work correctly" )] pub(crate) struct LinuxEventLoop { /// The thing that ends up executing these tasks. The tasks are usually executed from the worker @@ -71,7 +72,10 @@ where true } None => { - nih_trace!("The executor doesn't exist but somehow it's still submitting tasks, this shouldn't be possible!"); + nih_trace!( + "The executor doesn't exist but somehow it's still submitting tasks, this \ + shouldn't be possible!" + ); false } } @@ -112,7 +116,10 @@ where Ok(Message::Task(task)) => match executor.upgrade() { Some(e) => unsafe { e.execute(task) }, None => { - nih_trace!("Received a new task but the executor is no longer alive, shutting down worker"); + nih_trace!( + "Received a new task but the executor is no longer alive, shutting down \ + worker" + ); return; } }, diff --git a/src/event_loop/windows.rs b/src/event_loop/windows.rs index 257614f6..66411fb9 100644 --- a/src/event_loop/windows.rs +++ b/src/event_loop/windows.rs @@ -141,7 +141,10 @@ where true } None => { - nih_trace!("The executor doesn't exist but somehow it's still submitting tasks, this shouldn't be possible!"); + nih_trace!( + "The executor doesn't exist but somehow it's still submitting tasks, this \ + shouldn't be possible!" + ); false } } diff --git a/src/wrapper/clap/context.rs b/src/wrapper/clap/context.rs index 2ab6de41..42c6ad79 100644 --- a/src/wrapper/clap/context.rs +++ b/src/wrapper/clap/context.rs @@ -50,7 +50,11 @@ impl GuiContext for WrapperGuiContext

{ .wrapper .queue_parameter_event(OutputParamEvent::BeginGesture { param_hash: *hash }); - nih_debug_assert!(success, "Parameter output event queue was full, parameter change will not be sent to the host"); + nih_debug_assert!( + success, + "Parameter output event queue was full, parameter change will not be sent to \ + the host" + ); } None => nih_debug_assert_failure!("Unknown parameter: {:?}", param), } @@ -72,7 +76,11 @@ impl GuiContext for WrapperGuiContext

{ clap_plain_value, }); - nih_debug_assert!(success, "Parameter output event queue was full, parameter change will not be sent to the host"); + nih_debug_assert!( + success, + "Parameter output event queue was full, parameter change will not be sent to \ + the host" + ); } None => nih_debug_assert_failure!("Unknown parameter: {:?}", param), } @@ -85,7 +93,11 @@ impl GuiContext for WrapperGuiContext

{ .wrapper .queue_parameter_event(OutputParamEvent::EndGesture { param_hash: *hash }); - nih_debug_assert!(success, "Parameter output event queue was full, parameter change will not be sent to the host"); + nih_debug_assert!( + success, + "Parameter output event queue was full, parameter change will not be sent to \ + the host" + ); } None => nih_debug_assert_failure!("Unknown parameter: {:?}", param), } diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 5a3d7c5e..f56ba342 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -391,8 +391,8 @@ impl Wrapper

{ nih_debug_assert_eq!( param_map.len(), param_ids.len(), - "The plugin has duplicate parameter IDs, weird things may happen. \ - Consider using 6 character parameter IDs to avoid collissions.." + "The plugin has duplicate parameter IDs, weird things may happen. Consider using \ + 6 character parameter IDs to avoid collissions.." ); let mut bypass_param_exists = false; diff --git a/src/wrapper/standalone.rs b/src/wrapper/standalone.rs index 16f7519f..07c8377c 100644 --- a/src/wrapper/standalone.rs +++ b/src/wrapper/standalone.rs @@ -115,7 +115,12 @@ fn run_wrapper(backend: B, config: WrapperConfig) -> bool fn print_error(error: WrapperError, config: &WrapperConfig) { match error { WrapperError::IncompatibleConfig => { - nih_error!("The plugin does not support the {} channel input and {} channel output configuration", config.input_channels, config.output_channels); + nih_error!( + "The plugin does not support the {} channel input and {} channel output \ + configuration", + config.input_channels, + config.output_channels + ); } WrapperError::InitializationFailed => { nih_error!("The plugin failed to initialize"); diff --git a/src/wrapper/standalone/backend/jack.rs b/src/wrapper/standalone/backend/jack.rs index 09e91499..17a9596b 100644 --- a/src/wrapper/standalone/backend/jack.rs +++ b/src/wrapper/standalone/backend/jack.rs @@ -64,7 +64,10 @@ impl Backend for Jack { // buffers like that so we'll just make it easier for ourselves by not supporting that let num_frames = ps.n_frames(); if num_frames != buffer_size { - nih_error!("Buffer size changed from {buffer_size} to {num_frames}. Buffer size changes are currently not supported, aborting..."); + nih_error!( + "Buffer size changed from {buffer_size} to {num_frames}. Buffer size changes \ + are currently not supported, aborting..." + ); control_sender.send(Task::Shutdown).unwrap(); return Control::Quit; } diff --git a/src/wrapper/standalone/wrapper.rs b/src/wrapper/standalone/wrapper.rs index b8663b67..f80c3814 100644 --- a/src/wrapper/standalone/wrapper.rs +++ b/src/wrapper/standalone/wrapper.rs @@ -142,8 +142,8 @@ impl Wrapper { nih_debug_assert_eq!( param_map.len(), param_ids.len(), - "The plugin has duplicate parameter IDs, weird things may happen. \ - Consider using 6 character parameter IDs to avoid collissions.." + "The plugin has duplicate parameter IDs, weird things may happen. Consider using \ + 6 character parameter IDs to avoid collissions.." ); let mut bypass_param_exists = false; diff --git a/src/wrapper/vst3/inner.rs b/src/wrapper/vst3/inner.rs index 6063e7fa..b66812d2 100644 --- a/src/wrapper/vst3/inner.rs +++ b/src/wrapper/vst3/inner.rs @@ -220,8 +220,8 @@ impl WrapperInner

{ nih_debug_assert_eq!( param_map.len(), param_ids.len(), - "The plugin has duplicate parameter IDs, weird things may happen. \ - Consider using 6 character parameter IDs to avoid collissions.." + "The plugin has duplicate parameter IDs, weird things may happen. Consider using \ + 6 character parameter IDs to avoid collissions.." ); let mut bypass_param_exists = false; @@ -241,7 +241,9 @@ impl WrapperInner

{ && (VST3_MIDI_PARAMS_START..VST3_MIDI_PARAMS_END).contains(hash) { nih_debug_assert_failure!( - "Parameter '{}' collides with an automatically generated MIDI CC parameter, consider giving it a different ID", id + "Parameter '{}' collides with an automatically generated MIDI CC \ + parameter, consider giving it a different ID", + id ); } } diff --git a/src/wrapper/vst3/view.rs b/src/wrapper/vst3/view.rs index 460f4796..02a75360 100644 --- a/src/wrapper/vst3/view.rs +++ b/src/wrapper/vst3/view.rs @@ -519,8 +519,8 @@ impl Drop for RunLoopEventHandler

{ if posting_failed { nih_debug_assert_failure!( - "Outstanding tasks have been dropped when clsoing \ - the editor as the task queue was full" + "Outstanding tasks have been dropped when clsoing the editor as the task queue \ + was full" ); }