Closed
Description
Let's assume you have two user defined proc_macro_attributes in the following order:
struct Test {}
#[depends_on_inner]
impl Test {
#[inner]
fn test() {
}
}
Is there any way to hand over information between these two macro executions, so that depends_on_inner knows that impl Test has a function with a #[inner] attribute?
Activity
ehuss commentedon Jul 31, 2020
I'm uncertain if there's a common way to relay information.
depends_on_inner
can parse its input and notice the presence of theinner
attribute, but I'm uncertain if that's guaranteed (see #692 and its linked issues).Questions like these should be asked on one of the user forums, like https://users.rust-lang.org/.
exellian commentedon Aug 1, 2020
Ok thanks!
Caellian commentedon Sep 28, 2023
For future reference if anyone stumbles upon this issue:
Instead of defining
#[inner]
as a separate macro, process it (assuming you're using syn) by detecting it fromImplItem::attributes
and then passing it to the same processor fn you otherwise would. If you need#[inner]
to work on its own you must name the version bound to#[depends_on_inner]
differently as order of expansion is not guaranteed and might change depending on target/version.