Independent of what rustc does today, which output would you *want* the following program to print?

macro_rules! stringify_expr {
($expr:expr) => {
stringify!($expr)
};
}

macro_rules! stringify_if_eq {
($expr:expr) => {
stringify_expr!(if $expr == $expr {})
};
}

fn main() {
println!("{}", stringify_if_eq!(Struct {}));
}

When voting for the option without parens, bear in mind that is not valid Rust syntax. If the pretty-printer behaves that way, it means for example `cargo rustc -- -Zunpretty=expanded` (i.e. cargo expand) would produce output that cannot be parsed by rustfmt.

@dtolnay Oh, I picked the non-parenthesized one, but this changes my answer. I think now I'd pick the third one, with one big set of parens.

Follow

@theincredibleholk @dtolnay I did the same and would also pick the third option now.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.