macros: Silence deprecation warnings in generated code

This commit is contained in:
Jonas Platte 2022-03-15 17:05:38 +01:00
parent cdc6b9a2aa
commit e86ee7dd31
No known key found for this signature in database
GPG Key ID: BBA95679259D342F
7 changed files with 8 additions and 0 deletions

View File

@ -8,6 +8,7 @@ pub fn expand_deserialize_from_cow_str(ident: &Ident) -> syn::Result<TokenStream
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl<'de> #ruma_common::exports::serde::de::Deserialize<'de> for #ident {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where

View File

@ -4,6 +4,7 @@ use quote::quote;
pub fn expand_display_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl ::std::fmt::Display for #ident {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str(::std::convert::AsRef::<::std::primitive::str>::as_ref(self))

View File

@ -50,6 +50,7 @@ pub fn expand_enum_as_ref_str(input: &ItemEnum) -> syn::Result<TokenStream> {
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl ::std::convert::AsRef<::std::primitive::str> for #enum_name {
fn as_ref(&self) -> &::std::primitive::str {
match self { #(#branches),* }

View File

@ -69,6 +69,7 @@ pub fn expand_enum_from_string(input: &ItemEnum) -> syn::Result<TokenStream> {
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl<T> ::std::convert::From<T> for #enum_name
where
T: ::std::convert::AsRef<::std::primitive::str>

View File

@ -4,6 +4,7 @@ use quote::quote;
pub fn expand_partial_eq_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl ::std::cmp::PartialEq for #ident {
fn eq(&self, other: &Self) -> bool {
let other = ::std::convert::AsRef::<::std::primitive::str>::as_ref(other);

View File

@ -4,6 +4,7 @@ use quote::quote;
pub fn expand_partial_ord_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl ::std::cmp::PartialOrd for #ident {
fn partial_cmp(&self, other: &Self) -> ::std::option::Option<::std::cmp::Ordering> {
let other = ::std::convert::AsRef::<::std::primitive::str>::as_ref(other);
@ -16,6 +17,7 @@ pub fn expand_partial_ord_as_ref_str(ident: &Ident) -> syn::Result<TokenStream>
pub fn expand_ord_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl ::std::cmp::Ord for #ident {
fn cmp(&self, other: &Self) -> ::std::cmp::Ordering {
let other = ::std::convert::AsRef::<::std::primitive::str>::as_ref(other);

View File

@ -8,6 +8,7 @@ pub fn expand_serialize_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl #ruma_common::exports::serde::ser::Serialize for #ident {
fn serialize<S>(&self, serializer: S) -> ::std::result::Result<S::Ok, S::Error>
where