martin-g commented on code in PR #397:
URL: https://github.com/apache/avro-rs/pull/397#discussion_r2697458022


##########
avro_derive/src/lib.rs:
##########
@@ -166,7 +170,13 @@ fn get_data_struct_schema_def(
                     None => quote! { None },
                 };
                 let aliases = preserve_vec(field_attrs.alias);
-                let schema_expr = type_to_schema_expr(&field.ty)?;
+                let schema_expr = match field_attrs.with {
+                    With::Trait => type_to_schema_expr(&field.ty)?,
+                    With::Serde(path) => {
+                        quote! {#path::get_schema_in_ctxt(named_schemas, 
enclosing_namespace)}
+                    }
+                    With::Expr(expr) => quote! {#expr(named_schemas, 
enclosing_namespace)},

Review Comment:
   Is there anything else that mandates the `expr` to be a function ?
   I don't see any restrictions in avro.rs and mod.rs to verify that the 
provided expression is a syn::Expr::Call.
   
   My main question is: What leads to `expected function` in errors like 
`error[E0618]: expected function, found apache_avro::Schema` ?
   
   I am experimenting with
   ```diff
                            quote! {#path::get_schema_in_ctxt(named_schemas, 
enclosing_namespace)}
                        }
   -                    With::Expr(expr) => quote! {#expr(named_schemas, 
enclosing_namespace)},
   +                    With::Expr(expr) => match expr {
   +                        Expr::Closure(closure) => {
   +                            dbg!("==========");
   +                            quote! {#closure()}
   +                        }
   +                        _ => quote! {#expr(named_schemas, 
enclosing_namespace)},
   +                    },
                    };
   ```
   but it seems something earlier makes the check for a `function`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to