error: an inner attribute is not permitted in this context
--> src\lib.rs:13:19
|
13 | #![cfg_attr(test, ruspiro_test_macros::ruspiro_test_framework)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
Is this not possible, or do I need a special implementation within my proc_macro to make this possible?
A macro must expand to a full "thing", where "thing" is an item, an expression, a type (maybe a pattern too).
Attributes are not "things" themselves, they are modifier on these other things, so it is literally impossible to have a macro that expands to attributes on their own.
What you can have is: a macro that wraps some item definition and re-emits it, with the extra desired attributes applied to it.
Sadly, a macro cannot emit or be applied to the root of a crate, so it is indeed literally impossible to do what you want.
The reason why I think it would be great to have this functionality is, that it would simplify the usage of custom test frameworks. I've defined one in a separate crate but there is a lot of boilerplate required in every crate that should make use of the custom test framework.
It would be highly appreciated if the boilerplate could be reduced to one or two proc-macro calls to improve usability of custom test frameworks.
So if anyone from the Rust team is also scanning the posts here this might be a possible future feature when it comes to testing support of Rust