Skip to content

Commit

Permalink
Merge pull request #1147 from hermit-os/parse-quote
Browse files Browse the repository at this point in the history
refactor(macro): replace `syn::parse2(quote!` with `parse_quote!`
  • Loading branch information
mkroening authored Apr 20, 2024
2 parents 6301e34 + 5610abe commit 82e46b7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions hermit-macro/src/system.rs
Original file line number Diff line number Diff line change
@@ -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(_)) {
Expand Down Expand Up @@ -94,15 +94,15 @@ fn emit_func(mut func: ItemFn, sig: &ParsedSig) -> Result<ItemFn> {
func_call
};

let func = syn::parse2(quote! {
let func = parse_quote! {
#(#attrs)*
#[no_mangle]
#vis #sig {
#func

#func_call
}
})?;
};

Ok(func)
}
Expand All @@ -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.
Expand All @@ -132,7 +132,7 @@ mod tests {
let c = i16::from(a) + b;
i32::from(c)
}
})?;
};

let expected = quote! {
/// Adds two numbers together.
Expand All @@ -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.
Expand All @@ -168,7 +168,7 @@ mod tests {
let c = i16::from(a) + b;
i32::from(c)
}
})?;
};

let expected = quote! {
/// Adds two numbers together.
Expand Down

0 comments on commit 82e46b7

Please sign in to comment.