I think this should be part of the proc_macros API since that's something the compiler is best equipped to deal with.
TL;DR from the issue:
PyO3 allows annotating an inherent
impl block with an attribute
#[pyclass], which exports all contained methods as Python methods. Some of those methods can be annotated with additional attributes, such as
#[staticmethod], which signals special kinds of methods to the proc macro.
A problem arises here with conditional compilation: if the outer attribute is behind a
#[cfg_attr], the inner attribute must be as well. But then, the attribute proc macro gets passed the full
#[cfg_attr(condition, staticmethod)] and needs to evaluate itself whether to parse it - the condition could be different from the one that activated the outer attribute.
This is in contrast to derive macros, where the structure passed to the macro already has such conditions resolved.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.