From 6d44106e762a5c9a81325c91c975cd802945f914 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 2 Sep 2022 09:58:08 -0500 Subject: [PATCH] fix(derive): Remove helper for removed help_heading --- clap_derive/src/attr.rs | 2 -- clap_derive/src/item.rs | 16 +++------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/clap_derive/src/attr.rs b/clap_derive/src/attr.rs index 111494b5..aee3ee51 100644 --- a/clap_derive/src/attr.rs +++ b/clap_derive/src/attr.rs @@ -63,7 +63,6 @@ impl Parse for ClapAttr { "skip" => Some(MagicAttrName::Skip), "next_display_order" => Some(MagicAttrName::NextDisplayOrder), "next_help_heading" => Some(MagicAttrName::NextHelpHeading), - "help_heading" => Some(MagicAttrName::HelpHeading), "default_value_t" => Some(MagicAttrName::DefaultValueT), "default_values_t" => Some(MagicAttrName::DefaultValuesT), "default_value_os_t" => Some(MagicAttrName::DefaultValueOsT), @@ -145,7 +144,6 @@ pub enum MagicAttrName { DefaultValuesOsT, NextDisplayOrder, NextHelpHeading, - HelpHeading, } #[derive(Clone)] diff --git a/clap_derive/src/item.rs b/clap_derive/src/item.rs index 6651187f..67d336d6 100644 --- a/clap_derive/src/item.rs +++ b/clap_derive/src/item.rs @@ -46,7 +46,6 @@ pub struct Item { verbatim_doc_comment: bool, next_display_order: Option, next_help_heading: Option, - help_heading: Option, is_enum: bool, is_positional: bool, kind: Sp, @@ -415,7 +414,6 @@ impl Item { verbatim_doc_comment: false, next_display_order: None, next_help_heading: None, - help_heading: None, is_enum: false, is_positional: true, kind: Sp::new(Kind::Arg(Sp::new(Ty::Other, default_span)), default_span), @@ -756,10 +754,6 @@ impl Item { self.next_display_order = Some(Method::new(attr.name.clone(), quote!(#expr))); } - Some(MagicAttrName::HelpHeading) => { - let expr = attr.value_or_abort(); - self.help_heading = Some(Method::new(attr.name.clone(), quote!(#expr))); - } Some(MagicAttrName::NextHelpHeading) => { let expr = attr.value_or_abort(); self.next_help_heading = Some(Method::new(attr.name.clone(), quote!(#expr))); @@ -851,11 +845,9 @@ impl Item { pub fn initial_top_level_methods(&self) -> TokenStream { let next_display_order = self.next_display_order.as_ref().into_iter(); let next_help_heading = self.next_help_heading.as_ref().into_iter(); - let help_heading = self.help_heading.as_ref().into_iter(); quote!( #(#next_display_order)* #(#next_help_heading)* - #(#help_heading)* ) } @@ -869,18 +861,17 @@ impl Item { /// generate methods on top of a field pub fn field_methods(&self, supports_long_help: bool) -> proc_macro2::TokenStream { let methods = &self.methods; - let help_heading = self.help_heading.as_ref().into_iter(); match supports_long_help { true => { let doc_comment = &self.doc_comment; - quote!( #(#doc_comment)* #(#help_heading)* #(#methods)* ) + quote!( #(#doc_comment)* #(#methods)* ) } false => { let doc_comment = self .doc_comment .iter() .filter(|mth| mth.name != "long_help"); - quote!( #(#doc_comment)* #(#help_heading)* #(#methods)* ) + quote!( #(#doc_comment)* #(#methods)* ) } } } @@ -892,8 +883,7 @@ impl Item { pub fn next_help_heading(&self) -> TokenStream { let next_help_heading = self.next_help_heading.as_ref().into_iter(); - let help_heading = self.help_heading.as_ref().into_iter(); - quote!( #(#next_help_heading)* #(#help_heading)* ) + quote!( #(#next_help_heading)* ) } pub fn id(&self) -> TokenStream {