1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-07-16 01:01:28 +00:00

use less non-public syn api

This commit is contained in:
Dominic 2020-05-03 23:43:42 +02:00
parent 5e5e3aaf9d
commit 992d9be195
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
6 changed files with 10 additions and 14 deletions

View file

@ -151,10 +151,7 @@ impl MethodArgumentType
fn quote_ty(&self) -> Option<TokenStream2>
{
match self {
Self::MethodArg(ty) => Some(quote!(#ty)),
Self::DatabaseConnection(ty) => Some(quote!(#ty)),
Self::AuthStatus(ty) => Some(quote!(#ty)),
Self::AuthStatusRef(ty) => Some(quote!(#ty)),
Self::MethodArg(ty) | Self::DatabaseConnection(ty) | Self::AuthStatus(ty) | Self::AuthStatusRef(ty) => Some(quote!(#ty)),
_ => None
}
}
@ -280,7 +277,8 @@ fn expand(method : Method, attrs : TokenStream, item : TokenStream) -> Result<To
let krate = super::krate();
// parse attributes
let mut method_attrs = parse_macro_input::parse::<AttributeArgs>(attrs)?;
// TODO this is not public api but syn currently doesn't offer another convenient way to parse AttributeArgs
let mut method_attrs : AttributeArgs = parse_macro_input::parse(attrs)?;
let resource_path = match method_attrs.remove(0) {
NestedMeta::Meta(Meta::Path(path)) => path,
p => return Err(Error::new(p.span(), "Expected name of the Resource struct this method belongs to"))
@ -288,7 +286,7 @@ fn expand(method : Method, attrs : TokenStream, item : TokenStream) -> Result<To
let resource_name = resource_path.segments.last().map(|s| s.ident.to_string())
.ok_or_else(|| Error::new(resource_path.span(), "Resource name must not be empty"))?;
let fun = parse_macro_input::parse::<ItemFn>(item)?;
let fun : ItemFn = syn::parse(item)?;
let fun_ident = &fun.sig.ident;
let fun_vis = &fun.vis;
let fun_is_async = fun.sig.asyncness.is_some();