1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-02-22 20:52:27 +00:00

allow &mut State in async fn (needs test)

This commit is contained in:
Dominic 2020-11-20 01:12:20 +01:00
parent 6ded517824
commit ce570c4787
Signed by: msrd0
GPG key ID: DCC8C247452E98F9

View file

@ -364,10 +364,10 @@ pub fn expand_method(method: Method, mut attrs: AttributeArgs, fun: ItemFn) -> R
let mut block = quote!(#fun_ident(#(#args_pass),*));
let mut state_block = quote!();
if fun_is_async {
if let Some(arg) = args.iter().find(|arg| (*arg).ty.is_state_ref()) {
if let Some(arg) = args.iter().find(|arg| matches!((*arg).ty, MethodArgumentType::StateRef)) {
return Err(Error::new(
arg.span(),
"async fn must not take &State as an argument as State is not Sync, consider boxing"
"async fn must not take &State as an argument as State is not Sync, consider taking &mut State"
));
}
block = quote!(#block.await);