I tried this code:
struct X;
macro_rules! foo {
() => (X);
}
fn foo(a: u32) {
let _: Option<X> = match a {
// This obviously works
0 => X.into(),
// This works as well
1 => foo!{}.into(),
// This does not
_ => {
foo!{}.into()
},
};
}
I expected to see this happen: The code for the default match arm parses successfully just like the others.
Instead, this happened: It errors for the default match arm, because of the braces. This happens on every stable and nightly i've tested. This is a minimal reproducer from a program using quote, which gets constantly broken because rustfmt tries to format the actually longer line into a block.
Meta
Playground stable, nightly
rustc --version --verbose:
rustc 1.45.0-nightly (7ced01a73 2020-04-30)
binary: rustc
commit-hash: 7ced01a730e8fc1bae2f8d4369c26812c0484da4
commit-date: 2020-04-30
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0
I tried this code:
I expected to see this happen: The code for the default match arm parses successfully just like the others.
Instead, this happened: It errors for the default match arm, because of the braces. This happens on every stable and nightly i've tested. This is a minimal reproducer from a program using quote, which gets constantly broken because rustfmt tries to format the actually longer line into a block.
Meta
Playground stable, nightly
rustc --version --verbose: