macros: Rename error_ty => error

This commit is contained in:
Jonas Platte 2022-10-24 15:06:45 +02:00
parent 1be2def65a
commit c021a14b60
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C
5 changed files with 13 additions and 13 deletions

View File

@ -98,7 +98,7 @@ impl Request {
)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[incoming_derive(!Deserialize, #ruma_macros::_FakeDeriveRumaApi)]
#[ruma_api(error_ty = #error_ty)]
#[ruma_api(error = #error_ty)]
#( #struct_attributes )*
pub struct #request_ident < #(#lifetimes),* > {
#fields

View File

@ -44,7 +44,7 @@ impl Response {
)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[incoming_derive(!Deserialize, #ruma_macros::_FakeDeriveRumaApi)]
#[ruma_api(error_ty = #error_ty)]
#[ruma_api(error = #error_ty)]
#( #struct_attributes )*
pub struct #response_ident {
#fields

View File

@ -12,7 +12,7 @@ mod kw {
syn::custom_keyword!(query);
syn::custom_keyword!(query_map);
syn::custom_keyword!(header);
syn::custom_keyword!(error_ty);
syn::custom_keyword!(error);
syn::custom_keyword!(manual_body_serde);
}
@ -54,16 +54,16 @@ impl Parse for RequestMeta {
}
pub enum DeriveRequestMeta {
ErrorTy(Type),
Error(Type),
}
impl Parse for DeriveRequestMeta {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let lookahead = input.lookahead1();
if lookahead.peek(kw::error_ty) {
let _: kw::error_ty = input.parse()?;
if lookahead.peek(kw::error) {
let _: kw::error = input.parse()?;
let _: Token![=] = input.parse()?;
input.parse().map(Self::ErrorTy)
input.parse().map(Self::Error)
} else {
Err(lookahead.error())
}
@ -98,7 +98,7 @@ impl Parse for ResponseMeta {
#[allow(clippy::large_enum_variant)]
pub enum DeriveResponseMeta {
ManualBodySerde,
ErrorTy(Type),
Error(Type),
}
impl Parse for DeriveResponseMeta {
@ -107,10 +107,10 @@ impl Parse for DeriveResponseMeta {
if lookahead.peek(kw::manual_body_serde) {
let _: kw::manual_body_serde = input.parse()?;
Ok(Self::ManualBodySerde)
} else if lookahead.peek(kw::error_ty) {
let _: kw::error_ty = input.parse()?;
} else if lookahead.peek(kw::error) {
let _: kw::error = input.parse()?;
let _: Token![=] = input.parse()?;
input.parse().map(Self::ErrorTy)
input.parse().map(Self::Error)
} else {
Err(lookahead.error())
}

View File

@ -55,7 +55,7 @@ pub fn expand_derive_request(input: DeriveInput) -> syn::Result<TokenStream> {
attr.parse_args_with(Punctuated::<DeriveRequestMeta, Token![,]>::parse_terminated)?;
for meta in metas {
match meta {
DeriveRequestMeta::ErrorTy(t) => error_ty = Some(t),
DeriveRequestMeta::Error(t) => error_ty = Some(t),
}
}
}

View File

@ -34,7 +34,7 @@ pub fn expand_derive_response(input: DeriveInput) -> syn::Result<TokenStream> {
for meta in metas {
match meta {
DeriveResponseMeta::ManualBodySerde => manual_body_serde = true,
DeriveResponseMeta::ErrorTy(t) => error_ty = Some(t),
DeriveResponseMeta::Error(t) => error_ty = Some(t),
}
}
}