macros: Rename error_ty => error
This commit is contained in:
parent
1be2def65a
commit
c021a14b60
@ -98,7 +98,7 @@ impl Request {
|
|||||||
)]
|
)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[incoming_derive(!Deserialize, #ruma_macros::_FakeDeriveRumaApi)]
|
#[incoming_derive(!Deserialize, #ruma_macros::_FakeDeriveRumaApi)]
|
||||||
#[ruma_api(error_ty = #error_ty)]
|
#[ruma_api(error = #error_ty)]
|
||||||
#( #struct_attributes )*
|
#( #struct_attributes )*
|
||||||
pub struct #request_ident < #(#lifetimes),* > {
|
pub struct #request_ident < #(#lifetimes),* > {
|
||||||
#fields
|
#fields
|
||||||
|
@ -44,7 +44,7 @@ impl Response {
|
|||||||
)]
|
)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[incoming_derive(!Deserialize, #ruma_macros::_FakeDeriveRumaApi)]
|
#[incoming_derive(!Deserialize, #ruma_macros::_FakeDeriveRumaApi)]
|
||||||
#[ruma_api(error_ty = #error_ty)]
|
#[ruma_api(error = #error_ty)]
|
||||||
#( #struct_attributes )*
|
#( #struct_attributes )*
|
||||||
pub struct #response_ident {
|
pub struct #response_ident {
|
||||||
#fields
|
#fields
|
||||||
|
@ -12,7 +12,7 @@ mod kw {
|
|||||||
syn::custom_keyword!(query);
|
syn::custom_keyword!(query);
|
||||||
syn::custom_keyword!(query_map);
|
syn::custom_keyword!(query_map);
|
||||||
syn::custom_keyword!(header);
|
syn::custom_keyword!(header);
|
||||||
syn::custom_keyword!(error_ty);
|
syn::custom_keyword!(error);
|
||||||
syn::custom_keyword!(manual_body_serde);
|
syn::custom_keyword!(manual_body_serde);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,16 +54,16 @@ impl Parse for RequestMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum DeriveRequestMeta {
|
pub enum DeriveRequestMeta {
|
||||||
ErrorTy(Type),
|
Error(Type),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for DeriveRequestMeta {
|
impl Parse for DeriveRequestMeta {
|
||||||
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let lookahead = input.lookahead1();
|
let lookahead = input.lookahead1();
|
||||||
if lookahead.peek(kw::error_ty) {
|
if lookahead.peek(kw::error) {
|
||||||
let _: kw::error_ty = input.parse()?;
|
let _: kw::error = input.parse()?;
|
||||||
let _: Token![=] = input.parse()?;
|
let _: Token![=] = input.parse()?;
|
||||||
input.parse().map(Self::ErrorTy)
|
input.parse().map(Self::Error)
|
||||||
} else {
|
} else {
|
||||||
Err(lookahead.error())
|
Err(lookahead.error())
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ impl Parse for ResponseMeta {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DeriveResponseMeta {
|
pub enum DeriveResponseMeta {
|
||||||
ManualBodySerde,
|
ManualBodySerde,
|
||||||
ErrorTy(Type),
|
Error(Type),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for DeriveResponseMeta {
|
impl Parse for DeriveResponseMeta {
|
||||||
@ -107,10 +107,10 @@ impl Parse for DeriveResponseMeta {
|
|||||||
if lookahead.peek(kw::manual_body_serde) {
|
if lookahead.peek(kw::manual_body_serde) {
|
||||||
let _: kw::manual_body_serde = input.parse()?;
|
let _: kw::manual_body_serde = input.parse()?;
|
||||||
Ok(Self::ManualBodySerde)
|
Ok(Self::ManualBodySerde)
|
||||||
} else if lookahead.peek(kw::error_ty) {
|
} else if lookahead.peek(kw::error) {
|
||||||
let _: kw::error_ty = input.parse()?;
|
let _: kw::error = input.parse()?;
|
||||||
let _: Token![=] = input.parse()?;
|
let _: Token![=] = input.parse()?;
|
||||||
input.parse().map(Self::ErrorTy)
|
input.parse().map(Self::Error)
|
||||||
} else {
|
} else {
|
||||||
Err(lookahead.error())
|
Err(lookahead.error())
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ pub fn expand_derive_request(input: DeriveInput) -> syn::Result<TokenStream> {
|
|||||||
attr.parse_args_with(Punctuated::<DeriveRequestMeta, Token![,]>::parse_terminated)?;
|
attr.parse_args_with(Punctuated::<DeriveRequestMeta, Token![,]>::parse_terminated)?;
|
||||||
for meta in metas {
|
for meta in metas {
|
||||||
match meta {
|
match meta {
|
||||||
DeriveRequestMeta::ErrorTy(t) => error_ty = Some(t),
|
DeriveRequestMeta::Error(t) => error_ty = Some(t),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ pub fn expand_derive_response(input: DeriveInput) -> syn::Result<TokenStream> {
|
|||||||
for meta in metas {
|
for meta in metas {
|
||||||
match meta {
|
match meta {
|
||||||
DeriveResponseMeta::ManualBodySerde => manual_body_serde = true,
|
DeriveResponseMeta::ManualBodySerde => manual_body_serde = true,
|
||||||
DeriveResponseMeta::ErrorTy(t) => error_ty = Some(t),
|
DeriveResponseMeta::Error(t) => error_ty = Some(t),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user