From 79ba02daa5a00c7a141e3c881d374b32bc6f6090 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 28 Sep 2022 14:27:08 -0500 Subject: [PATCH 1/2] fix(derive): Quote the attribute in the error --- clap_derive/src/item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clap_derive/src/item.rs b/clap_derive/src/item.rs index 627d11b52e1..851d62b8a3c 100644 --- a/clap_derive/src/item.rs +++ b/clap_derive/src/item.rs @@ -1264,7 +1264,7 @@ fn assert_attr_kind(attr: &ClapAttr, possible_kind: &[AttrKind]) { if !possible_kind.contains(attr.kind.get()) { let options = possible_kind .iter() - .map(|k| format!("`#[{}({})]", k.as_str(), attr.name)) + .map(|k| format!("`#[{}({})]`", k.as_str(), attr.name)) .collect::>(); abort!( attr.name, From 24be631f8695ab0090384f5986956f132750f571 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 28 Sep 2022 14:29:31 -0500 Subject: [PATCH 2/2] fix(derive): Ensure clap/structopt attributes still work The problem with updating all code to use non-deprecated APIs, there aren't tests for the old way anymore. Fixes #4274 --- clap_derive/src/item.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clap_derive/src/item.rs b/clap_derive/src/item.rs index 851d62b8a3c..758df901a37 100644 --- a/clap_derive/src/item.rs +++ b/clap_derive/src/item.rs @@ -1261,7 +1261,9 @@ impl ToTokens for Deprecation { } fn assert_attr_kind(attr: &ClapAttr, possible_kind: &[AttrKind]) { - if !possible_kind.contains(attr.kind.get()) { + if *attr.kind.get() == AttrKind::Clap || *attr.kind.get() == AttrKind::StructOpt { + // deprecated + } else if !possible_kind.contains(attr.kind.get()) { let options = possible_kind .iter() .map(|k| format!("`#[{}({})]`", k.as_str(), attr.name))