It's weird that {} are even required, so I guess rustfmt just isn't aware that this can happen. You can put #[rustfmt::skip] on the macro to keep rustfmt from breaking it.
Here's an alternative that rustfmt doesn't break. As a bonus, it also adds the ability to use associated constants.
macro_rules! get_msg {
($module:path) => {
let message = {
use $module as m;
m::MESSAGE
};
println!("{}", message);
};
}
Do you want to accept get_msg!(a::<T>::Q() -> Z)? If not, you don't want the $:path binder. Honestly, because $:path is a whole path, not a path fragment, it's rarely what you actually want. Despite being much more annoying to work with for the macro, you usually want $($m:ident)::+ instead of $m:path (except when you want $T:ty).
That this is even allowed with brackets is surprising.
That's a great clarification on path. I was definitely under the impression it was just SimplePath-- no clue where I got that from. I was able to refactor to just use a single ident in this case which did indirectly solve the issue.
I also opened this issue for the original problem.