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

add trybuild tests for OpenapiType and Resource derive macros

This commit is contained in:
Dominic 2020-05-09 15:29:29 +02:00
parent 9ed24c9bcb
commit 6680887b84
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
16 changed files with 149 additions and 3 deletions

View file

@ -108,7 +108,7 @@ fn expand_variant(variant : &Variant) -> Result<TokenStream>
{
if variant.fields != Fields::Unit
{
return Err(Error::new(variant.span(), "Enum Variants with Fields not supported"));
return Err(Error::new(variant.span(), "#[derive(OpenapiType)] does not support enum variants with fields"));
}
let ident = &variant.ident;
@ -173,7 +173,7 @@ fn expand_field(field : &Field) -> Result<TokenStream>
{
let ident = match &field.ident {
Some(ident) => ident,
None => return Err(Error::new(field.span(), "Fields without ident are not supported"))
None => return Err(Error::new(field.span(), "#[derive(OpenapiType)] does not support fields without an ident"))
};
let ty = &field.ty;
@ -242,7 +242,7 @@ fn expand_struct(ident : Ident, generics : Generics, attrs : Vec<Attribute>, inp
.map(expand_field)
.collect_to_result()?
},
Fields::Unnamed(fields) => return Err(Error::new(fields.span(), "Unnamed fields are not supported")),
Fields::Unnamed(fields) => return Err(Error::new(fields.span(), "#[derive(OpenapiType)] does not support unnamed fields")),
Fields::Unit => Vec::new()
};