Explorar o código

start playing around with other functions

henrye %!s(int64=2) %!d(string=hai) anos
pai
achega
b160da9860
Modificáronse 1 ficheiros con 12 adicións e 1 borrados
  1. 12 1
      lang/syn/src/parser/accounts/mod.rs

+ 12 - 1
lang/syn/src/parser/accounts/mod.rs

@@ -350,10 +350,21 @@ fn option_to_inner_path(path: &Path) -> ParseResult<Path> {
 }
 
 fn ident_string(f: &syn::Field) -> ParseResult<(String, bool, Path)> {
+    // TODO support parsing references to account infos
     let mut path = match &f.ty {
         syn::Type::Path(ty_path) => ty_path.path.clone(),
-        _ => return Err(ParseError::new(f.ty.span(), "invalid account type given")),
+        _ => {
+            return Err(ParseError::new_spanned(
+                f,
+                format!(
+                    "Field {} has a non-path type",
+                    f.ident.as_ref().expect("named fields only")
+                ),
+            ))
+        }
     };
+
+    // TODO replace string matching with helper functions using syn type match statments
     let mut optional = false;
     if parser::tts_to_string(&path)
         .replace(' ', "")