You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm aware how minimal and stable this crate is and has been for a long time, but something that's always put me off from using it (usually in favor of manual #[cfg] attributes) is how its syntax is completely unfamiliar to rustfmt, and therefore any expressions or items inside of a cfg_if! block can't get the advantages that rustfmt brings.
// stays as is when `cargo fmt` is runcfg_if!{if #[cfg(foobar)]{fn baz(){ qux(); flop()}}
else {fn bar(){}}}
Was there a reason that you didn't choose a more traditional/valid rust syntax for the macro? e.g.
I'm aware that rustfmt wasn't as popular/well-integrated in 2017, but I feel like a syntax like this would greatly improve the ergonomics of this crate.
(feel free to ignore, I was just surprised that there wasn't an issue about this already)
The text was updated successfully, but these errors were encountered:
I chose to use #[cfg] instead of cfg! because cfg! already exists but behaves differently than this crate. It's true that when this was created rustfmt didn't exist, but I would indeed be interested if there's a way to get rustfmt to look at code inside the macro and format it. I don't know what heuristics rustfmt has, however.
We don't really have the ability to format anything that's contained with any macro call using brace delimiters, so a change to cfg! isn't going to do anything for rustfmt.
cfg_if is actually already one of the special case scenarios where we do peek inside to look for any out-of-line mods that are imported and we do format the associated files for those mods, but don't touch the inline args to the mac call.
Our ability to format the out-of-line mods is heavily predicated on the current syntax, so the only immediate impact of from #[cfg] to cfg! would actually be to break the current ability to format those mods.
I'm aware how minimal and stable this crate is and has been for a long time, but something that's always put me off from using it (usually in favor of manual
#[cfg]
attributes) is how its syntax is completely unfamiliar to rustfmt, and therefore any expressions or items inside of acfg_if!
block can't get the advantages that rustfmt brings.Was there a reason that you didn't choose a more traditional/valid rust syntax for the macro? e.g.
I'm aware that rustfmt wasn't as popular/well-integrated in 2017, but I feel like a syntax like this would greatly improve the ergonomics of this crate.
(feel free to ignore, I was just surprised that there wasn't an issue about this already)
The text was updated successfully, but these errors were encountered: