Replace syn::Error::to_compile_error with into_compile_error

This commit is contained in:
Jonas Platte 2021-03-09 19:12:21 +01:00
parent 4d51e98707
commit ad608c0013
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
3 changed files with 16 additions and 16 deletions

View File

@ -23,5 +23,5 @@ mod util;
#[proc_macro] #[proc_macro]
pub fn ruma_api(input: TokenStream) -> TokenStream { pub fn ruma_api(input: TokenStream) -> TokenStream {
let api = parse_macro_input!(input as Api); let api = parse_macro_input!(input as Api);
api::expand_all(api).unwrap_or_else(|err| err.to_compile_error()).into() api::expand_all(api).unwrap_or_else(syn::Error::into_compile_error).into()
} }

View File

@ -48,7 +48,7 @@ mod event_parse;
#[proc_macro] #[proc_macro]
pub fn event_enum(input: TokenStream) -> TokenStream { pub fn event_enum(input: TokenStream) -> TokenStream {
let event_enum_input = syn::parse_macro_input!(input as EventEnumInput); let event_enum_input = syn::parse_macro_input!(input as EventEnumInput);
expand_event_enum(event_enum_input).unwrap_or_else(|err| err.to_compile_error()).into() expand_event_enum(event_enum_input).unwrap_or_else(syn::Error::into_compile_error).into()
} }
/// Generates an implementation of `ruma_events::EventContent`. /// Generates an implementation of `ruma_events::EventContent`.
@ -58,7 +58,7 @@ pub fn derive_event_content(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_event_content(&input, true, &ruma_events) expand_event_content(&input, true, &ruma_events)
.unwrap_or_else(|err| err.to_compile_error()) .unwrap_or_else(syn::Error::into_compile_error)
.into() .into()
} }
@ -69,7 +69,7 @@ pub fn derive_basic_event_content(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_basic_event_content(&input, &ruma_events) expand_basic_event_content(&input, &ruma_events)
.unwrap_or_else(|err| err.to_compile_error()) .unwrap_or_else(syn::Error::into_compile_error)
.into() .into()
} }
@ -80,7 +80,7 @@ pub fn derive_room_event_content(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_room_event_content(&input, &ruma_events) expand_room_event_content(&input, &ruma_events)
.unwrap_or_else(|err| err.to_compile_error()) .unwrap_or_else(syn::Error::into_compile_error)
.into() .into()
} }
@ -91,7 +91,7 @@ pub fn derive_message_event_content(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_message_event_content(&input, &ruma_events) expand_message_event_content(&input, &ruma_events)
.unwrap_or_else(|err| err.to_compile_error()) .unwrap_or_else(syn::Error::into_compile_error)
.into() .into()
} }
@ -102,7 +102,7 @@ pub fn derive_state_event_content(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_state_event_content(&input, &ruma_events) expand_state_event_content(&input, &ruma_events)
.unwrap_or_else(|err| err.to_compile_error()) .unwrap_or_else(syn::Error::into_compile_error)
.into() .into()
} }
@ -113,7 +113,7 @@ pub fn derive_ephemeral_room_event_content(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_ephemeral_room_event_content(&input, &ruma_events) expand_ephemeral_room_event_content(&input, &ruma_events)
.unwrap_or_else(|err| err.to_compile_error()) .unwrap_or_else(syn::Error::into_compile_error)
.into() .into()
} }
@ -121,7 +121,7 @@ pub fn derive_ephemeral_room_event_content(input: TokenStream) -> TokenStream {
#[proc_macro_derive(Event, attributes(ruma_event))] #[proc_macro_derive(Event, attributes(ruma_event))]
pub fn derive_state_event(input: TokenStream) -> TokenStream { pub fn derive_state_event(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_event(input).unwrap_or_else(|err| err.to_compile_error()).into() expand_event(input).unwrap_or_else(syn::Error::into_compile_error).into()
} }
pub(crate) fn import_ruma_events() -> pm2::TokenStream { pub(crate) fn import_ruma_events() -> pm2::TokenStream {

View File

@ -64,19 +64,19 @@ struct IncomingMyType {
#[proc_macro_derive(Outgoing, attributes(incoming_derive))] #[proc_macro_derive(Outgoing, attributes(incoming_derive))]
pub fn derive_outgoing(input: TokenStream) -> TokenStream { pub fn derive_outgoing(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_derive_outgoing(input).unwrap_or_else(|err| err.to_compile_error()).into() expand_derive_outgoing(input).unwrap_or_else(syn::Error::into_compile_error).into()
} }
#[proc_macro_derive(AsRefStr, attributes(ruma_enum))] #[proc_macro_derive(AsRefStr, attributes(ruma_enum))]
pub fn derive_enum_as_ref_str(input: TokenStream) -> TokenStream { pub fn derive_enum_as_ref_str(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as ItemEnum); let input = parse_macro_input!(input as ItemEnum);
expand_enum_as_ref_str(&input).unwrap_or_else(|err| err.to_compile_error()).into() expand_enum_as_ref_str(&input).unwrap_or_else(syn::Error::into_compile_error).into()
} }
#[proc_macro_derive(FromString, attributes(ruma_enum))] #[proc_macro_derive(FromString, attributes(ruma_enum))]
pub fn derive_enum_from_string(input: TokenStream) -> TokenStream { pub fn derive_enum_from_string(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as ItemEnum); let input = parse_macro_input!(input as ItemEnum);
expand_enum_from_string(&input).unwrap_or_else(|err| err.to_compile_error()).into() expand_enum_from_string(&input).unwrap_or_else(syn::Error::into_compile_error).into()
} }
// FIXME: The following macros aren't actually interested in type details beyond name (and possibly // FIXME: The following macros aren't actually interested in type details beyond name (and possibly
@ -85,20 +85,20 @@ pub fn derive_enum_from_string(input: TokenStream) -> TokenStream {
#[proc_macro_derive(DisplayAsRefStr)] #[proc_macro_derive(DisplayAsRefStr)]
pub fn derive_display_as_ref_str(input: TokenStream) -> TokenStream { pub fn derive_display_as_ref_str(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_display_as_ref_str(&input.ident).unwrap_or_else(|err| err.to_compile_error()).into() expand_display_as_ref_str(&input.ident).unwrap_or_else(syn::Error::into_compile_error).into()
} }
#[proc_macro_derive(SerializeAsRefStr)] #[proc_macro_derive(SerializeAsRefStr)]
pub fn derive_serialize_as_ref_str(input: TokenStream) -> TokenStream { pub fn derive_serialize_as_ref_str(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_serialize_as_ref_str(&input.ident).unwrap_or_else(|err| err.to_compile_error()).into() expand_serialize_as_ref_str(&input.ident).unwrap_or_else(syn::Error::into_compile_error).into()
} }
#[proc_macro_derive(DeserializeFromCowStr)] #[proc_macro_derive(DeserializeFromCowStr)]
pub fn derive_deserialize_from_cow_str(input: TokenStream) -> TokenStream { pub fn derive_deserialize_from_cow_str(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);
expand_deserialize_from_cow_str(&input.ident) expand_deserialize_from_cow_str(&input.ident)
.unwrap_or_else(|err| err.to_compile_error()) .unwrap_or_else(syn::Error::into_compile_error)
.into() .into()
} }
@ -123,7 +123,7 @@ pub fn derive_string_enum(input: TokenStream) -> TokenStream {
} }
let input = parse_macro_input!(input as ItemEnum); let input = parse_macro_input!(input as ItemEnum);
expand_all(input).unwrap_or_else(|err| err.to_compile_error()).into() expand_all(input).unwrap_or_else(syn::Error::into_compile_error).into()
} }
/// A derive macro that generates no code, but registers the serde attribute so both `#[serde(...)]` /// A derive macro that generates no code, but registers the serde attribute so both `#[serde(...)]`