mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-02-23 04:52:28 +00:00
emit proper error message for async fn read_all(state: &State)
This commit is contained in:
parent
110ef2be7a
commit
3de130e104
1 changed files with 9 additions and 0 deletions
|
@ -133,6 +133,11 @@ enum MethodArgumentType
|
||||||
|
|
||||||
impl MethodArgumentType
|
impl MethodArgumentType
|
||||||
{
|
{
|
||||||
|
fn is_state_ref(&self) -> bool
|
||||||
|
{
|
||||||
|
matches!(self, Self::StateRef | Self::StateMutRef)
|
||||||
|
}
|
||||||
|
|
||||||
fn is_method_arg(&self) -> bool
|
fn is_method_arg(&self) -> bool
|
||||||
{
|
{
|
||||||
matches!(self, Self::MethodArg(_))
|
matches!(self, Self::MethodArg(_))
|
||||||
|
@ -368,6 +373,10 @@ pub fn expand_method(method : Method, mut attrs : AttributeArgs, fun : ItemFn) -
|
||||||
let mut state_block = quote!();
|
let mut state_block = quote!();
|
||||||
if fun_is_async
|
if fun_is_async
|
||||||
{
|
{
|
||||||
|
if let Some(arg) = args.iter().find(|arg| (*arg).ty.is_state_ref())
|
||||||
|
{
|
||||||
|
return Err(Error::new(arg.span(), "async fn must not take &State as an argument as State is not Sync"));
|
||||||
|
}
|
||||||
block = quote!(#block.await);
|
block = quote!(#block.await);
|
||||||
}
|
}
|
||||||
if is_no_content
|
if is_no_content
|
||||||
|
|
Loading…
Add table
Reference in a new issue