@@ -5,7 +5,7 @@ use darling::FromMeta;
5
5
use heck:: { ToKebabCase , ToLowerCamelCase , ToShoutySnakeCase , ToSnakeCase , ToUpperCamelCase } ;
6
6
use proc_macro2:: { Literal , TokenStream } ;
7
7
use quote:: { format_ident, quote} ;
8
- use syn:: { Attribute , FnArg , Ident , Pat , Signature , Type } ;
8
+ use syn:: { spanned :: Spanned , Attribute , FnArg , Ident , Pat , Signature , Type } ;
9
9
10
10
use proxy:: proxy_macro;
11
11
use service:: service_macro;
@@ -51,7 +51,7 @@ impl MethodAttributes {
51
51
52
52
pub ( crate ) struct RpcMethod < ' a > {
53
53
signature : & ' a Signature ,
54
- args : Vec < ( & ' a Ident , & ' a Type ) > ,
54
+ args : Vec < ( Ident , & ' a Type ) > ,
55
55
method_name : String ,
56
56
method_name_literal : Literal ,
57
57
args_struct_ident : Ident ,
@@ -67,6 +67,7 @@ impl<'a> RpcMethod<'a> {
67
67
) -> Self {
68
68
let mut has_self = false ;
69
69
let mut args = vec ! [ ] ;
70
+ let rename_all = rename_all. as_ref ( ) ;
70
71
71
72
for arg in & signature. inputs {
72
73
match arg {
@@ -75,7 +76,12 @@ impl<'a> RpcMethod<'a> {
75
76
}
76
77
FnArg :: Typed ( pat_type) => {
77
78
let ident = match & * pat_type. pat {
78
- Pat :: Ident ( ty) => & ty. ident ,
79
+ Pat :: Ident ( ty) => {
80
+ let fn_arg = rename_all
81
+ . map ( |r| r. rename ( & ty. ident . to_string ( ) ) )
82
+ . unwrap_or ( ty. ident . to_string ( ) ) ;
83
+ Ident :: new ( & fn_arg, ty. span ( ) . clone ( ) )
84
+ }
79
85
_ => panic ! ( "Arguments must not be patterns." ) ,
80
86
} ;
81
87
args. push ( ( ident, & * pat_type. ty ) ) ;
@@ -92,7 +98,6 @@ impl<'a> RpcMethod<'a> {
92
98
93
99
let method_name = signature. ident . to_string ( ) ;
94
100
let method_name = rename_all
95
- . as_ref ( )
96
101
. map ( |r| r. rename ( & method_name) )
97
102
. unwrap_or ( method_name) ;
98
103
let method_name_literal = Literal :: string ( & method_name) ;
@@ -120,6 +125,7 @@ impl<'a> RpcMethod<'a> {
120
125
let tokens = quote ! {
121
126
#[ derive( Debug , :: serde:: Serialize , :: serde:: Deserialize ) ]
122
127
#[ allow( non_camel_case_types) ]
128
+ #[ allow( non_snake_case) ]
123
129
struct #args_struct_ident {
124
130
#( #struct_fields) *
125
131
}
@@ -213,6 +219,7 @@ impl<'a> RpcMethod<'a> {
213
219
} ;
214
220
215
221
quote ! {
222
+ #[ allow( non_snake_case) ]
216
223
async fn #method_ident( & mut self , #( #method_args) , * ) #output {
217
224
let args = #args_struct_ident {
218
225
#( #struct_fields) , *
0 commit comments