Skip to content

Commit 82e46b7

Browse files
authored
Merge pull request #1147 from hermit-os/parse-quote
refactor(macro): replace `syn::parse2(quote!` with `parse_quote!`
2 parents 6301e34 + 5610abe commit 82e46b7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

hermit-macro/src/system.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use proc_macro2::{Ident, Span};
22
use quote::quote;
3-
use syn::{Abi, Attribute, Item, ItemFn, Pat, Result, Signature, Visibility};
3+
use syn::{parse_quote, Abi, Attribute, Item, ItemFn, Pat, Result, Signature, Visibility};
44

55
fn validate_vis(vis: &Visibility) -> Result<()> {
66
if !matches!(vis, Visibility::Public(_)) {
@@ -94,15 +94,15 @@ fn emit_func(mut func: ItemFn, sig: &ParsedSig) -> Result<ItemFn> {
9494
func_call
9595
};
9696

97-
let func = syn::parse2(quote! {
97+
let func = parse_quote! {
9898
#(#attrs)*
9999
#[no_mangle]
100100
#vis #sig {
101101
#func
102102

103103
#func_call
104104
}
105-
})?;
105+
};
106106

107107
Ok(func)
108108
}
@@ -123,7 +123,7 @@ mod tests {
123123

124124
#[test]
125125
fn test_safe() -> Result<()> {
126-
let input = syn::parse2(quote! {
126+
let input = parse_quote! {
127127
/// Adds two numbers together.
128128
///
129129
/// This is very important.
@@ -132,7 +132,7 @@ mod tests {
132132
let c = i16::from(a) + b;
133133
i32::from(c)
134134
}
135-
})?;
135+
};
136136

137137
let expected = quote! {
138138
/// Adds two numbers together.
@@ -159,7 +159,7 @@ mod tests {
159159

160160
#[test]
161161
fn test_unsafe() -> Result<()> {
162-
let input = syn::parse2(quote! {
162+
let input = parse_quote! {
163163
/// Adds two numbers together.
164164
///
165165
/// This is very important.
@@ -168,7 +168,7 @@ mod tests {
168168
let c = i16::from(a) + b;
169169
i32::from(c)
170170
}
171-
})?;
171+
};
172172

173173
let expected = quote! {
174174
/// Adds two numbers together.

0 commit comments

Comments
 (0)