diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /vendor/clap_derive/src/utils | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_derive/src/utils')
-rw-r--r-- | vendor/clap_derive/src/utils/doc_comments.rs | 24 | ||||
-rw-r--r-- | vendor/clap_derive/src/utils/error.rs | 22 | ||||
-rw-r--r-- | vendor/clap_derive/src/utils/mod.rs | 2 |
3 files changed, 37 insertions, 11 deletions
diff --git a/vendor/clap_derive/src/utils/doc_comments.rs b/vendor/clap_derive/src/utils/doc_comments.rs index 5183b6b25..63c6ad1ef 100644 --- a/vendor/clap_derive/src/utils/doc_comments.rs +++ b/vendor/clap_derive/src/utils/doc_comments.rs @@ -6,24 +6,26 @@ use std::iter; pub fn extract_doc_comment(attrs: &[syn::Attribute]) -> Vec<String> { - use syn::Lit::*; - use syn::Meta::*; - use syn::MetaNameValue; - // multiline comments (`/** ... */`) may have LFs (`\n`) in them, // we need to split so we could handle the lines correctly // // we also need to remove leading and trailing blank lines let mut lines: Vec<_> = attrs .iter() - .filter(|attr| attr.path.is_ident("doc")) + .filter(|attr| attr.path().is_ident("doc")) .filter_map(|attr| { - if let Ok(NameValue(MetaNameValue { lit: Str(s), .. })) = attr.parse_meta() { - Some(s.value()) - } else { - // non #[doc = "..."] attributes are not our concern - // we leave them for rustc to handle - None + // non #[doc = "..."] attributes are not our concern + // we leave them for rustc to handle + match &attr.meta { + syn::Meta::NameValue(syn::MetaNameValue { + value: + syn::Expr::Lit(syn::ExprLit { + lit: syn::Lit::Str(s), + .. + }), + .. + }) => Some(s.value()), + _ => None, } }) .skip_while(|s| is_blank(s)) diff --git a/vendor/clap_derive/src/utils/error.rs b/vendor/clap_derive/src/utils/error.rs new file mode 100644 index 000000000..276e34949 --- /dev/null +++ b/vendor/clap_derive/src/utils/error.rs @@ -0,0 +1,22 @@ +pub trait SpanError { + #[allow(non_snake_case)] + fn EXPECTED_Span_OR_ToTokens<D: std::fmt::Display>(&self, msg: D) -> syn::Error; +} + +pub trait ToTokensError { + #[allow(non_snake_case)] + fn EXPECTED_Span_OR_ToTokens<D: std::fmt::Display>(&self, msg: D) -> syn::Error; +} + +impl<T: quote::ToTokens> ToTokensError for T { + fn EXPECTED_Span_OR_ToTokens<D: std::fmt::Display>(&self, msg: D) -> syn::Error { + // Curb monomorphization from generating too many identical `new_spanned`. + syn::Error::new_spanned(self.to_token_stream(), msg) + } +} + +impl SpanError for proc_macro2::Span { + fn EXPECTED_Span_OR_ToTokens<D: std::fmt::Display>(&self, msg: D) -> syn::Error { + syn::Error::new(*self, msg) + } +} diff --git a/vendor/clap_derive/src/utils/mod.rs b/vendor/clap_derive/src/utils/mod.rs index 9f8b6f380..13e6e7106 100644 --- a/vendor/clap_derive/src/utils/mod.rs +++ b/vendor/clap_derive/src/utils/mod.rs @@ -1,3 +1,5 @@ +pub mod error; + mod doc_comments; mod spanned; mod ty; |