From 75ef1f279dbbca39e3e67db8be19f7304c3d8800 Mon Sep 17 00:00:00 2001 From: Casper Meijn Date: Fri, 14 Feb 2025 10:59:17 +0100 Subject: [PATCH] build(deps): Update to darling 0.20 --- shellfn-attribute/Cargo.toml | 2 +- shellfn-attribute/src/lib.rs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/shellfn-attribute/Cargo.toml b/shellfn-attribute/Cargo.toml index c9a6abf..eb0b815 100644 --- a/shellfn-attribute/Cargo.toml +++ b/shellfn-attribute/Cargo.toml @@ -15,6 +15,6 @@ path = "src/lib.rs" syn = { version = "0.15.26", features = ["full", "extra-traits"] } quote = "0.6.11" proc-macro2 = "0.4.27" -darling = "0.8.3" +darling = "0.20" shellwords = "1.0.0" shellfn-core = { path = "../shellfn-core", version = "0.1.1" } \ No newline at end of file diff --git a/shellfn-attribute/src/lib.rs b/shellfn-attribute/src/lib.rs index ad48a62..1294dde 100644 --- a/shellfn-attribute/src/lib.rs +++ b/shellfn-attribute/src/lib.rs @@ -16,8 +16,19 @@ use syn::{Expr, ExprLit, Lit, Stmt}; #[proc_macro_attribute] pub fn shell(attr: TokenStream, input: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(input as syn::ItemFn); - let attr_args = syn::parse_macro_input!(attr as syn::AttributeArgs); - let attrs = Attributes::from_list(&attr_args).expect("Meta"); + + let parsed_attrs = match darling::ast::NestedMeta::parse_meta_list(attr.into()) { + Ok(v) => v, + Err(e) => { + return TokenStream::from(darling::Error::from(e).write_errors()); + } + }; + let attrs = match Attributes::from_list(&parsed_attrs) { + Ok(v) => v, + Err(e) => { + return TokenStream::from(e.write_errors()); + } + }; if let Some(Stmt::Expr(Expr::Lit(ExprLit { lit: Lit::Str(ref program),