Skip to content

Change savefile-derive dummy constants to be anonymous #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions savefile-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ fn savefile_derive_crate_serialize(input: DeriveInput) -> TokenStream {
let saveerr = quote_spanned! {defspan=>
Result<(),_savefile::prelude::SavefileError>
};
let magic = format!("_IMPL_SAVEFILE_SERIALIZE_FOR_{}", &name).to_string();
let dummy_const = syn::Ident::new(&magic, proc_macro2::Span::call_site());

let dummy_const = syn::Ident::new("_", proc_macro2::Span::call_site());

let expanded = match &input.data {
&syn::Data::Enum(ref enum1) => {
Expand Down Expand Up @@ -978,8 +978,7 @@ fn savefile_derive_crate_deserialize(input: DeriveInput) -> TokenStream {
_savefile::prelude::SavefileError
};

let magic = format!("_IMPL_SAVEFILE_DESERIALIZE_FOR_{}", &name).to_string();
let dummy_const = syn::Ident::new(&magic, proc_macro2::Span::call_site());
let dummy_const = syn::Ident::new("_", proc_macro2::Span::call_site());

let expanded = match &input.data {
&syn::Data::Enum(ref enum1) => {
Expand Down Expand Up @@ -1117,8 +1116,7 @@ fn savefile_derive_crate_deserialize(input: DeriveInput) -> TokenStream {
fn implement_reprc_hardcoded_false(name: syn::Ident, generics: syn::Generics) -> TokenStream {
let defspan = proc_macro2::Span::call_site();

let magic = format!("_IMPL_SAVEFILE_REPRC_FOR_{}", &name).to_string();
let dummy_const = syn::Ident::new(&magic, proc_macro2::Span::call_site());
let dummy_const = syn::Ident::new("_", proc_macro2::Span::call_site());
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
let extra_where = get_extra_where_clauses(&generics, where_clause,quote!{_savefile::prelude::WithSchema});
let uses = quote_spanned! { defspan =>
Expand Down Expand Up @@ -1170,8 +1168,8 @@ fn implement_reprc(field_infos: Vec<FieldInfo>, generics: syn::Generics, name: s
let uses = quote_spanned! { defspan =>
extern crate savefile as _savefile;
};
let magic = format!("_IMPL_SAVEFILE_REPRC_FOR_{}", &name).to_string();
let dummy_const = syn::Ident::new(&magic, proc_macro2::Span::call_site());

let dummy_const = syn::Ident::new("_", proc_macro2::Span::call_site());

for field in field_infos.windows(2) {
let field_name1 = field[0].ident.as_ref().expect("Field was expected to have a name");
Expand Down Expand Up @@ -1553,8 +1551,7 @@ fn savefile_derive_crate_introspect(input: DeriveInput) -> TokenStream {
//let Field = quote_spanned! { defspan => _savefile::prelude::Field };
//let Variant = quote_spanned! { defspan => _savefile::prelude::Variant };

let magic = format!("_IMPL_SAVEFILE_INTROSPECT_FOR_{}", &name).to_string();
let dummy_const = syn::Ident::new(&magic, proc_macro2::Span::call_site());
let dummy_const = syn::Ident::new("_", proc_macro2::Span::call_site());

let expanded = match &input.data {
&syn::Data::Enum(ref enum1) => {
Expand Down Expand Up @@ -1837,8 +1834,7 @@ fn savefile_derive_crate_withschema(input: DeriveInput) -> TokenStream {
let Field = quote_spanned! { defspan => _savefile::prelude::Field };
let Variant = quote_spanned! { defspan => _savefile::prelude::Variant };

let magic = format!("_IMPL_SAVEFILE_WITHSCHEMA_FOR_{}", &name).to_string();
let dummy_const = syn::Ident::new(&magic, proc_macro2::Span::call_site());
let dummy_const = syn::Ident::new("_", proc_macro2::Span::call_site());

let expanded = match &input.data {
&syn::Data::Enum(ref enum1) => {
Expand Down