Skip to content

Rework the #[flag_name] feature and re-stabilize as #[bitflags(flag_name)]#487

Merged
KodrAus merged 10 commits into
mainfrom
fix/macro-expansion
May 31, 2026
Merged

Rework the #[flag_name] feature and re-stabilize as #[bitflags(flag_name)]#487
KodrAus merged 10 commits into
mainfrom
fix/macro-expansion

Conversation

@KodrAus

@KodrAus KodrAus commented May 31, 2026

Copy link
Copy Markdown
Member

Closes #486

In #483, we added macro code to recognize and handle a custom #[flag_name] attribute for setting the name of a flag. This was being expanded under the expr_safe! macro, which already recurses on each attribute on the expression. Combining the two pushed larger bitflags invocations over the default 128 recursion depth limit.

This PR pulls the logic for computing the flag name out of the logic for wrapping expressions, so we recurse to the same depth as before.

@KodrAus

KodrAus commented May 31, 2026

Copy link
Copy Markdown
Member Author

While working on this I've also cleaned up the workaround for #320 which has been fixed for a few years now. I've also re-organized our compile-pass tests just for a bit of housekeeping.

@KodrAus KodrAus changed the title Don't expand flag names under code that expands expressions Rework the #[flag_name] feature and re-stabilize as #[bitflags(flag_name)] May 31, 2026
@KodrAus

KodrAus commented May 31, 2026

Copy link
Copy Markdown
Member Author

Since we have a second chance to look at this feature, I've namespaced the attribute as #[bitflags(flag_name = "value")] instead of the raw #[flag_name = "value"].

@KodrAus KodrAus merged commit a5d3d5e into main May 31, 2026
20 checks passed
@KodrAus KodrAus deleted the fix/macro-expansion branch May 31, 2026 21:39
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.

2.12.0 causes build failure while trying to compile dispatch2 on macOS

1 participant