From 27f847545a01622d26c16cc9222f81895e823ea7 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 19 Jul 2024 07:22:09 -0400 Subject: [PATCH] cleanup getters/setters --- .../salsa-macro-rules/src/setup_input_struct.rs | 11 ++++------- .../salsa-macro-rules/src/setup_interned_struct.rs | 7 ++----- .../salsa-macro-rules/src/setup_tracked_struct.rs | 7 ++----- components/salsa-macros/src/input.rs | 5 ++--- components/salsa-macros/src/interned.rs | 3 +-- components/salsa-macros/src/tracked_struct.rs | 3 +-- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/components/salsa-macro-rules/src/setup_input_struct.rs b/components/salsa-macro-rules/src/setup_input_struct.rs index f8dc364..b88dc07 100644 --- a/components/salsa-macro-rules/src/setup_input_struct.rs +++ b/components/salsa-macro-rules/src/setup_input_struct.rs @@ -20,14 +20,11 @@ macro_rules! setup_input_struct { // Field names field_ids: [$($field_id:ident),*], - // Visibilities for field accessor methods - field_vis: [$($field_vis:vis f),*], - // Names for field getter methods (typically `foo`) - field_getter_ids: [$($field_getter_id:ident),*], + field_getters: [$($field_getter_vis:vis $field_getter_id:ident),*], // Names for field setter methods (typically `set_foo`) - field_setter_ids: [$($field_setter_id:ident),*], + field_setters: [$($field_setter_vis:vis $field_setter_id:ident),*], // Field types field_tys: [$($field_ty:ty),*], @@ -135,7 +132,7 @@ macro_rules! setup_input_struct { } $( - $field_vis fn $field_getter_id<'db, $Db>(self, db: &'db $Db) -> $zalsa::maybe_cloned_ty!($field_option, 'db, $field_ty) + $field_getter_vis fn $field_getter_id<'db, $Db>(self, db: &'db $Db) -> $zalsa::maybe_cloned_ty!($field_option, 'db, $field_ty) where // FIXME(rust-lang/rust#65991): The `db` argument *should* have the type `dyn Database` $Db: ?Sized + $zalsa::Database, @@ -152,7 +149,7 @@ macro_rules! setup_input_struct { $( #[must_use] - $field_vis fn $field_setter_id<'db, $Db>(self, db: &'db mut $Db) -> impl salsa::Setter + 'db + $field_setter_vis fn $field_setter_id<'db, $Db>(self, db: &'db mut $Db) -> impl salsa::Setter + 'db where // FIXME(rust-lang/rust#65991): The `db` argument *should* have the type `dyn Database` $Db: ?Sized + $zalsa::Database, diff --git a/components/salsa-macro-rules/src/setup_interned_struct.rs b/components/salsa-macro-rules/src/setup_interned_struct.rs index d16eff2..8a225b2 100644 --- a/components/salsa-macro-rules/src/setup_interned_struct.rs +++ b/components/salsa-macro-rules/src/setup_interned_struct.rs @@ -23,11 +23,8 @@ macro_rules! setup_interned_struct { // Field names field_ids: [$($field_id:ident),*], - // Visibilities for field accessor methods - field_vis: [$($field_vis:vis f),*], - // Names for field setter methods (typically `set_foo`) - field_getter_ids: [$($field_getter_id:ident),*], + field_getters: [$($field_getter_vis:vis $field_getter_id:ident),*], // Field types field_tys: [$($field_ty:ty),*], @@ -137,7 +134,7 @@ macro_rules! setup_interned_struct { } $( - $field_vis fn $field_getter_id<$Db>(self, db: &'db $Db) -> $zalsa::maybe_cloned_ty!($field_option, 'db, $field_ty) + $field_getter_vis fn $field_getter_id<$Db>(self, db: &'db $Db) -> $zalsa::maybe_cloned_ty!($field_option, 'db, $field_ty) where // FIXME(rust-lang/rust#65991): The `db` argument *should* have the type `dyn Database` $Db: ?Sized + $zalsa::Database, diff --git a/components/salsa-macro-rules/src/setup_tracked_struct.rs b/components/salsa-macro-rules/src/setup_tracked_struct.rs index 21b2f1e..aa6d099 100644 --- a/components/salsa-macro-rules/src/setup_tracked_struct.rs +++ b/components/salsa-macro-rules/src/setup_tracked_struct.rs @@ -20,11 +20,8 @@ macro_rules! setup_tracked_struct { // Field names field_ids: [$($field_id:ident),*], - // Visibilities for field accessor methods - field_vis: [$($field_vis:vis f),*], - // Field names - field_getter_ids: [$($field_getter_id:ident),*], + field_getters: [$($field_getter_vis:vis $field_getter_id:ident),*], // Field types, may reference `db_lt` field_tys: [$($field_ty:ty),*], @@ -200,7 +197,7 @@ macro_rules! setup_tracked_struct { } $( - $field_vis fn $field_getter_id<$Db>(&self, db: &$db_lt $Db) -> $crate::maybe_cloned_ty!($field_option, $db_lt, $field_ty) + $field_getter_vis fn $field_getter_id<$Db>(&self, db: &$db_lt $Db) -> $crate::maybe_cloned_ty!($field_option, $db_lt, $field_ty) where // FIXME(rust-lang/rust#65991): The `db` argument *should* have the type `dyn Database` $Db: ?Sized + $zalsa::Database, diff --git a/components/salsa-macros/src/input.rs b/components/salsa-macros/src/input.rs index 08fa5f2..2ff9f18 100644 --- a/components/salsa-macros/src/input.rs +++ b/components/salsa-macros/src/input.rs @@ -106,9 +106,8 @@ impl Macro { new_fn: #new_fn, field_options: [#(#field_options),*], field_ids: [#(#field_ids),*], - field_vis: [#(#field_vis f),*], - field_getter_ids: [#(#field_getter_ids),*], - field_setter_ids: [#(#field_setter_ids),*], + field_getters: [#(#field_vis #field_getter_ids),*], + field_setters: [#(#field_vis #field_setter_ids),*], field_tys: [#(#field_tys),*], field_indices: [#(#field_indices),*], num_fields: #num_fields, diff --git a/components/salsa-macros/src/interned.rs b/components/salsa-macros/src/interned.rs index 1338242..50862b8 100644 --- a/components/salsa-macros/src/interned.rs +++ b/components/salsa-macros/src/interned.rs @@ -107,8 +107,7 @@ impl Macro { new_fn: #new_fn, field_options: [#(#field_options),*], field_ids: [#(#field_ids),*], - field_vis: [#(#field_vis f),*], - field_getter_ids: [#(#field_getter_ids),*], + field_getters: [#(#field_vis #field_getter_ids),*], field_tys: [#(#field_tys),*], field_indices: [#(#field_indices),*], num_fields: #num_fields, diff --git a/components/salsa-macros/src/tracked_struct.rs b/components/salsa-macros/src/tracked_struct.rs index 41b4419..9af4b03 100644 --- a/components/salsa-macros/src/tracked_struct.rs +++ b/components/salsa-macros/src/tracked_struct.rs @@ -104,8 +104,7 @@ impl Macro { db_lt: #db_lt, new_fn: #new_fn, field_ids: [#(#field_ids),*], - field_vis: [#(#field_vis f),*], - field_getter_ids: [#(#field_getter_ids),*], + field_getters: [#(#field_vis #field_getter_ids),*], field_tys: [#(#field_tys),*], field_indices: [#(#field_indices),*], id_field_indices: [#(#id_field_indices),*],