Part of the same issues #2766 wants to fix.
The XcmWeightInfo trait is already auto-generated from the Instruction enum by the XcmWeightInfoTrait derive macro (polkadot/xcm/procedural/src/weight_info.rs). However, the dispatch glue that maps each variant to its trait method is not. This is manually written and has to be updated in v3, v4 and v5 whenever any variant of the enum changes.
We should extend the existing proc macro so the same derive that emits the XcmWeightInfo trait also emits the GetWeight impl we need. Then remove the manually written impls.
Tip
The Builder pattern macro in xcm-procedural is a good example of how to turn variant names into method names within a proc macro. Its structure can be mirrored.
Part of the same issues #2766 wants to fix.
The
XcmWeightInfotrait is already auto-generated from theInstructionenum by theXcmWeightInfoTraitderive macro (polkadot/xcm/procedural/src/weight_info.rs). However, the dispatch glue that maps each variant to its trait method is not. This is manually written and has to be updated in v3, v4 and v5 whenever any variant of the enum changes.We should extend the existing proc macro so the same derive that emits the
XcmWeightInfotrait also emits theGetWeightimpl we need. Then remove the manually written impls.Tip
The
Builderpattern macro in xcm-procedural is a good example of how to turn variant names into method names within a proc macro. Its structure can be mirrored.