Skip to content

Commit

Permalink
Add allow() for const impl pattern that causes false positives in a r…
Browse files Browse the repository at this point in the history
…ustc lint in derive macros; rust-lang/rust#120363
  • Loading branch information
Shnatsel committed Jan 13, 2025
1 parent b306295 commit 983aa2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions derive/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions derive/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<A> Component<A> for @Self
where
A: #abscissa_core::Application
Expand Down Expand Up @@ -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<A> Component<A> for MyComponent
where
A: abscissa_core::Application
Expand Down
4 changes: 4 additions & 0 deletions derive/src/runnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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 {
Expand Down

0 comments on commit 983aa2e

Please sign in to comment.