From 983aa2ec812a9dfc2346d2f3c5ecc824771abe54 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Mon, 13 Jan 2025 19:21:13 +0000 Subject: [PATCH] Add allow() for const impl pattern that causes false positives in a rustc lint in derive macros; https://github.com/rust-lang/rust/issues/120363 --- derive/src/command.rs | 6 ++++++ derive/src/component.rs | 4 ++++ derive/src/runnable.rs | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/derive/src/command.rs b/derive/src/command.rs index 78cb6340..8955dff0 100644 --- a/derive/src/command.rs +++ b/derive/src/command.rs @@ -9,6 +9,8 @@ pub fn derive_command(s: Structure<'_>) -> TokenStream { let subcommand_usage = quote!(); s.gen_impl(quote! { + #[allow(unknown_lints)] + #[allow(non_local_definitions)] gen impl Command for @Self { #[doc = "Name of this program as a string"] fn name() -> &'static str { @@ -44,6 +46,8 @@ mod tests { expands to { #[allow(non_upper_case_globals)] const _DERIVE_Command_FOR_MyCommand: () = { + #[allow(unknown_lints)] + #[allow(non_local_definitions)] impl Command for MyCommand { #[doc = "Name of this program as a string"] fn name() -> & 'static str { @@ -79,6 +83,8 @@ mod tests { expands to { #[allow(non_upper_case_globals)] const _DERIVE_Command_FOR_MyCommand: () = { + #[allow(unknown_lints)] + #[allow(non_local_definitions)] impl Command for MyCommand { #[doc = "Name of this program as a string"] fn name() -> & 'static str { diff --git a/derive/src/component.rs b/derive/src/component.rs index da1deaa6..8ef45d40 100644 --- a/derive/src/component.rs +++ b/derive/src/component.rs @@ -13,6 +13,8 @@ pub fn derive_component(s: Structure<'_>) -> TokenStream { let dependency_methods = attrs.dependency_methods(); s.gen_impl(quote! { + #[allow(unknown_lints)] + #[allow(non_local_definitions)] gen impl Component for @Self where A: #abscissa_core::Application @@ -199,6 +201,8 @@ mod tests { expands to { #[allow(non_upper_case_globals)] const _DERIVE_Component_A_FOR_MyComponent: () = { + #[allow(unknown_lints)] + #[allow(non_local_definitions)] impl Component for MyComponent where A: abscissa_core::Application diff --git a/derive/src/runnable.rs b/derive/src/runnable.rs index 642560df..2ed23b16 100644 --- a/derive/src/runnable.rs +++ b/derive/src/runnable.rs @@ -7,6 +7,8 @@ pub fn derive_runnable(s: synstructure::Structure<'_>) -> proc_macro2::TokenStre }); s.gen_impl(quote! { + #[allow(unknown_lints)] + #[allow(non_local_definitions)] gen impl Runnable for @Self { fn run(&self) { match *self { #body } @@ -33,6 +35,8 @@ mod tests { expands to { #[allow(non_upper_case_globals)] const _DERIVE_Runnable_FOR_MyRunnable: () = { + #[allow(unknown_lints)] + #[allow(non_local_definitions)] impl Runnable for MyRunnable { fn run(&self) { match *self {