diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
commit | 4547b622d8d29df964fa2914213088b148c498fc (patch) | |
tree | 9fc6b25f3c3add6b745be9a2400a6e96140046e9 /vendor/strum_macros/src/helpers/mod.rs | |
parent | Releasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz rustc-4547b622d8d29df964fa2914213088b148c498fc.zip |
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/strum_macros/src/helpers/mod.rs')
-rw-r--r-- | vendor/strum_macros/src/helpers/mod.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/strum_macros/src/helpers/mod.rs b/vendor/strum_macros/src/helpers/mod.rs new file mode 100644 index 000000000..11aebc835 --- /dev/null +++ b/vendor/strum_macros/src/helpers/mod.rs @@ -0,0 +1,32 @@ +pub use self::case_style::CaseStyleHelpers; +pub use self::type_props::HasTypeProperties; +pub use self::variant_props::HasStrumVariantProperties; + +pub mod case_style; +mod metadata; +pub mod type_props; +pub mod variant_props; + +use proc_macro2::Span; +use quote::ToTokens; +use syn::spanned::Spanned; + +pub fn non_enum_error() -> syn::Error { + syn::Error::new(Span::call_site(), "This macro only supports enums.") +} + +pub fn strum_discriminants_passthrough_error(span: &impl Spanned) -> syn::Error { + syn::Error::new( + span.span(), + "expected a pass-through attribute, e.g. #[strum_discriminants(serde(rename = \"var0\"))]", + ) +} + +pub fn occurrence_error<T: ToTokens>(fst: T, snd: T, attr: &str) -> syn::Error { + let mut e = syn::Error::new_spanned( + snd, + format!("Found multiple occurrences of strum({})", attr), + ); + e.combine(syn::Error::new_spanned(fst, "first one here")); + e +} |