Skip to content

Commit

Permalink
Merge pull request #197 from ephraimkunz/fix-nonlocal-impl
Browse files Browse the repository at this point in the history
Fix non-local impl definition errors
  • Loading branch information
MarcAntoine-Arnaud authored Oct 31, 2024
2 parents 5cd0918 + 4c8595b commit 8d20bf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions yaserde_derive/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod expand_enum;
pub mod expand_struct;

use crate::common::YaSerdeAttribute;
use proc_macro2::{Ident, TokenStream};
use proc_macro2::TokenStream;
use quote::quote;

pub fn expand_derive_deserialize(ast: &syn::DeriveInput) -> Result<TokenStream, String> {
Expand Down Expand Up @@ -42,11 +42,9 @@ pub fn expand_derive_deserialize(ast: &syn::DeriveInput) -> Result<TokenStream,
syn::Data::Union(ref _data_union) => unimplemented!(),
};

let dummy_const = Ident::new(&format!("_IMPL_YA_DESERIALIZE_FOR_{}", name), name.span());

Ok(quote! {
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const #dummy_const: () = {
const _: () = {
use ::std::str::FromStr as _;
use ::yaserde::Visitor as _;

Expand Down
6 changes: 2 additions & 4 deletions yaserde_derive/src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod label;
pub mod namespace;

use crate::common::YaSerdeAttribute;
use proc_macro2::{Ident, TokenStream};
use proc_macro2::TokenStream;
use quote::quote;

pub fn expand_derive_serialize(ast: &syn::DeriveInput) -> Result<TokenStream, String> {
Expand All @@ -33,11 +33,9 @@ pub fn expand_derive_serialize(ast: &syn::DeriveInput) -> Result<TokenStream, St
syn::Data::Union(ref _data_union) => unimplemented!(),
};

let dummy_const = Ident::new(&format!("_IMPL_YA_SERIALIZE_FOR_{}", name), name.span());

Ok(quote! {
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const #dummy_const: () = {
const _: () = {
use ::std::str::FromStr as _;

#impl_block
Expand Down

0 comments on commit 8d20bf2

Please sign in to comment.