Skip to content

Allow plugin functions in plugin_group!#24345

Open
Jengamon wants to merge 1 commit into
bevyengine:mainfrom
Jengamon:allow-plugin-func-in-group
Open

Allow plugin functions in plugin_group!#24345
Jengamon wants to merge 1 commit into
bevyengine:mainfrom
Jengamon:allow-plugin-func-in-group

Conversation

@Jengamon
Copy link
Copy Markdown

Objective

Allow plugin functions to be used inside plugin_group! declarations.

Right now, functions of signature fn(&mut App) implement Plugin, but cannot be added to plugin groups, due
to how the macro is implemented.

This fixes that.

Solution

This PR fixes the problem by introducing a block after the top-level members, labeled with fn, where the names are considered to be referencing values directly, rather than types. It looks like:

plugin_group! {
  pub struct MyFnGroup {
     // ... stuff that `impl Plugin` ...
     fn {
       :local_fn,
       outer:::outer_fn,
       #[doc(hidden)]
       internal:::hidden_fn,
    }
  }
}

Testing

I edited the doctest above the macro implementation, and made sure that passes, and the syntax is non-invasive otherwise, so overall, not much should change.


@github-actions
Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨

@Jengamon Jengamon force-pushed the allow-plugin-func-in-group branch from 4cb37a0 to 9d8b233 Compare May 18, 2026 23:47
introduces a little idiosyncratic `fn {}` block for containing the
function members, mostly as a workaround for the fact that macro parsing
cannot backtrack
@Jengamon Jengamon force-pushed the allow-plugin-func-in-group branch from 9d8b233 to 30f8623 Compare May 19, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant