You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/11/11 10:57:32 UTC

[avro] 01/01: Use fully qualified names for darling::FromAttributes and syn::Error

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch fqn-proc-macro
in repository https://gitbox.apache.org/repos/asf/avro.git

commit 9dc89421eb6564228b6fff294c62440025b07372
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Wed Nov 9 09:47:18 2022 +0200

    Use fully qualified names for darling::FromAttributes and syn::Error
    
    This makes it easier to read and reason about the code
    No functional changes!
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
 lang/rust/avro_derive/src/lib.rs | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/lang/rust/avro_derive/src/lib.rs b/lang/rust/avro_derive/src/lib.rs
index 238d95b18..8f6a9b70a 100644
--- a/lang/rust/avro_derive/src/lib.rs
+++ b/lang/rust/avro_derive/src/lib.rs
@@ -21,11 +21,9 @@ use darling::FromAttributes;
 use proc_macro2::{Span, TokenStream};
 use quote::quote;
 
-use syn::{
-    parse_macro_input, spanned::Spanned, AttrStyle, Attribute, DeriveInput, Error, Type, TypePath,
-};
+use syn::{parse_macro_input, spanned::Spanned, AttrStyle, Attribute, DeriveInput, Type, TypePath};
 
-#[derive(FromAttributes)]
+#[derive(darling::FromAttributes)]
 #[darling(attributes(avro))]
 struct FieldOptions {
     #[darling(default)]
@@ -38,7 +36,7 @@ struct FieldOptions {
     skip: Option<bool>,
 }
 
-#[derive(FromAttributes)]
+#[derive(darling::FromAttributes)]
 #[darling(attributes(avro))]
 struct NamedTypeOptions {
     #[darling(default)]
@@ -86,7 +84,7 @@ fn derive_avro_schema(input: &mut DeriveInput) -> Result<TokenStream, Vec<syn::E
             input.ident.span(),
         )?,
         _ => {
-            return Err(vec![Error::new(
+            return Err(vec![syn::Error::new(
                 input.ident.span(),
                 "AvroSchema derive only works for structs and simple enums ",
             )])
@@ -139,7 +137,7 @@ fn get_data_struct_schema_def(
                     Some(default_value) => {
                         let _: serde_json::Value = serde_json::from_str(&default_value[..])
                             .map_err(|e| {
-                                vec![Error::new(
+                                vec![syn::Error::new(
                                     field.ident.span(),
                                     format!("Invalid avro default json: \n{}", e),
                                 )]
@@ -167,13 +165,13 @@ fn get_data_struct_schema_def(
             }
         }
         syn::Fields::Unnamed(_) => {
-            return Err(vec![Error::new(
+            return Err(vec![syn::Error::new(
                 error_span,
                 "AvroSchema derive does not work for tuple structs",
             )])
         }
         syn::Fields::Unit => {
-            return Err(vec![Error::new(
+            return Err(vec![syn::Error::new(
                 error_span,
                 "AvroSchema derive does not work for unit structs",
             )])
@@ -224,7 +222,7 @@ fn get_data_enum_schema_def(
             }
         })
     } else {
-        Err(vec![Error::new(
+        Err(vec![syn::Error::new(
             error_span,
             "AvroSchema derive does not work for enums with non unit structs",
         )])