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 11:37:58 UTC

[avro] branch branch-1.11 updated: Use fully qualified names for darling::FromAttributes and syn::Error (#1953)

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

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


The following commit(s) were added to refs/heads/branch-1.11 by this push:
     new 1e468325d Use fully qualified names for darling::FromAttributes and syn::Error (#1953)
1e468325d is described below

commit 1e468325d55f9484bdf0efc9dd098caff909f6bc
Author: Martin Grigorov <ma...@users.noreply.github.com>
AuthorDate: Fri Nov 11 13:37:20 2022 +0200

    Use fully qualified names for darling::FromAttributes and syn::Error (#1953)
    
    This makes it easier to read and reason about the code
    No functional changes!
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
    (cherry picked from commit 8917a8bc9e0d48612250ab0cb24b281aa54350a9)
---
 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",
         )])