@kennytm
I think that when macros allowed in attributes, this in theory could work but it feels like a hacky way of allowing attribute aliases.
I subscribe fairly heavily to the concept of making easy thing easy and hard things possible. Macros solve hard problems which make them very useful but I find them to be unintuitive at first glance. I think the problem we are trying to solve is common enough, and “easy” enough that the solution should be easy at the moment of creation (making the alias) and at the moment of use (using the alias). I think that relying on attribute macros to solve this will fail on both ends.
When I compare these two pieces of code:
macro bar() {
all(complicated, stuff, not(easy, to, remember))
}
#[cfg(bar!())]
mod foo
#[cfg(not(bar!()))]
mod baz
#![alias(bar = cfg(all(complicated, stuff, not(easy, to, remember)))]
#[cfg(bar)]
mod foo
#[cfg(not(bar))]
mod foo
I can’t help but feel like the second one is more intuitive and ergonomic. In the first example I have to both know and care that bar!() is a macro instead of simply using it as any other cfg attribute. When the alias is created, there is nothing in the alias that says this belongs in a cfg attribute, so it is non-obvious what the purpose of it is.
I think if the user needs something more complex out of their attribute alias, then their case is no longer the easy one and then they can make a macro for their use case once attribute macros are introduced in Rust.
@kainino
I agree that an attribute that is a combination of other attributes is ideal. However, I also think that if we allowed aliasing only cfg attributes at first, without putting us into a corner, we can start with a small feature that adds user-value in a non-breaking way. Please read my comment to @kennytm for my issue with solving this using macros.