rustfmt
rustfmt copied to clipboard
rustfmt removes double colons in macro
Hello,
rustfmt
will remove ::
from a macro.
To illustrate:
construct_runtime!(
pub struct Runtime
where
Block = Block,
NodeBlock = generic::Block<Header, sp_runtime::OpaqueExtrinsic>,
UncheckedExtrinsic = UncheckedExtrinsic,
{
Council: pallet_collective::<Instance1>,
TechnicalCommittee: pallet_collective::<Instance2>,
}
);
After running cargo fmt
:
construct_runtime!(
pub struct Runtime
where
Block = Block,
NodeBlock = generic::Block<Header, sp_runtime::OpaqueExtrinsic>,
UncheckedExtrinsic = UncheckedExtrinsic,
{
Council: pallet_collective<Instance1>, <<== '::' is gone
TechnicalCommittee: pallet_collective<Instance2>,
}
);
The compilation will fail afterwards.
We're using Rust nightly-2022-07-24
.
Thanks for the report! Confirming I can reproduce this with rustfmt 1.5.1-nightly (2f3ddd9f 2022-06-27)
A smaller reproducible example. No macro needed.
Input
struct Runtime {
Council: pallet_collective::<Instance1>
}
Output
struct Runtime {
Council: pallet_collective<Instance1>,
}
hmm okay on second thought I think we actually want to remove the ::
if we're not in a macro context, but inside the macro we don't want to remove tokens, so I guess this is actually only an issue in the macro case. Related issues: #3139
Ran into this issue today too.