1
1
use proc_macro2:: { Ident , Span } ;
2
2
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 } ;
4
4
5
5
fn validate_vis ( vis : & Visibility ) -> Result < ( ) > {
6
6
if !matches ! ( vis, Visibility :: Public ( _) ) {
@@ -94,15 +94,15 @@ fn emit_func(mut func: ItemFn, sig: &ParsedSig) -> Result<ItemFn> {
94
94
func_call
95
95
} ;
96
96
97
- let func = syn :: parse2 ( quote ! {
97
+ let func = parse_quote ! {
98
98
#( #attrs) *
99
99
#[ no_mangle]
100
100
#vis #sig {
101
101
#func
102
102
103
103
#func_call
104
104
}
105
- } ) ? ;
105
+ } ;
106
106
107
107
Ok ( func)
108
108
}
@@ -123,7 +123,7 @@ mod tests {
123
123
124
124
#[ test]
125
125
fn test_safe ( ) -> Result < ( ) > {
126
- let input = syn :: parse2 ( quote ! {
126
+ let input = parse_quote ! {
127
127
/// Adds two numbers together.
128
128
///
129
129
/// This is very important.
@@ -132,7 +132,7 @@ mod tests {
132
132
let c = i16 :: from( a) + b;
133
133
i32 :: from( c)
134
134
}
135
- } ) ? ;
135
+ } ;
136
136
137
137
let expected = quote ! {
138
138
/// Adds two numbers together.
@@ -159,7 +159,7 @@ mod tests {
159
159
160
160
#[ test]
161
161
fn test_unsafe ( ) -> Result < ( ) > {
162
- let input = syn :: parse2 ( quote ! {
162
+ let input = parse_quote ! {
163
163
/// Adds two numbers together.
164
164
///
165
165
/// This is very important.
@@ -168,7 +168,7 @@ mod tests {
168
168
let c = i16 :: from( a) + b;
169
169
i32 :: from( c)
170
170
}
171
- } ) ? ;
171
+ } ;
172
172
173
173
let expected = quote ! {
174
174
/// Adds two numbers together.
0 commit comments