Open
Description
With Rust 1.77.1 and rustfmt
1.7.0, as well as on current nightly 2024-03-30
, the following macro definition (playground)
macro_rules! assert_eq_and_type {
($left:expr, $right:expr $(,)?) => {
{
fn check_statically_same_type<T>(_: &T, _: &T) {}
check_statically_same_type(&$left, &$right);
}
assert_eq!($left, $right);
};
}
formats to
macro_rules! assert_eq_and_type {
($left:expr, $right:expr $(,)?) => {{
fn check_statically_same_type<T>(_: &T, _: &T) {}
check_statically_same_type(&$left, &$right);
}
assert_eq!($left, $right);};
}
This certainly doesn't look right to me. I looked at other reported macro-related issues but couldn't find any very similar issues.
Activity
ytmimi commentedon Apr 1, 2024
@Andlon thanks for the report. This definitely feels like a distinct formatting issue. When you get a chance can you run
rustfmt +1.77.1 --version
andrustfmt +nightly --version
so we get exact version numbers. Also, are you using a configuration options?Andlon commentedon Apr 1, 2024
@ytmimi: The command
rustfmt +1.77.1 --version
does not work for me, complaining thaterror: toolchain '1.77.1-x86_64-unknown-linux-gnu' is not installed
(thoughrustc
is definitely 1.77.1).In any case, the issue can be reproduced on the playground (see my link in the first issue). There it says that for:
stable 1.77.1
, it's usingrustfmt
1.7.0-stable (2024-03-27 7cf61eb)
.1.79.0-nightly (2024-03-31 805813650248c1a2f6f2)
it's usingrustfmt
1.7.0-nightly (2024-03-31 8058136)
.I hope that helps!
Andlon commentedon Apr 1, 2024
As for configuration options, I assume the playground uses default options? The code base I was working on locally had a
rustfmt.toml
like this:ytmimi commentedon Apr 1, 2024
Thanks for the extra info! I'm also guessing that the playground uses default options, and I think it's unlikely that the configuration options you're currently using lead to this issue.
correabuscar commentedon May 22, 2024
ytmimi commentedon May 22, 2024
@correabuscar my guess is that this is unrelated. rustfmt doesn't format macros that use repetition so that likely explains why your manual edits are left unchanged.