Skip to content

Conversation

@cpubot
Copy link
Collaborator

@cpubot cpubot commented Oct 11, 2025

Current tuple macro will correctly drop initialized fields when an error is encountered. But, it does not use a drop guard like the derive macros currently do, so it's not panic safe.

Generating correct drop guard logic with macro_rules gets exceptionally ugly, and thus hard to understand and maintain. This PR rewrites the current tuple macro into a function that generates a TokenStream (like a proc-macro) so that the implementation is much easier to reason about (doesn't require multiple recursing declarative macros), in addition to using drop guard like the derive macros so that we're panic safe.

I've also bundled this into a build step so that we don't require a separate crate to expose a proc-macro, which would have to be independently versioned and published.

@cpubot cpubot requested a review from alessandrod October 11, 2025 00:09
@cpubot cpubot force-pushed the tuple-drop-guard branch 3 times, most recently from ec384f8 to f59ae34 Compare October 12, 2025 14:46
@cpubot cpubot force-pushed the tuple-drop-guard branch 6 times, most recently from 6361f61 to 07c180e Compare October 12, 2025 16:02
@cpubot cpubot merged commit c096eec into master Oct 13, 2025
2 checks passed
@cpubot cpubot deleted the tuple-drop-guard branch October 13, 2025 16:49
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.

3 participants