From 5610abef5c495b8a6451aa011991053c09c17133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Sat, 20 Apr 2024 23:44:13 +0200 Subject: [PATCH] refactor(macro): replace `syn::parse2(quote!` with `parse_quote!` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- hermit-macro/src/system.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hermit-macro/src/system.rs b/hermit-macro/src/system.rs index ef9a91ec1a..72d352548b 100644 --- a/hermit-macro/src/system.rs +++ b/hermit-macro/src/system.rs @@ -1,6 +1,6 @@ use proc_macro2::{Ident, Span}; use quote::quote; -use syn::{Abi, Attribute, Item, ItemFn, Pat, Result, Signature, Visibility}; +use syn::{parse_quote, Abi, Attribute, Item, ItemFn, Pat, Result, Signature, Visibility}; fn validate_vis(vis: &Visibility) -> Result<()> { if !matches!(vis, Visibility::Public(_)) { @@ -94,7 +94,7 @@ fn emit_func(mut func: ItemFn, sig: &ParsedSig) -> Result { func_call }; - let func = syn::parse2(quote! { + let func = parse_quote! { #(#attrs)* #[no_mangle] #vis #sig { @@ -102,7 +102,7 @@ fn emit_func(mut func: ItemFn, sig: &ParsedSig) -> Result { #func_call } - })?; + }; Ok(func) } @@ -123,7 +123,7 @@ mod tests { #[test] fn test_safe() -> Result<()> { - let input = syn::parse2(quote! { + let input = parse_quote! { /// Adds two numbers together. /// /// This is very important. @@ -132,7 +132,7 @@ mod tests { let c = i16::from(a) + b; i32::from(c) } - })?; + }; let expected = quote! { /// Adds two numbers together. @@ -159,7 +159,7 @@ mod tests { #[test] fn test_unsafe() -> Result<()> { - let input = syn::parse2(quote! { + let input = parse_quote! { /// Adds two numbers together. /// /// This is very important. @@ -168,7 +168,7 @@ mod tests { let c = i16::from(a) + b; i32::from(c) } - })?; + }; let expected = quote! { /// Adds two numbers together.