diff --git a/cli/src/commit_templater.rs b/cli/src/commit_templater.rs index e46351ee0..d602fd352 100644 --- a/cli/src/commit_templater.rs +++ b/cli/src/commit_templater.rs @@ -90,6 +90,7 @@ use crate::template_parser::TemplateParseError; use crate::template_parser::TemplateParseResult; use crate::templater; use crate::templater::BoxedTemplateProperty; +use crate::templater::ListTemplate; use crate::templater::PlainTextFormattedProperty; use crate::templater::SizeHint; use crate::templater::Template; @@ -398,7 +399,13 @@ template_builder::impl_property_wrappers!(<'repo> CommitTemplatePropertyKind<'re }); impl<'repo> CoreTemplatePropertyVar<'repo> for CommitTemplatePropertyKind<'repo> { - template_builder::impl_core_wrap_property_fns!('repo, CommitTemplatePropertyKind::Core); + fn wrap_template(template: Box) -> Self { + CommitTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_template(template)) + } + + fn wrap_list_template(template: Box) -> Self { + CommitTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_list_template(template)) + } fn type_name(&self) -> &'static str { match self { diff --git a/cli/src/generic_templater.rs b/cli/src/generic_templater.rs index 95b14f1a3..902b86062 100644 --- a/cli/src/generic_templater.rs +++ b/cli/src/generic_templater.rs @@ -28,6 +28,7 @@ use crate::template_parser::FunctionCallNode; use crate::template_parser::TemplateDiagnostics; use crate::template_parser::TemplateParseResult; use crate::templater::BoxedTemplateProperty; +use crate::templater::ListTemplate; use crate::templater::Template; /// General-purpose template language for basic value types. @@ -160,7 +161,13 @@ macro_rules! impl_self_property_wrapper { pub(crate) use impl_self_property_wrapper; impl<'a, C> CoreTemplatePropertyVar<'a> for GenericTemplatePropertyKind<'a, C> { - template_builder::impl_core_wrap_property_fns!('a, GenericTemplatePropertyKind::Core); + fn wrap_template(template: Box) -> Self { + GenericTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_template(template)) + } + + fn wrap_list_template(template: Box) -> Self { + GenericTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_list_template(template)) + } fn type_name(&self) -> &'static str { match self { diff --git a/cli/src/operation_templater.rs b/cli/src/operation_templater.rs index 696efca2e..a00ec7b31 100644 --- a/cli/src/operation_templater.rs +++ b/cli/src/operation_templater.rs @@ -38,6 +38,7 @@ use crate::template_parser::FunctionCallNode; use crate::template_parser::TemplateDiagnostics; use crate::template_parser::TemplateParseResult; use crate::templater::BoxedTemplateProperty; +use crate::templater::ListTemplate; use crate::templater::PlainTextFormattedProperty; use crate::templater::Template; use crate::templater::TemplateFormatter; @@ -148,7 +149,13 @@ template_builder::impl_property_wrappers!(OperationTemplatePropertyKind { }); impl CoreTemplatePropertyVar<'static> for OperationTemplatePropertyKind { - template_builder::impl_core_wrap_property_fns!('static, OperationTemplatePropertyKind::Core); + fn wrap_template(template: Box) -> Self { + OperationTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_template(template)) + } + + fn wrap_list_template(template: Box) -> Self { + OperationTemplatePropertyKind::Core(CoreTemplatePropertyKind::wrap_list_template(template)) + } fn type_name(&self) -> &'static str { match self { diff --git a/cli/src/template_builder.rs b/cli/src/template_builder.rs index 5b68d4c65..84c837301 100644 --- a/cli/src/template_builder.rs +++ b/cli/src/template_builder.rs @@ -93,28 +93,6 @@ pub trait TemplateLanguage<'a> { ) -> TemplateParseResult; } -/// Implements `CoreTemplatePropertyVar::wrap_template()` functions. -/// -/// - `impl_core_wrap_property_fns('a)` for `CoreTemplatePropertyKind`, -/// - `impl_core_wrap_property_fns('a, MyKind::Core)` for `MyKind::Core(..)`. -macro_rules! impl_core_wrap_property_fns { - ($a:lifetime) => { - $crate::template_builder::impl_core_wrap_property_fns!($a, std::convert::identity); - }; - ($a:lifetime, $outer:path) => { - fn wrap_template(template: Box) -> Self { - use $crate::template_builder::CoreTemplatePropertyKind as Kind; - $outer(Kind::Template(template)) - } - fn wrap_list_template(template: Box) -> Self { - use $crate::template_builder::CoreTemplatePropertyKind as Kind; - $outer(Kind::ListTemplate(template)) - } - }; -} - -pub(crate) use impl_core_wrap_property_fns; - /// Implements [`WrapTemplateProperty<'a, O>`] for property types. /// /// - `impl_property_wrappers!(Kind { Foo(Foo), FooList(Vec), .. });` to @@ -256,7 +234,13 @@ pub(crate) use impl_core_property_wrappers; impl_core_property_wrappers!(<'a> CoreTemplatePropertyKind<'a>); impl<'a> CoreTemplatePropertyVar<'a> for CoreTemplatePropertyKind<'a> { - impl_core_wrap_property_fns!('a); + fn wrap_template(template: Box) -> Self { + CoreTemplatePropertyKind::Template(template) + } + + fn wrap_list_template(template: Box) -> Self { + CoreTemplatePropertyKind::ListTemplate(template) + } fn type_name(&self) -> &'static str { match self {