Forward attributes on spec! it cases - #3
Merged
Merged
Conversation
Attributes written before an `it` (#[ignore], #[should_panic], #[cfg(...)], and so on) are now parsed and emitted on the generated test function, so the DSL matches what attribute-style #[test_suite] already allows. Attributes on hooks (before/after/before_each/after_each) are rejected with a clear compile error, since a hook isn't a standalone function and the attribute would otherwise be dropped silently.
brianp
force-pushed
the
spec-attr-passthrough
branch
from
July 21, 2026 15:46
e3327fd to
74e3d11
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the discussion on #1, where Bruce mentioned he'd have liked arbitrary attributes to be supported.
In attribute style (
#[test_suite]) you can already put#[ignore],#[cfg(...)],#[should_panic], and so on directly on a#[test]fn, and the macro carries them through. Thespec!DSL couldn't do that. There was no syntax to attach an attribute to anit, so anything that needed one meant dropping out of the DSL.This wires it up. Attributes written before an
itare parsed and emitted on the generated#[test]function:Works on
async ittoo.Attributes on hooks (
before/after/before_each/after_each) are rejected with a compile error rather than silently dropped, since a hook isn't a standalone function. Gating a hook is a separate, harder thing and I left it out.Independent of the #[after] fix in #2, so this branches straight off main.